-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
.../TelegramVaporBot/Bot/Telegram/ModelExtensions/TGMaybeInaccessibleMessageExtensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Telegram-vapor-bot - Telegram Bot Swift SDK. | ||
|
||
/** | ||
This extension adds common properties betwwen TGMessage and TGInaccessibleMessage (chat, messageId and date) to TGMaybeInaccessibleMessage. These properties are always accessible no mather TGInaccessibleMessage is TGMessage or TGInaccessibleMessage. | ||
SeeAlso Telegram Bot API Reference: | ||
[MaybeInaccessibleMessage](https://core.telegram.org/bots/api#maybeinaccessiblemessage) | ||
**/ | ||
|
||
public extension TGMaybeInaccessibleMessage { | ||
var chat: TGChat { | ||
switch self { | ||
case .inaccessibleMessage(let msg): | ||
return msg.chat | ||
case .message(let msg): | ||
return msg.chat | ||
} | ||
} | ||
|
||
var messageId: Int { | ||
switch self { | ||
case .inaccessibleMessage(let msg): | ||
return msg.messageId | ||
case .message(let msg): | ||
return msg.messageId | ||
} | ||
} | ||
|
||
var date: Int { | ||
switch self { | ||
case .inaccessibleMessage(let msg): | ||
return msg.date | ||
case .message(let msg): | ||
return msg.date | ||
} | ||
} | ||
} |