diff --git a/.github/workflows/telegram-api.yml b/.github/workflows/telegram-api.yml index ca93ff0..b2e6a52 100644 --- a/.github/workflows/telegram-api.yml +++ b/.github/workflows/telegram-api.yml @@ -16,7 +16,7 @@ jobs: with: support-label: 'telegram api' issue-comment: > - **Github Issues** should be used only for problems with the library itself. + Please note that **Github Issues** should be used only for problems with the library code itself. For questions about Telegram API usage, you can search the [API official documentation](https://core.telegram.org/api#getting-started) or [click here to ask your question on **StackOverflow**](https://stackoverflow.com/questions/ask?tags=c%23+wtelegramclient+telegram-api) so the whole community can help and benefit. diff --git a/README.md b/README.md index a715c3e..44fe5df 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ This library works best with **.NET 5.0+** (faster, no dependencies) and is also This library can be used for any Telegram scenario including: - Sequential or parallel automated steps based on API requests/responses - Real-time [monitoring](https://wiz0u.github.io/WTelegramClient/EXAMPLES#updates) of incoming Updates/Messages -- Download/upload of files/media +- [Download](https://wiz0u.github.io/WTelegramClient/EXAMPLES#download)/[upload](https://wiz0u.github.io/WTelegramClient/EXAMPLES#upload) of files/media - Exchange end-to-end encrypted messages/files in [Secret Chats](https://wiz0u.github.io/WTelegramClient/EXAMPLES#e2e) - Building a full-featured interactive client diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs index 6907426..6f0021d 100644 --- a/src/TL.Helpers.cs +++ b/src/TL.Helpers.cs @@ -430,18 +430,21 @@ namespace TL public virtual Dictionary Chats => NoChats; private static readonly Dictionary NoUsers = new(); private static readonly Dictionary NoChats = new(); + public virtual (long mbox_id, int pts, int pts_count) GetMBox() => default; } partial class UpdatesCombined { public override Update[] UpdateList => updates; public override Dictionary Users => users; public override Dictionary Chats => chats; + public override (long mbox_id, int pts, int pts_count) GetMBox() => (-2, seq, seq - seq_start + 1); } partial class Updates { public override Update[] UpdateList => updates; public override Dictionary Users => users; public override Dictionary Chats => chats; + public override (long mbox_id, int pts, int pts_count) GetMBox() => (-2, seq, 1); } partial class UpdatesTooLong { public override Update[] UpdateList => Array.Empty(); } partial class UpdateShort { public override Update[] UpdateList => new[] { update }; } diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index 4068515..6c39236 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -3455,7 +3455,10 @@ namespace TL public class InputMessagesFilterPinned : MessagesFilter { } /// Object contains info on events occurred. See Derived classes: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , - public abstract class Update : IObject { } + public abstract class Update : IObject + { + public virtual (long mbox_id, int pts, int pts_count) GetMBox() => default; + } /// New message in a private chat or in a basic group. See [TLDef(0x1F2B0AFD)] public class UpdateNewMessage : Update @@ -3466,6 +3469,8 @@ namespace TL public int pts; /// Number of generated events public int pts_count; + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// Sent message with random_id client identifier was assigned an identifier. See [TLDef(0x4E90BFD6)] @@ -3486,6 +3491,8 @@ namespace TL public int pts; /// Number of generated events public int pts_count; + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// The user is preparing a message; typing, recording, uploading, etc. This update is valid for 6 seconds. If no further updates of this kind are received after 6 seconds, it should be considered that the user stopped doing whatever they were doing See [TLDef(0xC01E857F, inheritBefore = true)] @@ -3557,6 +3564,8 @@ namespace TL public EncryptedMessageBase message; /// New qts value, see updates » for more info. public int qts; + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// Interlocutor is typing a message in an encrypted chat. Update period is 6 second. If upon this time there is no repeated update, it shall be considered that the interlocutor stopped typing. See [TLDef(0x1710F156)] @@ -3689,6 +3698,8 @@ namespace TL /// Field has a value has_folder_id = 0x1, } + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// Outgoing messages were read See [TLDef(0x2F2F21BF)] @@ -3702,6 +3713,8 @@ namespace TL public int pts; /// Number of events that were generated public int pts_count; + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// An instant view webpage preview was generated See [TLDef(0x7F891213)] @@ -3713,6 +3726,8 @@ namespace TL public int pts; /// Number of events that were generated public int pts_count; + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// Contents of messages in the common message box were read See [TLDef(0xF8227181)] @@ -3733,6 +3748,8 @@ namespace TL /// Field has a value has_date = 0x1, } + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// There are new updates in the specified channel, the client must fetch them.
If the difference is too long or if the channel isn't currently in the states, start fetching from the specified pts. See
[TLDef(0x108D941F)] @@ -3750,6 +3767,8 @@ namespace TL /// Field has a value has_pts = 0x1, } + + public override (long, int, int) GetMBox() => (channel_id, pts, 0); } /// A new channel or supergroup is available, or info about an existing channel has changed and must be refeteched. See [TLDef(0x635B4C09)] @@ -3760,7 +3779,10 @@ namespace TL } /// A new message was sent in a channel/supergroup See [TLDef(0x62BA04D9)] - public class UpdateNewChannelMessage : UpdateNewMessage { } + public class UpdateNewChannelMessage : UpdateNewMessage + { + public override (long, int, int) GetMBox() => (message.Peer is PeerChannel pc ? pc.channel_id : 0, pts, pts_count); + } /// Incoming messages in a channel/supergroup were read See [TLDef(0x922E6E10)] public class UpdateReadChannelInbox : Update @@ -3783,6 +3805,8 @@ namespace TL /// Field has a value has_folder_id = 0x1, } + + public override (long, int, int) GetMBox() => (channel_id, pts, 0); } /// Some messages in a supergroup/channel were deleted See [TLDef(0xC32D5B12)] @@ -3790,6 +3814,8 @@ namespace TL { /// Channel ID public long channel_id; + + public override (long, int, int) GetMBox() => (channel_id, pts, pts_count); } /// The view counter of a message in a channel has changed See [TLDef(0xF226AC08, inheritBefore = true)] @@ -3897,7 +3923,10 @@ namespace TL } /// A message was edited in a channel/supergroup See [TLDef(0x1B3F4DF7)] - public class UpdateEditChannelMessage : UpdateEditMessage { } + public class UpdateEditChannelMessage : UpdateEditMessage + { + public override (long, int, int) GetMBox() => (message.Peer is PeerChannel pc ? pc.channel_id : 0, pts, pts_count); + } /// A callback button was pressed, and the button data was sent to the bot that created the button See [TLDef(0xB9CFC48D)] public class UpdateBotCallbackQuery : Update @@ -3937,6 +3966,8 @@ namespace TL public int pts; /// PTS count public int pts_count; + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// This notification is received by bots when a button is pressed See [TLDef(0x691E9052)] @@ -4011,6 +4042,8 @@ namespace TL { /// Channel/supergroup ID public long channel_id; + + public override (long, int, int) GetMBox() => (channel_id, pts, pts_count); } /// A dialog was pinned/unpinned See [TLDef(0x6E6FE51C)] @@ -4218,6 +4251,8 @@ namespace TL public int pts; /// Number of events that were generated public int pts_count; + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// Settings of a certain peer have changed See [TLDef(0x6A7E7366)] @@ -4282,6 +4317,8 @@ namespace TL public byte[][] options; /// New qts value, see updates » for more info. public int qts; + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// A new folder was added See [TLDef(0x26FFDE7D)] @@ -4420,6 +4457,8 @@ namespace TL /// Whether the messages were pinned or unpinned pinned = 0x1, } + + public override (long, int, int) GetMBox() => (0, pts, pts_count); } /// Messages were pinned/unpinned in a channel/supergroup See [TLDef(0x5BB98608)] @@ -4441,6 +4480,8 @@ namespace TL /// Whether the messages were pinned or unpinned pinned = 0x1, } + + public override (long, int, int) GetMBox() => (channel_id, pts, pts_count); } /// A new chat is available See [TLDef(0xF89A6A4E)] @@ -4518,6 +4559,8 @@ namespace TL /// Field has a value has_invite = 0x4, } + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// A participant has left, joined, was banned or admined in a channel or supergroup. See [TLDef(0x985D3ABB)] @@ -4553,6 +4596,8 @@ namespace TL /// Whether the participant joined using a chat folder deep link ». via_chatlist = 0x8, } + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// A bot was stopped or re-started. See [TLDef(0xC4870A49)] @@ -4566,6 +4611,8 @@ namespace TL public bool stopped; /// New qts value, see updates » for more info. public int qts; + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// New WebRTC parameters See [TLDef(0x0B783982)] @@ -4620,6 +4667,8 @@ namespace TL public ExportedChatInvite invite; /// QTS event sequence identifier public int qts; + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// New message reactions » are available See [TLDef(0x5E1B3CB8)] @@ -4832,6 +4881,8 @@ namespace TL public Peer peer; public Boost boost; public int qts; + + public override (long, int, int) GetMBox() => (-1, qts, 1); } /// See [TLDef(0x07B68920, inheritBefore = true)]