From f339fe11609c1e0429ab7fc42d36817b32040afa Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Sun, 20 Mar 2022 13:09:25 +0100
Subject: [PATCH 001/429] lock sessionStore while updating/writing buffer to
store (useful to avoid buffer copy for custom stores)
---
.github/dev.yml | 2 +-
EXAMPLES.md | 4 ++--
FAQ.md | 4 ++--
src/Session.cs | 25 ++++++++++++++-----------
4 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/.github/dev.yml b/.github/dev.yml
index cd48873..c557db8 100644
--- a/.github/dev.yml
+++ b/.github/dev.yml
@@ -2,7 +2,7 @@ pr: none
trigger:
- master
-name: 2.1.3-dev.$(Rev:r)
+name: 2.1.4-dev.$(Rev:r)
pool:
vmImage: ubuntu-latest
diff --git a/EXAMPLES.md b/EXAMPLES.md
index 455aa6b..e4f5e71 100644
--- a/EXAMPLES.md
+++ b/EXAMPLES.md
@@ -361,7 +361,7 @@ By default, WTelegramClient logs are displayed on the Console screen.
If you are not in a Console app or don't want the logs on screen, you can redirect them as you prefer:
```csharp
-// • Log to VS Output debugging pane in addition to default Console screen logging:
+// • Log to VS Output debugging pane in addition (+=) to default Console screen logging:
WTelegram.Helpers.Log += (lvl, str) => System.Diagnostics.Debug.WriteLine(str);
// • Log to file in replacement of default Console screen logging, using this static variable:
@@ -369,7 +369,7 @@ static StreamWriter WTelegramLogs = new StreamWriter("WTelegram.log", true, Enco
...
WTelegram.Helpers.Log = (lvl, str) => WTelegramLogs.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} [{"TDIWE!"[lvl]}] {str}");
-// • In an ASP.NET service, you will typically send logs to a ILogger:
+// • In an ASP.NET service, you will typically send logs to an ILogger:
WTelegram.Helpers.Log = (lvl, str) => _logger.Log((LogLevel)lvl, str);
```
diff --git a/FAQ.md b/FAQ.md
index e357937..179a272 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -174,7 +174,7 @@ There are various reasons why you may get this error. Here are the explanation a
1) On secondary DCs *(DC used to download files)*, a Connection shut down is considered "normal"
Your main DC is the one WTelegramClient connects to during login. Secondary DC connections are established and maintained when you download files.
The DC number for an operation or error is indicated with a prefix like "2>" on the log line.
-If Telegram servers decide to shutdown this secondary connection, it's not an issue, WTelegramClient will re-established the connection later if necessary.
+If Telegram servers decide to shutdown this secondary connection, it's not an issue, WTelegramClient will re-establish the connection later if necessary.
2) Occasional connection shutdowns on the main DC should be caught by WTelegramClient and the reactor should automatically reconnect to the DC
*(up to `MaxAutoReconnects` times)*.
@@ -185,7 +185,7 @@ You can choose to increase `MaxAutoReconnects` if it happens too often because y
In this case, the recommended action would be to dispose the client and recreate one
4) In case of slow Internet connection or if you break in the debugger for some time,
-you might also get Connection shutdown because your client couldn't send Pings to Telegram in the alloted time.
+you might also get Connection shutdown because your client couldn't send Pings to Telegram in the allotted time.
In this case, you can use the `PingInterval` property to increase the delay between pings *(for example 300 seconds instead of 60)*.
diff --git a/src/Session.cs b/src/Session.cs
index f718492..c4d3e9c 100644
--- a/src/Session.cs
+++ b/src/Session.cs
@@ -95,17 +95,20 @@ namespace WTelegram
var utf8Json = _jsonStream.GetBuffer();
var utf8JsonLen = (int)_jsonStream.Position;
int encryptedLen = 64 + (utf8JsonLen & ~15);
- if (encryptedLen > _encrypted.Length)
- Array.Copy(_encrypted, _encrypted = new byte[encryptedLen + 256], 16);
- _encryptor.TransformBlock(_sha256.ComputeHash(utf8Json, 0, utf8JsonLen), 0, 32, _encrypted, 16);
- _encryptor.TransformBlock(utf8Json, 0, encryptedLen - 64, _encrypted, 48);
- _encryptor.TransformFinalBlock(utf8Json, encryptedLen - 64, utf8JsonLen & 15).CopyTo(_encrypted, encryptedLen - 16);
- if (!_encryptor.CanReuseTransform) // under Mono, AES encryptor is not reusable
- using (var aes = Aes.Create())
- _encryptor = aes.CreateEncryptor(_reuseKey, _encrypted[0..16]);
- _store.Position = 0;
- _store.Write(_encrypted, 0, encryptedLen);
- _store.SetLength(encryptedLen);
+ lock (_store) // while updating _encrypted buffer and writing to store
+ {
+ if (encryptedLen > _encrypted.Length)
+ Array.Copy(_encrypted, _encrypted = new byte[encryptedLen + 256], 16);
+ _encryptor.TransformBlock(_sha256.ComputeHash(utf8Json, 0, utf8JsonLen), 0, 32, _encrypted, 16);
+ _encryptor.TransformBlock(utf8Json, 0, encryptedLen - 64, _encrypted, 48);
+ _encryptor.TransformFinalBlock(utf8Json, encryptedLen - 64, utf8JsonLen & 15).CopyTo(_encrypted, encryptedLen - 16);
+ if (!_encryptor.CanReuseTransform) // under Mono, AES encryptor is not reusable
+ using (var aes = Aes.Create())
+ _encryptor = aes.CreateEncryptor(_reuseKey, _encrypted[0..16]);
+ _store.Position = 0;
+ _store.Write(_encrypted, 0, encryptedLen);
+ _store.SetLength(encryptedLen);
+ }
_jsonStream.Position = 0;
_jsonWriter.Reset();
}
From b31c9b4366895849d511ba68588af83ac3f416ce Mon Sep 17 00:00:00 2001
From: Wizou <11647984+wiz0u@users.noreply.github.com>
Date: Mon, 21 Mar 2022 21:25:30 +0100
Subject: [PATCH 002/429] Split TL.Schema.cs and TL.Helpers.cs
---
src/TL.Extensions.cs | 250 ++
src/TL.Helpers.cs | 247 +-
src/TL.MTProto.cs | 5 +-
src/TL.Schema.cs | 8272 ----------------------------------------
src/TL.SchemaFuncs.cs | 8273 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 8527 insertions(+), 8520 deletions(-)
create mode 100644 src/TL.Extensions.cs
create mode 100644 src/TL.SchemaFuncs.cs
diff --git a/src/TL.Extensions.cs b/src/TL.Extensions.cs
new file mode 100644
index 0000000..c68d8e6
--- /dev/null
+++ b/src/TL.Extensions.cs
@@ -0,0 +1,250 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web;
+
+namespace TL
+{
+ public static class Extensions
+ {
+ private class CollectorPeer : Peer
+ {
+ public override long ID => 0;
+ internal Dictionary _users;
+ internal Dictionary _chats;
+ internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats)
+ {
+ lock (_users)
+ foreach (var user in users.Values)
+ if (user != null)
+ if (!user.flags.HasFlag(User.Flags.min) || !_users.TryGetValue(user.id, out var prevUser) || prevUser.flags.HasFlag(User.Flags.min))
+ _users[user.id] = user;
+ lock (_chats)
+ foreach (var kvp in chats)
+ if (kvp.Value is not Channel channel)
+ _chats[kvp.Key] = kvp.Value;
+ else if (!channel.flags.HasFlag(Channel.Flags.min) || !_chats.TryGetValue(channel.id, out var prevChat) || prevChat is not Channel prevChannel || prevChannel.flags.HasFlag(Channel.Flags.min))
+ _chats[kvp.Key] = channel;
+ return null;
+ }
+ }
+
+ /// Accumulate users/chats found in this structure in your dictionaries, ignoring Min constructors when the full object is already stored
+ /// The structure having a users
+ ///
+ ///
+ public static void CollectUsersChats(this IPeerResolver structure, Dictionary users, Dictionary chats)
+ => structure.UserOrChat(new CollectorPeer { _users = users, _chats = chats });
+ }
+
+ public static class Markdown
+ {
+ /// Converts a Markdown text into the (Entities + plain text) format used by Telegram messages
+ /// Client, used for getting access_hash for tg://user?id= URLs
+ /// [in] The Markdown text
[out] The same (plain) text, stripped of all Markdown notation
+ /// The array of formatting entities that you can pass (along with the plain text) to SendMessageAsync or SendMediaAsync
+ public static MessageEntity[] MarkdownToEntities(this WTelegram.Client client, ref string text)
+ {
+ var entities = new List();
+ var sb = new StringBuilder(text);
+ for (int offset = 0; offset < sb.Length;)
+ {
+ switch (sb[offset])
+ {
+ case '\\': sb.Remove(offset++, 1); break;
+ case '*': ProcessEntity(); break;
+ case '~': ProcessEntity(); break;
+ case '_':
+ if (offset + 1 < sb.Length && sb[offset + 1] == '_')
+ {
+ sb.Remove(offset, 1);
+ ProcessEntity();
+ }
+ else
+ ProcessEntity();
+ break;
+ case '|':
+ if (offset + 1 < sb.Length && sb[offset + 1] == '|')
+ {
+ sb.Remove(offset, 1);
+ ProcessEntity();
+ }
+ else
+ offset++;
+ break;
+ case '`':
+ if (offset + 2 < sb.Length && sb[offset + 1] == '`' && sb[offset + 2] == '`')
+ {
+ int len = 3;
+ if (entities.FindLast(e => e.length == -1) is MessageEntityPre pre)
+ pre.length = offset - pre.offset;
+ else
+ {
+ while (offset + len < sb.Length && !char.IsWhiteSpace(sb[offset + len]))
+ len++;
+ entities.Add(new MessageEntityPre { offset = offset, length = -1, language = sb.ToString(offset + 3, len - 3) });
+ }
+ sb.Remove(offset, len);
+ }
+ else
+ ProcessEntity();
+ break;
+ case '[':
+ entities.Add(new MessageEntityTextUrl { offset = offset, length = -1 });
+ sb.Remove(offset, 1);
+ break;
+ case ']':
+ if (offset + 2 < sb.Length && sb[offset + 1] == '(')
+ {
+ var lastIndex = entities.FindLastIndex(e => e.length == -1);
+ if (lastIndex >= 0 && entities[lastIndex] is MessageEntityTextUrl textUrl)
+ {
+ textUrl.length = offset - textUrl.offset;
+ int offset2 = offset + 2;
+ while (offset2 < sb.Length)
+ {
+ char c = sb[offset2++];
+ if (c == '\\') sb.Remove(offset2 - 1, 1);
+ else if (c == ')') break;
+ }
+ textUrl.url = sb.ToString(offset + 2, offset2 - offset - 3);
+ if (textUrl.url.StartsWith("tg://user?id=") && long.TryParse(textUrl.url[13..], out var user_id) && client.GetAccessHashFor(user_id) is long hash)
+ entities[lastIndex] = new InputMessageEntityMentionName { offset = textUrl.offset, length = textUrl.length, user_id = new InputUser { user_id = user_id, access_hash = hash } };
+ sb.Remove(offset, offset2 - offset);
+ break;
+ }
+ }
+ offset++;
+ break;
+ default: offset++; break;
+ }
+
+ void ProcessEntity() where T : MessageEntity, new()
+ {
+ if (entities.LastOrDefault(e => e.length == -1) is T prevEntity)
+ prevEntity.length = offset - prevEntity.offset;
+ else
+ entities.Add(new T { offset = offset, length = -1 });
+ sb.Remove(offset, 1);
+ }
+ }
+ text = sb.ToString();
+ return entities.Count == 0 ? null : entities.ToArray();
+ }
+
+ /// Insert backslashes in front of Markdown reserved characters
+ /// The text to escape
+ /// The escaped text, ready to be used in MarkdownToEntities without problems
+ public static string Escape(string text)
+ {
+ StringBuilder sb = null;
+ for (int index = 0, added = 0; index < text.Length; index++)
+ {
+ switch (text[index])
+ {
+ case '_': case '*': case '~': case '`': case '#': case '+': case '-': case '=': case '.': case '!':
+ case '[': case ']': case '(': case ')': case '{': case '}': case '>': case '|': case '\\':
+ sb ??= new StringBuilder(text, text.Length + 32);
+ sb.Insert(index + added++, '\\');
+ break;
+ }
+ }
+ return sb?.ToString() ?? text;
+ }
+ }
+
+ public static class HtmlText
+ {
+ /// Converts an HTML-formatted text into the (Entities + plain text) format used by Telegram messages
+ /// Client, used for getting access_hash for tg://user?id= URLs
+ /// [in] The HTML-formatted text
[out] The same (plain) text, stripped of all HTML tags
+ /// The array of formatting entities that you can pass (along with the plain text) to SendMessageAsync or SendMediaAsync
+ public static MessageEntity[] HtmlToEntities(this WTelegram.Client client, ref string text)
+ {
+ var entities = new List();
+ var sb = new StringBuilder(text);
+ int end;
+ for (int offset = 0; offset < sb.Length;)
+ {
+ char c = sb[offset];
+ if (c == '&')
+ {
+ for (end = offset + 1; end < sb.Length; end++)
+ if (sb[end] == ';') break;
+ if (end >= sb.Length) break;
+ var html = HttpUtility.HtmlDecode(sb.ToString(offset, end - offset + 1));
+ if (html.Length == 1)
+ {
+ sb[offset] = html[0];
+ sb.Remove(++offset, end - offset + 1);
+ }
+ else
+ offset = end + 1;
+ }
+ else if (c == '<')
+ {
+ for (end = ++offset; end < sb.Length; end++)
+ if (sb[end] == '>') break;
+ if (end >= sb.Length) break;
+ bool closing = sb[offset] == '/';
+ var tag = closing ? sb.ToString(offset + 1, end - offset - 1) : sb.ToString(offset, end - offset);
+ sb.Remove(--offset, end + 1 - offset);
+ switch (tag)
+ {
+ case "b": case "strong": ProcessEntity(); break;
+ case "i": case "em": ProcessEntity(); break;
+ case "u": case "ins": ProcessEntity(); break;
+ case "s": case "strike": case "del": ProcessEntity(); break;
+ case "span class=\"tg-spoiler\"":
+ case "span" when closing:
+ case "tg-spoiler": ProcessEntity(); break;
+ case "code": ProcessEntity(); break;
+ case "pre": ProcessEntity(); break;
+ default:
+ if (closing)
+ {
+ if (tag == "a")
+ {
+ var prevEntity = entities.LastOrDefault(e => e.length == -1);
+ if (prevEntity is InputMessageEntityMentionName or MessageEntityTextUrl)
+ prevEntity.length = offset - prevEntity.offset;
+ }
+ }
+ else if (tag.StartsWith("a href=\"") && tag.EndsWith("\""))
+ {
+ tag = tag[8..^1];
+ if (tag.StartsWith("tg://user?id=") && long.TryParse(tag[13..], out var user_id) && client.GetAccessHashFor(user_id) is long hash)
+ entities.Add(new InputMessageEntityMentionName { offset = offset, length = -1, user_id = new InputUser { user_id = user_id, access_hash = hash } });
+ else
+ entities.Add(new MessageEntityTextUrl { offset = offset, length = -1, url = tag });
+ }
+ else if (tag.StartsWith("code class=\"language-") && tag.EndsWith("\""))
+ {
+ if (entities.LastOrDefault(e => e.length == -1) is MessageEntityPre prevEntity)
+ prevEntity.language = tag[21..^1];
+ }
+ break;
+ }
+
+ void ProcessEntity() where T : MessageEntity, new()
+ {
+ if (!closing)
+ entities.Add(new T { offset = offset, length = -1 });
+ else if (entities.LastOrDefault(e => e.length == -1) is T prevEntity)
+ prevEntity.length = offset - prevEntity.offset;
+ }
+ }
+ else
+ offset++;
+ }
+ text = sb.ToString();
+ return entities.Count == 0 ? null : entities.ToArray();
+ }
+
+ /// Replace special HTML characters with their &xx; equivalent
+ /// The text to make HTML-safe
+ /// The HTML-safe text, ready to be used in HtmlToEntities without problems
+ public static string Escape(string text)
+ => text.Replace("&", "&").Replace("<", "<").Replace(">", ">");
+ }
+}
diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs
index 96ccc36..5649e59 100644
--- a/src/TL.Helpers.cs
+++ b/src/TL.Helpers.cs
@@ -14,8 +14,8 @@ namespace TL
InputPeer ToInputPeer();
}
- partial class InputPeer { public static InputPeerSelf Self => new(); }
- partial class InputUser { public static InputUserSelf Self => new(); }
+ partial class InputPeer { public static InputPeerSelf Self => new(); }
+ partial class InputUser { public static InputUserSelf Self => new(); }
partial class InputPeerChannel { public static implicit operator InputChannel(InputPeerChannel channel) => new() { channel_id = channel.channel_id, access_hash = channel.access_hash }; }
partial class InputPeerUser { public static implicit operator InputUser(InputPeerUser user) => new() { user_id = user.user_id, access_hash = user.access_hash }; }
partial class InputUser { public static implicit operator InputPeerUser(InputUser user) => new() { user_id = user.user_id, access_hash = user.access_hash }; }
@@ -519,247 +519,4 @@ namespace TL
return dic;
}
}
-
- public static class Helpers
- {
- private class CollectorPeer : Peer
- {
- public override long ID => 0;
- internal Dictionary _users;
- internal Dictionary _chats;
- internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats)
- {
- lock (_users)
- foreach (var user in users.Values)
- if (user != null)
- if (!user.flags.HasFlag(User.Flags.min) || !_users.TryGetValue(user.id, out var prevUser) || prevUser.flags.HasFlag(User.Flags.min))
- _users[user.id] = user;
- lock (_chats)
- foreach (var kvp in chats)
- if (kvp.Value is not Channel channel)
- _chats[kvp.Key] = kvp.Value;
- else if (!channel.flags.HasFlag(Channel.Flags.min) || !_chats.TryGetValue(channel.id, out var prevChat) || prevChat is not Channel prevChannel || prevChannel.flags.HasFlag(Channel.Flags.min))
- _chats[kvp.Key] = channel;
- return null;
- }
- }
-
- /// Accumulate users/chats found in this structure in your dictionaries, ignoring Min constructors when the full object is already stored
- /// The structure having a users
- ///
- ///
- public static void CollectUsersChats(this IPeerResolver structure, Dictionary users, Dictionary chats)
- => structure.UserOrChat(new CollectorPeer { _users = users, _chats = chats });
- }
-
- public static class Markdown
- {
- /// Converts a Markdown text into the (Entities + plain text) format used by Telegram messages
- /// Client, used for getting access_hash for tg://user?id= URLs
- /// [in] The Markdown text
[out] The same (plain) text, stripped of all Markdown notation
- /// The array of formatting entities that you can pass (along with the plain text) to SendMessageAsync or SendMediaAsync
- public static MessageEntity[] MarkdownToEntities(this WTelegram.Client client, ref string text)
- {
- var entities = new List();
- var sb = new StringBuilder(text);
- for (int offset = 0; offset < sb.Length;)
- {
- switch (sb[offset])
- {
- case '\\': sb.Remove(offset++, 1); break;
- case '*': ProcessEntity(); break;
- case '~': ProcessEntity(); break;
- case '_':
- if (offset + 1 < sb.Length && sb[offset + 1] == '_')
- {
- sb.Remove(offset, 1);
- ProcessEntity();
- }
- else
- ProcessEntity();
- break;
- case '|':
- if (offset + 1 < sb.Length && sb[offset + 1] == '|')
- {
- sb.Remove(offset, 1);
- ProcessEntity();
- }
- else
- offset++;
- break;
- case '`':
- if (offset + 2 < sb.Length && sb[offset + 1] == '`' && sb[offset + 2] == '`')
- {
- int len = 3;
- if (entities.FindLast(e => e.length == -1) is MessageEntityPre pre)
- pre.length = offset - pre.offset;
- else
- {
- while (offset + len < sb.Length && !char.IsWhiteSpace(sb[offset + len]))
- len++;
- entities.Add(new MessageEntityPre { offset = offset, length = -1, language = sb.ToString(offset + 3, len - 3) });
- }
- sb.Remove(offset, len);
- }
- else
- ProcessEntity();
- break;
- case '[':
- entities.Add(new MessageEntityTextUrl { offset = offset, length = -1 });
- sb.Remove(offset, 1);
- break;
- case ']':
- if (offset + 2 < sb.Length && sb[offset + 1] == '(')
- {
- var lastIndex = entities.FindLastIndex(e => e.length == -1);
- if (lastIndex >= 0 && entities[lastIndex] is MessageEntityTextUrl textUrl)
- {
- textUrl.length = offset - textUrl.offset;
- int offset2 = offset + 2;
- while (offset2 < sb.Length)
- {
- char c = sb[offset2++];
- if (c == '\\') sb.Remove(offset2 - 1, 1);
- else if (c == ')') break;
- }
- textUrl.url = sb.ToString(offset + 2, offset2 - offset - 3);
- if (textUrl.url.StartsWith("tg://user?id=") && long.TryParse(textUrl.url[13..], out var user_id) && client.GetAccessHashFor(user_id) is long hash)
- entities[lastIndex] = new InputMessageEntityMentionName { offset = textUrl.offset, length = textUrl.length, user_id = new InputUser { user_id = user_id, access_hash = hash } };
- sb.Remove(offset, offset2 - offset);
- break;
- }
- }
- offset++;
- break;
- default: offset++; break;
- }
-
- void ProcessEntity() where T : MessageEntity, new()
- {
- if (entities.LastOrDefault(e => e.length == -1) is T prevEntity)
- prevEntity.length = offset - prevEntity.offset;
- else
- entities.Add(new T { offset = offset, length = -1 });
- sb.Remove(offset, 1);
- }
- }
- text = sb.ToString();
- return entities.Count == 0 ? null : entities.ToArray();
- }
-
- /// Insert backslashes in front of Markdown reserved characters
- /// The text to escape
- /// The escaped text, ready to be used in MarkdownToEntities without problems
- public static string Escape(string text)
- {
- StringBuilder sb = null;
- for (int index = 0, added = 0; index < text.Length; index++)
- {
- switch (text[index])
- {
- case '_': case '*': case '~': case '`': case '#': case '+': case '-': case '=': case '.': case '!':
- case '[': case ']': case '(': case ')': case '{': case '}': case '>': case '|': case '\\':
- sb ??= new StringBuilder(text, text.Length + 32);
- sb.Insert(index + added++, '\\');
- break;
- }
- }
- return sb?.ToString() ?? text;
- }
- }
-
- public static class HtmlText
- {
- /// Converts an HTML-formatted text into the (Entities + plain text) format used by Telegram messages
- /// Client, used for getting access_hash for tg://user?id= URLs
- /// [in] The HTML-formatted text
[out] The same (plain) text, stripped of all HTML tags
- /// The array of formatting entities that you can pass (along with the plain text) to SendMessageAsync or SendMediaAsync
- public static MessageEntity[] HtmlToEntities(this WTelegram.Client client, ref string text)
- {
- var entities = new List();
- var sb = new StringBuilder(text);
- int end;
- for (int offset = 0; offset < sb.Length;)
- {
- char c = sb[offset];
- if (c == '&')
- {
- for (end = offset + 1; end < sb.Length; end++)
- if (sb[end] == ';') break;
- if (end >= sb.Length) break;
- var html = HttpUtility.HtmlDecode(sb.ToString(offset, end - offset + 1));
- if (html.Length == 1)
- {
- sb[offset] = html[0];
- sb.Remove(++offset, end - offset + 1);
- }
- else
- offset = end + 1;
- }
- else if (c == '<')
- {
- for (end = ++offset; end < sb.Length; end++)
- if (sb[end] == '>') break;
- if (end >= sb.Length) break;
- bool closing = sb[offset] == '/';
- var tag = closing ? sb.ToString(offset + 1, end - offset - 1) : sb.ToString(offset, end - offset);
- sb.Remove(--offset, end + 1 - offset);
- switch (tag)
- {
- case "b": case "strong": ProcessEntity(); break;
- case "i": case "em": ProcessEntity(); break;
- case "u": case "ins": ProcessEntity(); break;
- case "s": case "strike": case "del": ProcessEntity(); break;
- case "span class=\"tg-spoiler\"":
- case "span" when closing:
- case "tg-spoiler": ProcessEntity(); break;
- case "code": ProcessEntity(); break;
- case "pre": ProcessEntity(); break;
- default:
- if (closing)
- {
- if (tag == "a")
- {
- var prevEntity = entities.LastOrDefault(e => e.length == -1);
- if (prevEntity is InputMessageEntityMentionName or MessageEntityTextUrl)
- prevEntity.length = offset - prevEntity.offset;
- }
- }
- else if (tag.StartsWith("a href=\"") && tag.EndsWith("\""))
- {
- tag = tag[8..^1];
- if (tag.StartsWith("tg://user?id=") && long.TryParse(tag[13..], out var user_id) && client.GetAccessHashFor(user_id) is long hash)
- entities.Add(new InputMessageEntityMentionName { offset = offset, length = -1, user_id = new InputUser { user_id = user_id, access_hash = hash } });
- else
- entities.Add(new MessageEntityTextUrl { offset = offset, length = -1, url = tag });
- }
- else if (tag.StartsWith("code class=\"language-") && tag.EndsWith("\""))
- {
- if (entities.LastOrDefault(e => e.length == -1) is MessageEntityPre prevEntity)
- prevEntity.language = tag[21..^1];
- }
- break;
- }
-
- void ProcessEntity() where T : MessageEntity, new()
- {
- if (!closing)
- entities.Add(new T { offset = offset, length = -1 });
- else if (entities.LastOrDefault(e => e.length == -1) is T prevEntity)
- prevEntity.length = offset - prevEntity.offset;
- }
- }
- else
- offset++;
- }
- text = sb.ToString();
- return entities.Count == 0 ? null : entities.ToArray();
- }
-
- /// Replace special HTML characters with their &xx; equivalent
- /// The text to make HTML-safe
- /// The HTML-safe text, ready to be used in HtmlToEntities without problems
- public static string Escape(string text)
- => text.Replace("&", "&").Replace("<", "<").Replace(">", ">");
- }
}
diff --git a/src/TL.MTProto.cs b/src/TL.MTProto.cs
index 47564bd..e05fe98 100644
--- a/src/TL.MTProto.cs
+++ b/src/TL.MTProto.cs
@@ -1,11 +1,10 @@
using System;
using System.Threading.Tasks;
+using TL.Methods;
+using Client = WTelegram.Client;
namespace TL
{
- using TL.Methods;
- using Client = WTelegram.Client;
-
[TLDef(0x05162463)] //resPQ#05162463 nonce:int128 server_nonce:int128 pq:bytes server_public_key_fingerprints:Vector = ResPQ
public class ResPQ : IObject
{
diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs
index a512d78..e97063b 100644
--- a/src/TL.Schema.cs
+++ b/src/TL.Schema.cs
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
namespace TL
{
- using TL.Methods;
- using Client = WTelegram.Client;
-
/// Boolean type. See
public enum Bool : uint
{
@@ -12735,8272 +12731,4 @@ namespace TL
/// Stream key
public string key;
}
-
- // ---functions---
-
- public static class SchemaExtensions
- {
- /// Invokes a query after successful completion of one of the previous queries. See
- /// Message identifier on which a current query depends
- /// The query itself
- public static Task InvokeAfterMsg(this Client client, long msg_id, IMethod query)
- => client.Invoke(new InvokeAfterMsg
- {
- msg_id = msg_id,
- query = query,
- });
-
- /// Invokes a query after a successful completion of previous queries See
- /// List of messages on which a current query depends
- /// The query itself
- public static Task InvokeAfterMsgs(this Client client, long[] msg_ids, IMethod query)
- => client.Invoke(new InvokeAfterMsgs
- {
- msg_ids = msg_ids,
- query = query,
- });
-
- /// Initialize connection See Possible codes: 400 (details)
- /// Application identifier (see. App configuration)
- /// Device model
- /// Operation system version
- /// Application version
- /// Code for the language used on the device's OS, ISO 639-1 standard
- /// Language pack to use
- /// Code for the language used on the client, ISO 639-1 standard
- /// Info about an MTProto proxy
- /// Additional initConnection parameters.
For now, only the tz_offset field is supported, for specifying timezone offset in seconds.
- /// The query itself
- public static Task InitConnection(this Client client, int api_id, string device_model, string system_version, string app_version, string system_lang_code, string lang_pack, string lang_code, IMethod query, InputClientProxy proxy = null, JSONValue params_ = null)
- => client.Invoke(new InitConnection
- {
- flags = (InitConnection.Flags)((proxy != null ? 0x1 : 0) | (params_ != null ? 0x2 : 0)),
- api_id = api_id,
- device_model = device_model,
- system_version = system_version,
- app_version = app_version,
- system_lang_code = system_lang_code,
- lang_pack = lang_pack,
- lang_code = lang_code,
- proxy = proxy,
- params_ = params_,
- query = query,
- });
-
- /// Invoke the specified query using the specified API layer See Possible codes: 400,403 (details)
- /// The layer to use
- /// The query
- public static Task InvokeWithLayer(this Client client, int layer, IMethod query)
- => client.Invoke(new InvokeWithLayer
- {
- layer = layer,
- query = query,
- });
-
- /// Invoke a request without subscribing the used connection for updates (this is enabled by default for file queries). See
- /// The query
- public static Task InvokeWithoutUpdates(this Client client, IMethod query)
- => client.Invoke(new InvokeWithoutUpdates
- {
- query = query,
- });
-
- /// Invoke with the given message range See
- /// Message range
- /// Query
- public static Task InvokeWithMessagesRange(this Client client, MessageRange range, IMethod query)
- => client.Invoke(new InvokeWithMessagesRange
- {
- range = range,
- query = query,
- });
-
- /// Invoke a method within a takeout session See
- /// Takeout session ID
- /// Query
- public static Task InvokeWithTakeout(this Client client, long takeout_id, IMethod query)
- => client.Invoke(new InvokeWithTakeout
- {
- takeout_id = takeout_id,
- query = query,
- });
-
- /// Send the verification code for login See Possible codes: 400,406,500 (details)
- /// Phone number in international format
- /// Application identifier (see App configuration)
- /// Application secret hash (see App configuration)
- /// Settings for the code type to send
- public static Task Auth_SendCode(this Client client, string phone_number, int api_id, string api_hash, CodeSettings settings)
- => client.Invoke(new Auth_SendCode
- {
- phone_number = phone_number,
- api_id = api_id,
- api_hash = api_hash,
- settings = settings,
- });
-
- /// Registers a validated phone number in the system. See Possible codes: 400,406 (details)
- /// Phone number in the international format
- /// SMS-message ID
- /// New user first name
- /// New user last name
- public static Task Auth_SignUp(this Client client, string phone_number, string phone_code_hash, string first_name, string last_name)
- => client.Invoke(new Auth_SignUp
- {
- phone_number = phone_number,
- phone_code_hash = phone_code_hash,
- first_name = first_name,
- last_name = last_name,
- });
-
- /// Signs in a user with a validated phone number. See Possible codes: 400,406,500 (details)
- /// Phone number in the international format
- /// SMS-message ID, obtained from auth.sendCode
- /// Valid numerical code from the SMS-message
- public static Task Auth_SignIn(this Client client, string phone_number, string phone_code_hash, string phone_code)
- => client.Invoke(new Auth_SignIn
- {
- phone_number = phone_number,
- phone_code_hash = phone_code_hash,
- phone_code = phone_code,
- });
-
- /// Logs out the user. See [bots: ✓]
- public static Task Auth_LogOut(this Client client)
- => client.Invoke(new Auth_LogOut
- {
- });
-
- /// Terminates all user's authorized sessions except for the current one. See Possible codes: 406 (details)
- public static Task Auth_ResetAuthorizations(this Client client)
- => client.Invoke(new Auth_ResetAuthorizations
- {
- });
-
- /// Returns data for copying authorization to another data-center. See [bots: ✓] Possible codes: 400 (details)
- /// Number of a target data-center
- public static Task Auth_ExportAuthorization(this Client client, int dc_id)
- => client.Invoke(new Auth_ExportAuthorization
- {
- dc_id = dc_id,
- });
-
- /// Logs in a user using a key transmitted from his native data-center. See [bots: ✓] Possible codes: 400 (details)
- /// User ID
- /// Authorization key
- public static Task Auth_ImportAuthorization(this Client client, long id, byte[] bytes)
- => client.Invoke(new Auth_ImportAuthorization
- {
- id = id,
- bytes = bytes,
- });
-
- /// Binds a temporary authorization key temp_auth_key_id to the permanent authorization key perm_auth_key_id. Each permanent key may only be bound to one temporary key at a time, binding a new temporary key overwrites the previous one. See [bots: ✓] Possible codes: 400 (details)
- /// Permanent auth_key_id to bind to
- /// Random long from Binding message contents
- /// Unix timestamp to invalidate temporary key, see Binding message contents
- /// See Generating encrypted_message
- public static Task Auth_BindTempAuthKey(this Client client, long perm_auth_key_id, long nonce, DateTime expires_at, byte[] encrypted_message)
- => client.Invoke(new Auth_BindTempAuthKey
- {
- perm_auth_key_id = perm_auth_key_id,
- nonce = nonce,
- expires_at = expires_at,
- encrypted_message = encrypted_message,
- });
-
- /// Login as a bot See [bots: ✓] Possible codes: 400 (details)
- /// Application identifier (see. App configuration)
- /// Application identifier hash (see. App configuration)
- /// Bot token (see bots)
- public static Task Auth_ImportBotAuthorization(this Client client, int flags, int api_id, string api_hash, string bot_auth_token)
- => client.Invoke(new Auth_ImportBotAuthorization
- {
- flags = flags,
- api_id = api_id,
- api_hash = api_hash,
- bot_auth_token = bot_auth_token,
- });
-
- /// Try logging to an account protected by a 2FA password. See Possible codes: 400 (details)
- /// The account's password (see SRP)
- public static Task Auth_CheckPassword(this Client client, InputCheckPasswordSRP password)
- => client.Invoke(new Auth_CheckPassword
- {
- password = password,
- });
-
- /// Request recovery code of a 2FA password, only for accounts with a recovery email configured. See Possible codes: 400 (details)
- public static Task Auth_RequestPasswordRecovery(this Client client)
- => client.Invoke(new Auth_RequestPasswordRecovery
- {
- });
-
- /// Reset the 2FA password using the recovery code sent using auth.requestPasswordRecovery. See Possible codes: 400 (details)
- /// Code received via email
- /// New password
- public static Task Auth_RecoverPassword(this Client client, string code, Account_PasswordInputSettings new_settings = null)
- => client.Invoke(new Auth_RecoverPassword
- {
- flags = (Auth_RecoverPassword.Flags)(new_settings != null ? 0x1 : 0),
- code = code,
- new_settings = new_settings,
- });
-
- /// Resend the login code via another medium, the phone code type is determined by the return value of the previous auth.sendCode/auth.resendCode: see login for more info. See Possible codes: 400,406 (details)
- /// The phone number
- /// The phone code hash obtained from auth.sendCode
- public static Task Auth_ResendCode(this Client client, string phone_number, string phone_code_hash)
- => client.Invoke(new Auth_ResendCode
- {
- phone_number = phone_number,
- phone_code_hash = phone_code_hash,
- });
-
- /// Cancel the login verification code See Possible codes: 400,406 (details)
- /// Phone number
- /// Phone code hash from auth.sendCode
- public static Task Auth_CancelCode(this Client client, string phone_number, string phone_code_hash)
- => client.Invoke(new Auth_CancelCode
- {
- phone_number = phone_number,
- phone_code_hash = phone_code_hash,
- });
-
- /// Delete all temporary authorization keys except for the ones specified See [bots: ✓]
- /// The auth keys that shouldn't be dropped.
- public static Task Auth_DropTempAuthKeys(this Client client, long[] except_auth_keys = null)
- => client.Invoke(new Auth_DropTempAuthKeys
- {
- except_auth_keys = except_auth_keys,
- });
-
- /// Generate a login token, for login via QR code.
The generated login token should be encoded using base64url, then shown as a tg://login?token=base64encodedtoken URL in the QR code. See Possible codes: 400 (details)
- /// Application identifier (see. App configuration)
- /// Application identifier hash (see. App configuration)
- /// List of already logged-in user IDs, to prevent logging in twice with the same user
- public static Task Auth_ExportLoginToken(this Client client, int api_id, string api_hash, long[] except_ids = null)
- => client.Invoke(new Auth_ExportLoginToken
- {
- api_id = api_id,
- api_hash = api_hash,
- except_ids = except_ids,
- });
-
- /// Login using a redirected login token, generated in case of DC mismatch during QR code login. See Possible codes: 400 (details)
- /// Login token
- public static Task Auth_ImportLoginToken(this Client client, byte[] token)
- => client.Invoke(new Auth_ImportLoginToken
- {
- token = token,
- });
-
- /// Accept QR code login token, logging in the app that generated it. See Possible codes: 400 (details)
- /// Login token embedded in QR code, for more info, see login via QR code.
- public static Task Auth_AcceptLoginToken(this Client client, byte[] token)
- => client.Invoke(new Auth_AcceptLoginToken
- {
- token = token,
- });
-
- /// Check if the 2FA recovery code sent using auth.requestPasswordRecovery is valid, before passing it to auth.recoverPassword. See Possible codes: 400 (details)
- /// Code received via email
- public static Task Auth_CheckRecoveryPassword(this Client client, string code)
- => client.Invoke(new Auth_CheckRecoveryPassword
- {
- code = code,
- });
-
- /// Register device to receive PUSH notifications See Possible codes: 400 (details)
- /// Avoid receiving (silent and invisible background) notifications. Useful to save battery.
- /// Device token type.
Possible values:
1 - APNS (device token for apple push)
2 - FCM (firebase token for google firebase)
3 - MPNS (channel URI for microsoft push)
4 - Simple push (endpoint for firefox's simple push API)
5 - Ubuntu phone (token for ubuntu push)
6 - Blackberry (token for blackberry push)
7 - Unused
8 - WNS (windows push)
9 - APNS VoIP (token for apple push VoIP)
10 - Web push (web push, see below)
11 - MPNS VoIP (token for microsoft push VoIP)
12 - Tizen (token for tizen push)
For 10 web push, the token must be a JSON-encoded object containing the keys described in PUSH updates
- /// Device token
- /// If is transmitted, a sandbox-certificate will be used during transmission.
- /// For FCM and APNS VoIP, optional encryption key used to encrypt push notifications
- /// List of user identifiers of other users currently using the client
- public static Task Account_RegisterDevice(this Client client, int token_type, string token, bool app_sandbox, byte[] secret, long[] other_uids, bool no_muted = false)
- => client.Invoke(new Account_RegisterDevice
- {
- flags = (Account_RegisterDevice.Flags)(no_muted ? 0x1 : 0),
- token_type = token_type,
- token = token,
- app_sandbox = app_sandbox,
- secret = secret,
- other_uids = other_uids,
- });
-
- /// Deletes a device by its token, stops sending PUSH-notifications to it. See Possible codes: 400 (details)
- /// Device token type.
Possible values:
1 - APNS (device token for apple push)
2 - FCM (firebase token for google firebase)
3 - MPNS (channel URI for microsoft push)
4 - Simple push (endpoint for firefox's simple push API)
5 - Ubuntu phone (token for ubuntu push)
6 - Blackberry (token for blackberry push)
7 - Unused
8 - WNS (windows push)
9 - APNS VoIP (token for apple push VoIP)
10 - Web push (web push, see below)
11 - MPNS VoIP (token for microsoft push VoIP)
12 - Tizen (token for tizen push)
For 10 web push, the token must be a JSON-encoded object containing the keys described in PUSH updates
- /// Device token
- /// List of user identifiers of other users currently using the client
- public static Task Account_UnregisterDevice(this Client client, int token_type, string token, long[] other_uids)
- => client.Invoke(new Account_UnregisterDevice
- {
- token_type = token_type,
- token = token,
- other_uids = other_uids,
- });
-
- /// Edits notification settings from a given user/group, from all users/all groups. See Possible codes: 400 (details)
- /// Notification source
- /// Notification settings
- public static Task Account_UpdateNotifySettings(this Client client, InputNotifyPeerBase peer, InputPeerNotifySettings settings)
- => client.Invoke(new Account_UpdateNotifySettings
- {
- peer = peer,
- settings = settings,
- });
-
- /// Gets current notification settings for a given user/group, from all users/all groups. See Possible codes: 400 (details)
- /// Notification source
- public static Task Account_GetNotifySettings(this Client client, InputNotifyPeerBase peer)
- => client.Invoke(new Account_GetNotifySettings
- {
- peer = peer,
- });
-
- /// Resets all notification settings from users and groups. See
- public static Task Account_ResetNotifySettings(this Client client)
- => client.Invoke(new Account_ResetNotifySettings
- {
- });
-
- /// Updates user profile. See Possible codes: 400 (details)
- /// New user first name
- /// New user last name
- /// New bio
- public static Task Account_UpdateProfile(this Client client, string first_name = null, string last_name = null, string about = null)
- => client.Invoke(new Account_UpdateProfile
- {
- flags = (Account_UpdateProfile.Flags)((first_name != null ? 0x1 : 0) | (last_name != null ? 0x2 : 0) | (about != null ? 0x4 : 0)),
- first_name = first_name,
- last_name = last_name,
- about = about,
- });
-
- /// Updates online user status. See
- /// If is transmitted, user status will change to .
- public static Task Account_UpdateStatus(this Client client, bool offline)
- => client.Invoke(new Account_UpdateStatus
- {
- offline = offline,
- });
-
- /// Returns a list of available wallpapers. See
- /// Hash for pagination, for more info click here
- /// a null value means account.wallPapersNotModified
- public static Task Account_GetWallPapers(this Client client, long hash = default)
- => client.Invoke(new Account_GetWallPapers
- {
- hash = hash,
- });
-
- /// Report a peer for violation of telegram's Terms of Service See Possible codes: 400 (details)
- /// The peer to report
- /// The reason why this peer is being reported
- /// Comment for report moderation
- public static Task Account_ReportPeer(this Client client, InputPeer peer, ReportReason reason, string message)
- => client.Invoke(new Account_ReportPeer
- {
- peer = peer,
- reason = reason,
- message = message,
- });
-
- /// Validates a username and checks availability. See Possible codes: 400 (details)
- /// username
Accepted characters: A-z (case-insensitive), 0-9 and underscores.
Length: 5-32 characters.
- public static Task Account_CheckUsername(this Client client, string username)
- => client.Invoke(new Account_CheckUsername
- {
- username = username,
- });
-
- /// Changes username for the current user. See Possible codes: 400 (details)
- /// username or empty string if username is to be removed
Accepted characters: a-z (case-insensitive), 0-9 and underscores.
Length: 5-32 characters.
- public static Task Account_UpdateUsername(this Client client, string username)
- => client.Invoke(new Account_UpdateUsername
- {
- username = username,
- });
-
- /// Get privacy settings of current account See Possible codes: 400 (details)
- /// Peer category whose privacy settings should be fetched
- public static Task Account_GetPrivacy(this Client client, InputPrivacyKey key)
- => client.Invoke(new Account_GetPrivacy
- {
- key = key,
- });
-
- /// Change privacy settings of current account See Possible codes: 400 (details)
- /// Peers to which the privacy rules apply
- /// New privacy rules
- public static Task Account_SetPrivacy(this Client client, InputPrivacyKey key, InputPrivacyRule[] rules)
- => client.Invoke(new Account_SetPrivacy
- {
- key = key,
- rules = rules,
- });
-
- /// Delete the user's account from the telegram servers. Can be used, for example, to delete the account of a user that provided the login code, but forgot the 2FA password and no recovery method is configured. See Possible codes: 420 (details)
- /// Why is the account being deleted, can be empty
- public static Task Account_DeleteAccount(this Client client, string reason)
- => client.Invoke(new Account_DeleteAccount
- {
- reason = reason,
- });
-
- /// Get days to live of account See
- public static Task Account_GetAccountTTL(this Client client)
- => client.Invoke(new Account_GetAccountTTL
- {
- });
-
- /// Set account self-destruction period See Possible codes: 400 (details)
- /// Time to live in days
- public static Task Account_SetAccountTTL(this Client client, AccountDaysTTL ttl)
- => client.Invoke(new Account_SetAccountTTL
- {
- ttl = ttl,
- });
-
- /// Verify a new phone number to associate to the current account See Possible codes: 400,406 (details)
- /// New phone number
- /// Phone code settings
- public static Task Account_SendChangePhoneCode(this Client client, string phone_number, CodeSettings settings)
- => client.Invoke(new Account_SendChangePhoneCode
- {
- phone_number = phone_number,
- settings = settings,
- });
-
- /// Change the phone number of the current account See Possible codes: 400,406 (details)
- /// New phone number
- /// Phone code hash received when calling account.sendChangePhoneCode
- /// Phone code received when calling account.sendChangePhoneCode
- public static Task Account_ChangePhone(this Client client, string phone_number, string phone_code_hash, string phone_code)
- => client.Invoke(new Account_ChangePhone
- {
- phone_number = phone_number,
- phone_code_hash = phone_code_hash,
- phone_code = phone_code,
- });
-
- /// When client-side passcode lock feature is enabled, will not show message texts in incoming PUSH notifications. See
- /// Inactivity period after which to start hiding message texts in PUSH notifications.
- public static Task Account_UpdateDeviceLocked(this Client client, int period)
- => client.Invoke(new Account_UpdateDeviceLocked
- {
- period = period,
- });
-
- /// Get logged-in sessions See
- public static Task Account_GetAuthorizations(this Client client)
- => client.Invoke(new Account_GetAuthorizations
- {
- });
-
- /// Log out an active authorized session by its hash See Possible codes: 400,406 (details)
- /// Session hash
- public static Task Account_ResetAuthorization(this Client client, long hash)
- => client.Invoke(new Account_ResetAuthorization
- {
- hash = hash,
- });
-
- /// Obtain configuration for two-factor authorization with password See
- public static Task Account_GetPassword(this Client client)
- => client.Invoke(new Account_GetPassword
- {
- });
-
- /// Get private info associated to the password info (recovery email, telegram passport info & so on) See Possible codes: 400 (details)
- /// The password (see SRP)
- public static Task Account_GetPasswordSettings(this Client client, InputCheckPasswordSRP password)
- => client.Invoke(new Account_GetPasswordSettings
- {
- password = password,
- });
-
- /// Set a new 2FA password See Possible codes: 400 (details)
- /// The old password (see SRP)
- /// The new password (see SRP)
- public static Task Account_UpdatePasswordSettings(this Client client, InputCheckPasswordSRP password, Account_PasswordInputSettings new_settings)
- => client.Invoke(new Account_UpdatePasswordSettings
- {
- password = password,
- new_settings = new_settings,
- });
-
- /// Send confirmation code to cancel account deletion, for more info click here » See Possible codes: 400 (details)
- /// The hash from the service notification, for more info click here »
- /// Phone code settings
- public static Task Account_SendConfirmPhoneCode(this Client client, string hash, CodeSettings settings)
- => client.Invoke(new Account_SendConfirmPhoneCode
- {
- hash = hash,
- settings = settings,
- });
-
- /// Confirm a phone number to cancel account deletion, for more info click here » See Possible codes: 400 (details)
- /// Phone code hash, for more info click here »
- /// SMS code, for more info click here »
- public static Task Account_ConfirmPhone(this Client client, string phone_code_hash, string phone_code)
- => client.Invoke(new Account_ConfirmPhone
- {
- phone_code_hash = phone_code_hash,
- phone_code = phone_code,
- });
-
- /// Get temporary payment password See Possible codes: 400 (details)
- /// SRP password parameters
- /// Time during which the temporary password will be valid, in seconds; should be between 60 and 86400
- public static Task Account_GetTmpPassword(this Client client, InputCheckPasswordSRP password, int period)
- => client.Invoke(new Account_GetTmpPassword
- {
- password = password,
- period = period,
- });
-
- /// Get web login widget authorizations See
- public static Task Account_GetWebAuthorizations(this Client client)
- => client.Invoke(new Account_GetWebAuthorizations
- {
- });
-
- /// Log out an active web telegram login session See Possible codes: 400 (details)
- /// hash
- public static Task Account_ResetWebAuthorization(this Client client, long hash)
- => client.Invoke(new Account_ResetWebAuthorization
- {
- hash = hash,
- });
-
- /// Reset all active web telegram login sessions See
- public static Task Account_ResetWebAuthorizations(this Client client)
- => client.Invoke(new Account_ResetWebAuthorizations
- {
- });
-
- /// Get all saved Telegram Passport documents, for more info see the passport docs » See
- public static Task Account_GetAllSecureValues(this Client client)
- => client.Invoke(new Account_GetAllSecureValues
- {
- });
-
- /// Get saved Telegram Passport document, for more info see the passport docs » See
- /// Requested value types
- public static Task Account_GetSecureValue(this Client client, SecureValueType[] types)
- => client.Invoke(new Account_GetSecureValue
- {
- types = types,
- });
-
- /// Securely save Telegram Passport document, for more info see the passport docs » See Possible codes: 400 (details)
- /// Secure value, for more info see the passport docs »
- /// Passport secret hash, for more info see the passport docs »
- public static Task Account_SaveSecureValue(this Client client, InputSecureValue value, long secure_secret_id)
- => client.Invoke(new Account_SaveSecureValue
- {
- value = value,
- secure_secret_id = secure_secret_id,
- });
-
- /// Delete stored Telegram Passport documents, for more info see the passport docs » See
- /// Document types to delete
- public static Task Account_DeleteSecureValue(this Client client, SecureValueType[] types)
- => client.Invoke(new Account_DeleteSecureValue
- {
- types = types,
- });
-
- /// Returns a Telegram Passport authorization form for sharing data with a service See Possible codes: 400 (details)
- /// User identifier of the service's bot
- /// Telegram Passport element types requested by the service
- /// Service's public key
- public static Task Account_GetAuthorizationForm(this Client client, long bot_id, string scope, string public_key)
- => client.Invoke(new Account_GetAuthorizationForm
- {
- bot_id = bot_id,
- scope = scope,
- public_key = public_key,
- });
-
- /// Sends a Telegram Passport authorization form, effectively sharing data with the service See
- /// Bot ID
- /// Telegram Passport element types requested by the service
- /// Service's public key
- /// Types of values sent and their hashes
- /// Encrypted values
- public static Task Account_AcceptAuthorization(this Client client, long bot_id, string scope, string public_key, SecureValueHash[] value_hashes, SecureCredentialsEncrypted credentials)
- => client.Invoke(new Account_AcceptAuthorization
- {
- bot_id = bot_id,
- scope = scope,
- public_key = public_key,
- value_hashes = value_hashes,
- credentials = credentials,
- });
-
- /// Send the verification phone code for telegram passport. See Possible codes: 400 (details)
- /// The phone number to verify
- /// Phone code settings
- public static Task Account_SendVerifyPhoneCode(this Client client, string phone_number, CodeSettings settings)
- => client.Invoke(new Account_SendVerifyPhoneCode
- {
- phone_number = phone_number,
- settings = settings,
- });
-
- /// Verify a phone number for telegram passport. See Possible codes: 400 (details)
- /// Phone number
- /// Phone code hash received from the call to account.sendVerifyPhoneCode
- /// Code received after the call to account.sendVerifyPhoneCode
- public static Task Account_VerifyPhone(this Client client, string phone_number, string phone_code_hash, string phone_code)
- => client.Invoke(new Account_VerifyPhone
- {
- phone_number = phone_number,
- phone_code_hash = phone_code_hash,
- phone_code = phone_code,
- });
-
- /// Send the verification email code for telegram passport. See Possible codes: 400 (details)
- /// The email where to send the code
- public static Task Account_SendVerifyEmailCode(this Client client, string email)
- => client.Invoke(new Account_SendVerifyEmailCode
- {
- email = email,
- });
-
- /// Verify an email address for telegram passport. See Possible codes: 400 (details)
- /// The email to verify
- /// The verification code that was received
- public static Task Account_VerifyEmail(this Client client, string email, string code)
- => client.Invoke(new Account_VerifyEmail
- {
- email = email,
- code = code,
- });
-
- /// Initialize account takeout session See Possible codes: 420 (details)
- /// Whether to export contacts
- /// Whether to export messages in private chats
- /// Whether to export messages in legacy groups
- /// Whether to export messages in supergroups
- /// Whether to export messages in channels
- /// Whether to export files
- /// Maximum size of files to export
- public static Task Account_InitTakeoutSession(this Client client, bool contacts = false, bool message_users = false, bool message_chats = false, bool message_megagroups = false, bool message_channels = false, bool files = false, int? file_max_size = null)
- => client.Invoke(new Account_InitTakeoutSession
- {
- flags = (Account_InitTakeoutSession.Flags)((contacts ? 0x1 : 0) | (message_users ? 0x2 : 0) | (message_chats ? 0x4 : 0) | (message_megagroups ? 0x8 : 0) | (message_channels ? 0x10 : 0) | (files ? 0x20 : 0) | (file_max_size != null ? 0x20 : 0)),
- file_max_size = file_max_size.GetValueOrDefault(),
- });
-
- /// Finish account takeout session See Possible codes: 403 (details)
- /// Data exported successfully
- public static Task Account_FinishTakeoutSession(this Client client, bool success = false)
- => client.Invoke(new Account_FinishTakeoutSession
- {
- flags = (Account_FinishTakeoutSession.Flags)(success ? 0x1 : 0),
- });
-
- /// Verify an email to use as 2FA recovery method. See Possible codes: 400 (details)
- /// The phone code that was received after setting a recovery email
- public static Task Account_ConfirmPasswordEmail(this Client client, string code)
- => client.Invoke(new Account_ConfirmPasswordEmail
- {
- code = code,
- });
-
- /// Resend the code to verify an email to use as 2FA recovery method. See
- public static Task Account_ResendPasswordEmail(this Client client)
- => client.Invoke(new Account_ResendPasswordEmail
- {
- });
-
- /// Cancel the code that was sent to verify an email to use as 2FA recovery method. See
- public static Task Account_CancelPasswordEmail(this Client client)
- => client.Invoke(new Account_CancelPasswordEmail
- {
- });
-
- /// Whether the user will receive notifications when contacts sign up See
- public static Task Account_GetContactSignUpNotification(this Client client)
- => client.Invoke(new Account_GetContactSignUpNotification
- {
- });
-
- /// Toggle contact sign up notifications See
- /// Whether to disable contact sign up notifications
- public static Task Account_SetContactSignUpNotification(this Client client, bool silent)
- => client.Invoke(new Account_SetContactSignUpNotification
- {
- silent = silent,
- });
-
- /// Returns list of chats with non-default notification settings See
- /// If true, chats with non-default sound will also be returned
- /// If specified, only chats of the specified category will be returned
- public static Task Account_GetNotifyExceptions(this Client client, bool compare_sound = false, InputNotifyPeerBase peer = null)
- => client.Invoke(new Account_GetNotifyExceptions
- {
- flags = (Account_GetNotifyExceptions.Flags)((compare_sound ? 0x2 : 0) | (peer != null ? 0x1 : 0)),
- peer = peer,
- });
-
- /// Get info about a certain wallpaper See Possible codes: 400 (details)
- /// The wallpaper to get info about
- public static Task Account_GetWallPaper(this Client client, InputWallPaperBase wallpaper)
- => client.Invoke(new Account_GetWallPaper
- {
- wallpaper = wallpaper,
- });
-
- /// Create and upload a new wallpaper See Possible codes: 400 (details)
- /// The JPG/PNG wallpaper
- /// MIME type of uploaded wallpaper
- /// Wallpaper settings
- public static Task Account_UploadWallPaper(this Client client, InputFileBase file, string mime_type, WallPaperSettings settings)
- => client.Invoke(new Account_UploadWallPaper
- {
- file = file,
- mime_type = mime_type,
- settings = settings,
- });
-
- /// Install/uninstall wallpaper See Possible codes: 400 (details)
- /// Wallpaper to save
- /// Uninstall wallpaper?
- /// Wallpaper settings
- public static Task Account_SaveWallPaper(this Client client, InputWallPaperBase wallpaper, bool unsave, WallPaperSettings settings)
- => client.Invoke(new Account_SaveWallPaper
- {
- wallpaper = wallpaper,
- unsave = unsave,
- settings = settings,
- });
-
- /// Install wallpaper See Possible codes: 400 (details)
- /// Wallpaper to install
- /// Wallpaper settings
- public static Task Account_InstallWallPaper(this Client client, InputWallPaperBase wallpaper, WallPaperSettings settings)
- => client.Invoke(new Account_InstallWallPaper
- {
- wallpaper = wallpaper,
- settings = settings,
- });
-
- /// Delete installed wallpapers See
- public static Task Account_ResetWallPapers(this Client client)
- => client.Invoke(new Account_ResetWallPapers
- {
- });
-
- /// Get media autodownload settings See
- public static Task Account_GetAutoDownloadSettings(this Client client)
- => client.Invoke(new Account_GetAutoDownloadSettings
- {
- });
-
- /// Change media autodownload settings See
- /// Whether to save media in the low data usage preset
- /// Whether to save media in the high data usage preset
- /// Media autodownload settings
- public static Task Account_SaveAutoDownloadSettings(this Client client, AutoDownloadSettings settings, bool low = false, bool high = false)
- => client.Invoke(new Account_SaveAutoDownloadSettings
- {
- flags = (Account_SaveAutoDownloadSettings.Flags)((low ? 0x1 : 0) | (high ? 0x2 : 0)),
- settings = settings,
- });
-
- /// Upload theme See Possible codes: 400 (details)
- /// Theme file uploaded as described in files »
- /// Thumbnail
- /// File name
- /// MIME type, must be application/x-tgtheme-{format}, where format depends on the client
- public static Task Account_UploadTheme(this Client client, InputFileBase file, string file_name, string mime_type, InputFileBase thumb = null)
- => client.Invoke(new Account_UploadTheme
- {
- flags = (Account_UploadTheme.Flags)(thumb != null ? 0x1 : 0),
- file = file,
- thumb = thumb,
- file_name = file_name,
- mime_type = mime_type,
- });
-
- /// Create a theme See Possible codes: 400 (details)
- /// Unique theme ID
- /// Theme name
- /// Theme file
- /// Theme settings
- public static Task Account_CreateTheme(this Client client, string slug, string title, InputDocument document = null, InputThemeSettings[] settings = null)
- => client.Invoke(new Account_CreateTheme
- {
- flags = (Account_CreateTheme.Flags)((document != null ? 0x4 : 0) | (settings != null ? 0x8 : 0)),
- slug = slug,
- title = title,
- document = document,
- settings = settings,
- });
-
- /// Update theme See Possible codes: 400 (details)
- /// Theme format, a string that identifies the theming engines supported by the client
- /// Theme to update
- /// Unique theme ID
- /// Theme name
- /// Theme file
- /// Theme settings
- public static Task Account_UpdateTheme(this Client client, string format, InputThemeBase theme, string slug = null, string title = null, InputDocument document = null, InputThemeSettings[] settings = null)
- => client.Invoke(new Account_UpdateTheme
- {
- flags = (Account_UpdateTheme.Flags)((slug != null ? 0x1 : 0) | (title != null ? 0x2 : 0) | (document != null ? 0x4 : 0) | (settings != null ? 0x8 : 0)),
- format = format,
- theme = theme,
- slug = slug,
- title = title,
- document = document,
- settings = settings,
- });
-
- /// Save a theme See
- /// Theme to save
- /// Unsave
- public static Task Account_SaveTheme(this Client client, InputThemeBase theme, bool unsave)
- => client.Invoke(new Account_SaveTheme
- {
- theme = theme,
- unsave = unsave,
- });
-
- /// Install a theme See
- /// Whether to install the dark version
- /// Theme to install
- /// Theme format, a string that identifies the theming engines supported by the client
- /// Indicates a basic theme provided by all clients
- public static Task Account_InstallTheme(this Client client, bool dark = false, InputThemeBase theme = null, string format = null, BaseTheme base_theme = default)
- => client.Invoke(new Account_InstallTheme
- {
- flags = (Account_InstallTheme.Flags)((dark ? 0x1 : 0) | (theme != null ? 0x2 : 0) | (format != null ? 0x4 : 0) | (base_theme != default ? 0x8 : 0)),
- theme = theme,
- format = format,
- base_theme = base_theme,
- });
-
- /// Get theme information See Possible codes: 400 (details)
- /// Theme format, a string that identifies the theming engines supported by the client
- /// Theme
- /// Document ID
- public static Task Account_GetTheme(this Client client, string format, InputThemeBase theme, long document_id)
- => client.Invoke(new Account_GetTheme
- {
- format = format,
- theme = theme,
- document_id = document_id,
- });
-
- /// Get installed themes See
- /// Theme format, a string that identifies the theming engines supported by the client
- /// Hash for pagination, for more info click here
- /// a null value means account.themesNotModified
- public static Task Account_GetThemes(this Client client, string format, long hash = default)
- => client.Invoke(new Account_GetThemes
- {
- format = format,
- hash = hash,
- });
-
- /// Set sensitive content settings (for viewing or hiding NSFW content) See Possible codes: 403 (details)
- /// Enable NSFW content
- public static Task Account_SetContentSettings(this Client client, bool sensitive_enabled = false)
- => client.Invoke(new Account_SetContentSettings
- {
- flags = (Account_SetContentSettings.Flags)(sensitive_enabled ? 0x1 : 0),
- });
-
- /// Get sensitive content settings See
- public static Task Account_GetContentSettings(this Client client)
- => client.Invoke(new Account_GetContentSettings
- {
- });
-
- /// Get info about multiple wallpapers See
- /// Wallpapers to fetch info about
- public static Task Account_GetMultiWallPapers(this Client client, InputWallPaperBase[] wallpapers)
- => client.Invoke(new Account_GetMultiWallPapers
- {
- wallpapers = wallpapers,
- });
-
- /// Get global privacy settings See
- public static Task Account_GetGlobalPrivacySettings(this Client client)
- => client.Invoke(new Account_GetGlobalPrivacySettings
- {
- });
-
- /// Set global privacy settings See Possible codes: 400 (details)
- /// Global privacy settings
- public static Task Account_SetGlobalPrivacySettings(this Client client, GlobalPrivacySettings settings)
- => client.Invoke(new Account_SetGlobalPrivacySettings
- {
- settings = settings,
- });
-
- /// Report a profile photo of a dialog See
- /// The dialog
- /// Dialog photo ID
- /// Report reason
- /// Comment for report moderation
- public static Task Account_ReportProfilePhoto(this Client client, InputPeer peer, InputPhoto photo_id, ReportReason reason, string message)
- => client.Invoke(new Account_ReportProfilePhoto
- {
- peer = peer,
- photo_id = photo_id,
- reason = reason,
- message = message,
- });
-
- /// Initiate a 2FA password reset: can only be used if the user is already logged-in, see here for more info » See
- public static Task Account_ResetPassword(this Client client)
- => client.Invoke(new Account_ResetPassword
- {
- });
-
- /// Abort a pending 2FA password reset, see here for more info » See Possible codes: 400 (details)
- public static Task Account_DeclinePasswordReset(this Client client)
- => client.Invoke(new Account_DeclinePasswordReset
- {
- });
-
- /// Get all available chat themes See
- /// Hash for pagination, for more info click here
- /// a null value means account.themesNotModified
- public static Task Account_GetChatThemes(this Client client, long hash = default)
- => client.Invoke(new Account_GetChatThemes
- {
- hash = hash,
- });
-
- /// Set time-to-live of current session See Possible codes: 406 (details)
- /// Time-to-live of current session in days
- public static Task Account_SetAuthorizationTTL(this Client client, int authorization_ttl_days)
- => client.Invoke(new Account_SetAuthorizationTTL
- {
- authorization_ttl_days = authorization_ttl_days,
- });
-
- /// Change authorization settings See Possible codes: 400 (details)
- /// Session ID from the constructor, fetchable using account.getAuthorizations
- /// Whether to enable or disable receiving encrypted chats: if the flag is not set, the previous setting is not changed
- /// Whether to enable or disable receiving calls: if the flag is not set, the previous setting is not changed
- public static Task Account_ChangeAuthorizationSettings(this Client client, long hash, bool? encrypted_requests_disabled = default, bool? call_requests_disabled = default)
- => client.Invoke(new Account_ChangeAuthorizationSettings
- {
- flags = (Account_ChangeAuthorizationSettings.Flags)((encrypted_requests_disabled != default ? 0x1 : 0) | (call_requests_disabled != default ? 0x2 : 0)),
- hash = hash,
- encrypted_requests_disabled = encrypted_requests_disabled.GetValueOrDefault(),
- call_requests_disabled = call_requests_disabled.GetValueOrDefault(),
- });
-
- /// Returns basic user info according to their identifiers. See [bots: ✓] Possible codes: 400 (details)
- /// List of user identifiers
- public static Task Users_GetUsers(this Client client, InputUserBase[] id)
- => client.Invoke(new Users_GetUsers
- {
- id = id,
- });
-
- /// Returns extended user info by ID. See [bots: ✓] Possible codes: 400 (details)
- /// User ID
- public static Task Users_GetFullUser(this Client client, InputUserBase id)
- => client.Invoke(new Users_GetFullUser
- {
- id = id,
- });
-
- /// Notify the user that the sent passport data contains some errors The user will not be able to re-submit their Passport data to you until the errors are fixed (the contents of the field for which you returned the error must change). See [bots: ✓] Possible codes: 400 (details)
- /// The user
- /// Errors
- public static Task Users_SetSecureValueErrors(this Client client, InputUserBase id, SecureValueErrorBase[] errors)
- => client.Invoke(new Users_SetSecureValueErrors
- {
- id = id,
- errors = errors,
- });
-
- /// Get contact by telegram IDs See
- /// Hash for pagination, for more info click here
- public static Task Contacts_GetContactIDs(this Client client, long hash = default)
- => client.Invoke(new Contacts_GetContactIDs
- {
- hash = hash,
- });
-
- /// Returns the list of contact statuses. See
- public static Task Contacts_GetStatuses(this Client client)
- => client.Invoke(new Contacts_GetStatuses
- {
- });
-
- /// Returns the current user's contact list. See
- /// If there already is a full contact list on the client, a hash of a the list of contact IDs in ascending order may be passed in this parameter. If the contact set was not changed, will be returned.
- /// a null value means contacts.contactsNotModified
- public static Task Contacts_GetContacts(this Client client, long hash = default)
- => client.Invoke(new Contacts_GetContacts
- {
- hash = hash,
- });
-
- /// Imports contacts: saves a full list on the server, adds already registered contacts to the contact list, returns added contacts and their info. See
- /// List of contacts to import
- public static Task Contacts_ImportContacts(this Client client, InputContact[] contacts)
- => client.Invoke(new Contacts_ImportContacts
- {
- contacts = contacts,
- });
-
- /// Deletes several contacts from the list. See
- /// User ID list
- public static Task Contacts_DeleteContacts(this Client client, InputUserBase[] id)
- => client.Invoke(new Contacts_DeleteContacts
- {
- id = id,
- });
-
- /// Delete contacts by phone number See
- /// Phone numbers
- public static Task Contacts_DeleteByPhones(this Client client, string[] phones)
- => client.Invoke(new Contacts_DeleteByPhones
- {
- phones = phones,
- });
-
- /// Adds the user to the blacklist. See Possible codes: 400 (details)
- /// User ID
- public static Task Contacts_Block(this Client client, InputPeer id)
- => client.Invoke(new Contacts_Block
- {
- id = id,
- });
-
- /// Deletes the user from the blacklist. See Possible codes: 400 (details)
- /// User ID
- public static Task Contacts_Unblock(this Client client, InputPeer id)
- => client.Invoke(new Contacts_Unblock
- {
- id = id,
- });
-
- /// Returns the list of blocked users. See
- /// The number of list elements to be skipped
- /// The number of list elements to be returned
- public static Task Contacts_GetBlocked(this Client client, int offset = default, int limit = int.MaxValue)
- => client.Invoke(new Contacts_GetBlocked
- {
- offset = offset,
- limit = limit,
- });
-
- /// Returns users found by username substring. See Possible codes: 400 (details)
- /// Target substring
- /// Maximum number of users to be returned
- public static Task Contacts_Search(this Client client, string q, int limit = int.MaxValue)
- => client.Invoke(new Contacts_Search
- {
- q = q,
- limit = limit,
- });
-
- /// Resolve a @username to get peer info See [bots: ✓] Possible codes: 400 (details)
- /// @username to resolve
- public static Task Contacts_ResolveUsername(this Client client, string username)
- => client.Invoke(new Contacts_ResolveUsername
- {
- username = username,
- });
-
- /// Get most used peers See Possible codes: 400 (details)
- /// Users we've chatted most frequently with
- /// Most used bots
- /// Most used inline bots
- /// Most frequently called users
- /// Users to which the users often forwards messages to
- /// Chats to which the users often forwards messages to
- /// Often-opened groups and supergroups
- /// Most frequently visited channels
- /// Offset for pagination
- /// Maximum number of results to return, see pagination
- /// Hash for pagination, for more info click here
- /// a null value means contacts.topPeersNotModified
- public static Task Contacts_GetTopPeers(this Client client, int offset = default, int limit = int.MaxValue, long hash = default, bool correspondents = false, bool bots_pm = false, bool bots_inline = false, bool phone_calls = false, bool forward_users = false, bool forward_chats = false, bool groups = false, bool channels = false)
- => client.Invoke(new Contacts_GetTopPeers
- {
- flags = (Contacts_GetTopPeers.Flags)((correspondents ? 0x1 : 0) | (bots_pm ? 0x2 : 0) | (bots_inline ? 0x4 : 0) | (phone_calls ? 0x8 : 0) | (forward_users ? 0x10 : 0) | (forward_chats ? 0x20 : 0) | (groups ? 0x400 : 0) | (channels ? 0x8000 : 0)),
- offset = offset,
- limit = limit,
- hash = hash,
- });
-
- /// Reset rating of top peer See Possible codes: 400 (details)
- /// Top peer category
- /// Peer whose rating should be reset
- public static Task Contacts_ResetTopPeerRating(this Client client, TopPeerCategory category, InputPeer peer)
- => client.Invoke(new Contacts_ResetTopPeerRating
- {
- category = category,
- peer = peer,
- });
-
- /// Delete saved contacts See
- public static Task Contacts_ResetSaved(this Client client)
- => client.Invoke(new Contacts_ResetSaved
- {
- });
-
- /// Get all contacts See Possible codes: 403 (details)
- public static Task Contacts_GetSaved(this Client client)
- => client.Invoke(new Contacts_GetSaved
- {
- });
-
- /// Enable/disable top peers See
- /// Enable/disable
- public static Task Contacts_ToggleTopPeers(this Client client, bool enabled)
- => client.Invoke(new Contacts_ToggleTopPeers
- {
- enabled = enabled,
- });
-
- /// Add an existing telegram user as contact. See Possible codes: 400 (details)
- /// Allow the other user to see our phone number?
- /// Telegram ID of the other user
- /// First name
- /// Last name
- /// User's phone number
- public static Task Contacts_AddContact(this Client client, InputUserBase id, string first_name, string last_name, string phone, bool add_phone_privacy_exception = false)
- => client.Invoke(new Contacts_AddContact
- {
- flags = (Contacts_AddContact.Flags)(add_phone_privacy_exception ? 0x1 : 0),
- id = id,
- first_name = first_name,
- last_name = last_name,
- phone = phone,
- });
-
- /// If the of a new user allow us to add them as contact, add that user as contact See Possible codes: 400 (details)
- /// The user to add as contact
- public static Task Contacts_AcceptContact(this Client client, InputUserBase id)
- => client.Invoke(new Contacts_AcceptContact
- {
- id = id,
- });
-
- /// Get contacts near you See Possible codes: 400,406 (details)
- /// While the geolocation of the current user is public, clients should update it in the background every half-an-hour or so, while setting this flag.
Do this only if the new location is more than 1 KM away from the previous one, or if the previous location is unknown.
- /// Geolocation
- /// If set, the geolocation of the current user will be public for the specified number of seconds; pass 0x7fffffff to disable expiry, 0 to make the current geolocation private; if the flag isn't set, no changes will be applied.
- public static Task Contacts_GetLocated(this Client client, InputGeoPoint geo_point, bool background = false, int? self_expires = null)
- => client.Invoke(new Contacts_GetLocated
- {
- flags = (Contacts_GetLocated.Flags)((background ? 0x2 : 0) | (self_expires != null ? 0x1 : 0)),
- geo_point = geo_point,
- self_expires = self_expires.GetValueOrDefault(),
- });
-
- /// Stop getting notifications about thread replies of a certain user in @replies See
- /// Whether to delete the specified message as well
- /// Whether to delete all @replies messages from this user as well
- /// Whether to also report this user for spam
- /// ID of the message in the @replies chat
- public static Task Contacts_BlockFromReplies(this Client client, int msg_id, bool delete_message = false, bool delete_history = false, bool report_spam = false)
- => client.Invoke(new Contacts_BlockFromReplies
- {
- flags = (Contacts_BlockFromReplies.Flags)((delete_message ? 0x1 : 0) | (delete_history ? 0x2 : 0) | (report_spam ? 0x4 : 0)),
- msg_id = msg_id,
- });
-
- /// Resolve a phone number to get user info, if their privacy settings allow it. See
- /// Phone number in international format, possibly obtained from a t.me/+number or tg://resolve?phone=number URI.
- public static Task Contacts_ResolvePhone(this Client client, string phone)
- => client.Invoke(new Contacts_ResolvePhone
- {
- phone = phone,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Returns the list of messages by their IDs. See [bots: ✓]
- /// Message ID list
- public static Task Messages_GetMessages(this Client client, InputMessage[] id)
- => client.Invoke(new Messages_GetMessages
- {
- id = id,
- });
-
- /// Returns the current user dialog list. See Possible codes: 400 (details)
- /// Exclude pinned dialogs
- /// Peer folder ID, for more info click here
- /// Offsets for pagination, for more info click here
- /// Offsets for pagination, for more info click here
- /// Offset peer for pagination
- /// Number of list elements to be returned
- /// Hash for pagination, for more info click here
- public static Task Messages_GetDialogs(this Client client, DateTime offset_date = default, int offset_id = default, InputPeer offset_peer = null, int limit = int.MaxValue, long hash = default, bool exclude_pinned = false, int? folder_id = null)
- => client.Invoke(new Messages_GetDialogs
- {
- flags = (Messages_GetDialogs.Flags)((exclude_pinned ? 0x1 : 0) | (folder_id != null ? 0x2 : 0)),
- folder_id = folder_id.GetValueOrDefault(),
- offset_date = offset_date,
- offset_id = offset_id,
- offset_peer = offset_peer,
- limit = limit,
- hash = hash,
- });
-
- /// Gets back the conversation history with one interlocutor / within a chat See Possible codes: 400 (details)
- /// Target peer
- /// Only return messages starting from the specified message ID
- /// Only return messages sent before the specified date
- /// Number of list elements to be skipped, negative values are also accepted.
- /// Number of results to return
- /// If a positive value was transferred, the method will return only messages with IDs less than max_id
- /// If a positive value was transferred, the method will return only messages with IDs more than min_id
- /// Result hash
- public static Task Messages_GetHistory(this Client client, InputPeer peer, int offset_id = default, DateTime offset_date = default, int add_offset = default, int limit = int.MaxValue, int max_id = default, int min_id = default, long hash = default)
- => client.Invoke(new Messages_GetHistory
- {
- peer = peer,
- offset_id = offset_id,
- offset_date = offset_date,
- add_offset = add_offset,
- limit = limit,
- max_id = max_id,
- min_id = min_id,
- hash = hash,
- });
-
- /// Gets back found messages See Possible codes: 400 (details)
- /// User or chat, histories with which are searched, or constructor for global search
- /// Text search request
- /// Only return messages sent by the specified user ID
- /// Thread ID
- /// Filter to return only specified message types
- /// If a positive value was transferred, only messages with a sending date bigger than the transferred one will be returned
- /// If a positive value was transferred, only messages with a sending date smaller than the transferred one will be returned
- /// Only return messages starting from the specified message ID
- /// Additional offset
- /// Number of results to return
- /// Maximum message ID to return
- /// Minimum message ID to return
- /// Hash
- public static Task Messages_Search(this Client client, InputPeer peer, string q, MessagesFilter filter, DateTime min_date = default, DateTime max_date = default, int offset_id = default, int add_offset = default, int limit = int.MaxValue, int max_id = default, int min_id = default, long hash = default, InputPeer from_id = null, int? top_msg_id = null)
- => client.Invoke(new Messages_Search
- {
- flags = (Messages_Search.Flags)((from_id != null ? 0x1 : 0) | (top_msg_id != null ? 0x2 : 0)),
- peer = peer,
- q = q,
- from_id = from_id,
- top_msg_id = top_msg_id.GetValueOrDefault(),
- filter = filter,
- min_date = min_date,
- max_date = max_date,
- offset_id = offset_id,
- add_offset = add_offset,
- limit = limit,
- max_id = max_id,
- min_id = min_id,
- hash = hash,
- });
-
- /// Marks message history as read. See Possible codes: 400 (details)
- /// Target user or group
- /// If a positive value is passed, only messages with identifiers less or equal than the given one will be read
- public static Task Messages_ReadHistory(this Client client, InputPeer peer, int max_id = default)
- => client.Invoke(new Messages_ReadHistory
- {
- peer = peer,
- max_id = max_id,
- });
-
- /// Deletes communication history. See Possible codes: 400 (details)
- /// Just clear history for the current user, without actually removing messages for every chat user
- /// Whether to delete the message history for all chat participants
- /// User or chat, communication history of which will be deleted
- /// Maximum ID of message to delete
- /// Delete all messages newer than this UNIX timestamp
- /// Delete all messages older than this UNIX timestamp
- public static Task Messages_DeleteHistory(this Client client, InputPeer peer, int max_id = default, bool just_clear = false, bool revoke = false, DateTime? min_date = null, DateTime? max_date = null)
- => client.Invoke(new Messages_DeleteHistory
- {
- flags = (Messages_DeleteHistory.Flags)((just_clear ? 0x1 : 0) | (revoke ? 0x2 : 0) | (min_date != null ? 0x4 : 0) | (max_date != null ? 0x8 : 0)),
- peer = peer,
- max_id = max_id,
- min_date = min_date.GetValueOrDefault(),
- max_date = max_date.GetValueOrDefault(),
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Deletes messages by their identifiers. See [bots: ✓] Possible codes: 400,403 (details)
- /// Whether to delete messages for all participants of the chat
- /// Message ID list
- public static Task Messages_DeleteMessages(this Client client, int[] id, bool revoke = false)
- => client.Invoke(new Messages_DeleteMessages
- {
- flags = (Messages_DeleteMessages.Flags)(revoke ? 0x1 : 0),
- id = id,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Confirms receipt of messages by a client, cancels PUSH-notification sending. See
- /// Maximum message ID available in a client.
- public static Task Messages_ReceivedMessages(this Client client, int max_id = default)
- => client.Invoke(new Messages_ReceivedMessages
- {
- max_id = max_id,
- });
-
- /// Sends a current user typing event (see for all event types) to a conversation partner or group. See [bots: ✓] Possible codes: 400,403 (details)
- /// Target user or group
- /// Thread ID
- /// Type of action
Parameter added in Layer 17.
- public static Task Messages_SetTyping(this Client client, InputPeer peer, SendMessageAction action, int? top_msg_id = null)
- => client.Invoke(new Messages_SetTyping
- {
- flags = (Messages_SetTyping.Flags)(top_msg_id != null ? 0x1 : 0),
- peer = peer,
- top_msg_id = top_msg_id.GetValueOrDefault(),
- action = action,
- });
-
- /// Sends a message to a chat See [bots: ✓] Possible codes: 400,403,420,500 (details)
- /// Set this flag to disable generation of the webpage preview
- /// Send this message silently (no notifications for the receivers)
- /// Send this message as background message
- /// Clear the draft field
- /// Only for bots, disallows forwarding and saving of the messages, even if the destination chat doesn't have content protection enabled
- /// The destination where the message will be sent
- /// The message ID to which this message will reply to
- /// The message
- /// Unique client message ID required to prevent message resending
- /// Reply markup for sending bot buttons
- /// Message entities for sending styled text
- /// Scheduled message date for scheduled messages
- /// Send this message as the specified peer
- public static Task Messages_SendMessage(this Client client, InputPeer peer, string message, long random_id, bool no_webpage = false, bool silent = false, bool background = false, bool clear_draft = false, bool noforwards = false, int? reply_to_msg_id = null, ReplyMarkup reply_markup = null, MessageEntity[] entities = null, DateTime? schedule_date = null, InputPeer send_as = null)
- => client.Invoke(new Messages_SendMessage
- {
- flags = (Messages_SendMessage.Flags)((no_webpage ? 0x2 : 0) | (silent ? 0x20 : 0) | (background ? 0x40 : 0) | (clear_draft ? 0x80 : 0) | (noforwards ? 0x4000 : 0) | (reply_to_msg_id != null ? 0x1 : 0) | (reply_markup != null ? 0x4 : 0) | (entities != null ? 0x8 : 0) | (schedule_date != null ? 0x400 : 0) | (send_as != null ? 0x2000 : 0)),
- peer = peer,
- reply_to_msg_id = reply_to_msg_id.GetValueOrDefault(),
- message = message,
- random_id = random_id,
- reply_markup = reply_markup,
- entities = entities,
- schedule_date = schedule_date.GetValueOrDefault(),
- send_as = send_as,
- });
-
- /// Send a media See [bots: ✓] Possible codes: 400,403,420,500 (details)
- /// Send message silently (no notification should be triggered)
- /// Send message in background
- /// Clear the draft
- /// Only for bots, disallows forwarding and saving of the messages, even if the destination chat doesn't have content protection enabled
- /// Destination
- /// Message ID to which this message should reply to
- /// Attached media
- /// Caption
- /// Random ID to avoid resending the same message
- /// Reply markup for bot keyboards
- /// Message entities for styled text
- /// Scheduled message date for scheduled messages
- /// Send this message as the specified peer
- public static Task Messages_SendMedia(this Client client, InputPeer peer, InputMedia media, string message, long random_id, bool silent = false, bool background = false, bool clear_draft = false, bool noforwards = false, int? reply_to_msg_id = null, ReplyMarkup reply_markup = null, MessageEntity[] entities = null, DateTime? schedule_date = null, InputPeer send_as = null)
- => client.Invoke(new Messages_SendMedia
- {
- flags = (Messages_SendMedia.Flags)((silent ? 0x20 : 0) | (background ? 0x40 : 0) | (clear_draft ? 0x80 : 0) | (noforwards ? 0x4000 : 0) | (reply_to_msg_id != null ? 0x1 : 0) | (reply_markup != null ? 0x4 : 0) | (entities != null ? 0x8 : 0) | (schedule_date != null ? 0x400 : 0) | (send_as != null ? 0x2000 : 0)),
- peer = peer,
- reply_to_msg_id = reply_to_msg_id.GetValueOrDefault(),
- media = media,
- message = message,
- random_id = random_id,
- reply_markup = reply_markup,
- entities = entities,
- schedule_date = schedule_date.GetValueOrDefault(),
- send_as = send_as,
- });
-
- /// Forwards messages by their IDs. See [bots: ✓] Possible codes: 400,403,406,420,500 (details)
- /// Whether to send messages silently (no notification will be triggered on the destination clients)
- /// Whether to send the message in background
- /// When forwarding games, whether to include your score in the game
- /// Whether to forward messages without quoting the original author
- /// Whether to strip captions from media
- /// Only for bots, disallows further re-forwarding and saving of the messages, even if the destination chat doesn't have content protection enabled
- /// Source of messages
- /// IDs of messages
- /// Random ID to prevent resending of messages
- /// Destination peer
- /// Scheduled message date for scheduled messages
- /// Forward the messages as the specified peer
- public static Task Messages_ForwardMessages(this Client client, InputPeer from_peer, int[] id, long[] random_id, InputPeer to_peer, bool silent = false, bool background = false, bool with_my_score = false, bool drop_author = false, bool drop_media_captions = false, bool noforwards = false, DateTime? schedule_date = null, InputPeer send_as = null)
- => client.Invoke(new Messages_ForwardMessages
- {
- flags = (Messages_ForwardMessages.Flags)((silent ? 0x20 : 0) | (background ? 0x40 : 0) | (with_my_score ? 0x100 : 0) | (drop_author ? 0x800 : 0) | (drop_media_captions ? 0x1000 : 0) | (noforwards ? 0x4000 : 0) | (schedule_date != null ? 0x400 : 0) | (send_as != null ? 0x2000 : 0)),
- from_peer = from_peer,
- id = id,
- random_id = random_id,
- to_peer = to_peer,
- schedule_date = schedule_date.GetValueOrDefault(),
- send_as = send_as,
- });
-
- /// Report a new incoming chat for spam, if the of the chat allow us to do that See Possible codes: 400 (details)
- /// Peer to report
- public static Task Messages_ReportSpam(this Client client, InputPeer peer)
- => client.Invoke(new Messages_ReportSpam
- {
- peer = peer,
- });
-
- /// Get peer settings See Possible codes: 400 (details)
- /// The peer
- public static Task Messages_GetPeerSettings(this Client client, InputPeer peer)
- => client.Invoke(new Messages_GetPeerSettings
- {
- peer = peer,
- });
-
- /// Report a message in a chat for violation of telegram's Terms of Service See Possible codes: 400 (details)
- /// Peer
- /// IDs of messages to report
- /// Why are these messages being reported
- /// Comment for report moderation
- public static Task Messages_Report(this Client client, InputPeer peer, int[] id, ReportReason reason, string message)
- => client.Invoke(new Messages_Report
- {
- peer = peer,
- id = id,
- reason = reason,
- message = message,
- });
-
- /// Returns chat basic info on their IDs. See [bots: ✓] Possible codes: 400 (details)
- /// List of chat IDs
- public static Task Messages_GetChats(this Client client, long[] id)
- => client.Invoke(new Messages_GetChats
- {
- id = id,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Get full info about a legacy group. See [bots: ✓] Possible codes: 400 (details)
- /// Legacy group ID.
- public static Task Messages_GetFullChat(this Client client, long chat_id)
- => client.Invoke(new Messages_GetFullChat
- {
- chat_id = chat_id,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Changes chat name and sends a service message on it. See [bots: ✓] Possible codes: 400 (details)
- /// Chat ID
- /// New chat name, different from the old one
- public static Task Messages_EditChatTitle(this Client client, long chat_id, string title)
- => client.Invoke(new Messages_EditChatTitle
- {
- chat_id = chat_id,
- title = title,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Changes chat photo and sends a service message on it See [bots: ✓] Possible codes: 400 (details)
- /// Chat ID
- /// Photo to be set
- public static Task Messages_EditChatPhoto(this Client client, long chat_id, InputChatPhotoBase photo)
- => client.Invoke(new Messages_EditChatPhoto
- {
- chat_id = chat_id,
- photo = photo,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Adds a user to a chat and sends a service message on it. See Possible codes: 400,403 (details)
- /// Chat ID
- /// User ID to be added
- /// Number of last messages to be forwarded
- public static Task Messages_AddChatUser(this Client client, long chat_id, InputUserBase user_id, int fwd_limit)
- => client.Invoke(new Messages_AddChatUser
- {
- chat_id = chat_id,
- user_id = user_id,
- fwd_limit = fwd_limit,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Deletes a user from a chat and sends a service message on it. See [bots: ✓] Possible codes: 400 (details)
- /// Remove the entire chat history of the specified user in this chat.
- /// Chat ID
- /// User ID to be deleted
- public static Task Messages_DeleteChatUser(this Client client, long chat_id, InputUserBase user_id, bool revoke_history = false)
- => client.Invoke(new Messages_DeleteChatUser
- {
- flags = (Messages_DeleteChatUser.Flags)(revoke_history ? 0x1 : 0),
- chat_id = chat_id,
- user_id = user_id,
- });
-
- /// Creates a new chat. See Possible codes: 400,403,500 (details)
- /// List of user IDs to be invited
- /// Chat name
- public static Task Messages_CreateChat(this Client client, InputUserBase[] users, string title)
- => client.Invoke(new Messages_CreateChat
- {
- users = users,
- title = title,
- });
-
- /// Returns configuration parameters for Diffie-Hellman key generation. Can also return a random sequence of bytes of required length. See Possible codes: 400 (details)
- /// Value of the version parameter from , available at the client
- /// Length of the required random sequence
- public static Task Messages_GetDhConfig(this Client client, int version, int random_length)
- => client.Invoke(new Messages_GetDhConfig
- {
- version = version,
- random_length = random_length,
- });
-
- /// Sends a request to start a secret chat to the user. See Possible codes: 400 (details)
- /// User ID
- /// Unique client request ID required to prevent resending. This also doubles as the chat ID.
- /// A = g ^ a mod p, see Wikipedia
- public static Task Messages_RequestEncryption(this Client client, InputUserBase user_id, int random_id, byte[] g_a)
- => client.Invoke(new Messages_RequestEncryption
- {
- user_id = user_id,
- random_id = random_id,
- g_a = g_a,
- });
-
- /// Confirms creation of a secret chat See Possible codes: 400 (details)
- /// Secret chat ID
- /// B = g ^ b mod p, see Wikipedia
- /// 64-bit fingerprint of the received key
- public static Task Messages_AcceptEncryption(this Client client, InputEncryptedChat peer, byte[] g_b, long key_fingerprint)
- => client.Invoke(new Messages_AcceptEncryption
- {
- peer = peer,
- g_b = g_b,
- key_fingerprint = key_fingerprint,
- });
-
- /// Cancels a request for creation and/or delete info on secret chat. See Possible codes: 400 (details)
- /// Whether to delete the entire chat history for the other user as well
- /// Secret chat ID
- public static Task Messages_DiscardEncryption(this Client client, int chat_id, bool delete_history = false)
- => client.Invoke(new Messages_DiscardEncryption
- {
- flags = (Messages_DiscardEncryption.Flags)(delete_history ? 0x1 : 0),
- chat_id = chat_id,
- });
-
- /// Send typing event by the current user to a secret chat. See Possible codes: 400 (details)
- /// Secret chat ID
- /// Typing.
Possible values:
, if the user started typing and more than 5 seconds have passed since the last request
, if the user stopped typing
- public static Task Messages_SetEncryptedTyping(this Client client, InputEncryptedChat peer, bool typing)
- => client.Invoke(new Messages_SetEncryptedTyping
- {
- peer = peer,
- typing = typing,
- });
-
- /// Marks message history within a secret chat as read. See Possible codes: 400 (details)
- /// Secret chat ID
- /// Maximum date value for received messages in history
- public static Task Messages_ReadEncryptedHistory(this Client client, InputEncryptedChat peer, DateTime max_date = default)
- => client.Invoke(new Messages_ReadEncryptedHistory
- {
- peer = peer,
- max_date = max_date,
- });
-
- /// Sends a text message to a secret chat. See Possible codes: 400,403 (details)
- /// Send encrypted message without a notification
- /// Secret chat ID
- /// Unique client message ID, necessary to avoid message resending
- /// TL-serialization of type, encrypted with a key that was created during chat initialization
- public static Task Messages_SendEncrypted(this Client client, InputEncryptedChat peer, long random_id, byte[] data, bool silent = false)
- => client.Invoke(new Messages_SendEncrypted
- {
- flags = (Messages_SendEncrypted.Flags)(silent ? 0x1 : 0),
- peer = peer,
- random_id = random_id,
- data = data,
- });
-
- /// Sends a message with a file attachment to a secret chat See Possible codes: 400 (details)
- /// Whether to send the file without triggering a notification
- /// Secret chat ID
- /// Unique client message ID necessary to prevent message resending
- /// TL-serialization of type, encrypted with a key generated during chat initialization
- /// File attachment for the secret chat
- public static Task Messages_SendEncryptedFile(this Client client, InputEncryptedChat peer, long random_id, byte[] data, InputEncryptedFileBase file, bool silent = false)
- => client.Invoke(new Messages_SendEncryptedFile
- {
- flags = (Messages_SendEncryptedFile.Flags)(silent ? 0x1 : 0),
- peer = peer,
- random_id = random_id,
- data = data,
- file = file,
- });
-
- /// Sends a service message to a secret chat. See Possible codes: 400,403 (details)
- /// Secret chat ID
- /// Unique client message ID required to prevent message resending
- /// TL-serialization of type, encrypted with a key generated during chat initialization
- public static Task Messages_SendEncryptedService(this Client client, InputEncryptedChat peer, long random_id, byte[] data)
- => client.Invoke(new Messages_SendEncryptedService
- {
- peer = peer,
- random_id = random_id,
- data = data,
- });
-
- /// Confirms receipt of messages in a secret chat by client, cancels push notifications. See Possible codes: 400 (details)
- /// Maximum qts value available at the client
- public static Task Messages_ReceivedQueue(this Client client, int max_qts)
- => client.Invoke(new Messages_ReceivedQueue
- {
- max_qts = max_qts,
- });
-
- /// Report a secret chat for spam See Possible codes: 400 (details)
- /// The secret chat to report
- public static Task Messages_ReportEncryptedSpam(this Client client, InputEncryptedChat peer)
- => client.Invoke(new Messages_ReportEncryptedSpam
- {
- peer = peer,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Notifies the sender about the recipient having listened a voice message or watched a video. See
- /// Message ID list
- public static Task Messages_ReadMessageContents(this Client client, int[] id)
- => client.Invoke(new Messages_ReadMessageContents
- {
- id = id,
- });
-
- /// Get stickers by emoji See Possible codes: 400 (details)
- /// The emoji
- /// Hash for pagination, for more info click here
- /// a null value means messages.stickersNotModified
- public static Task Messages_GetStickers(this Client client, string emoticon, long hash = default)
- => client.Invoke(new Messages_GetStickers
- {
- emoticon = emoticon,
- hash = hash,
- });
-
- /// Get all installed stickers See
- /// Hash for pagination, for more info click here
- /// a null value means messages.allStickersNotModified
- public static Task Messages_GetAllStickers(this Client client, long hash = default)
- => client.Invoke(new Messages_GetAllStickers
- {
- hash = hash,
- });
-
- /// Get preview of webpage See Possible codes: 400 (details)
- /// Message from which to extract the preview
- /// Message entities for styled text
- /// a null value means messageMediaEmpty
- public static Task Messages_GetWebPagePreview(this Client client, string message, MessageEntity[] entities = null)
- => client.Invoke(new Messages_GetWebPagePreview
- {
- flags = (Messages_GetWebPagePreview.Flags)(entities != null ? 0x8 : 0),
- message = message,
- entities = entities,
- });
-
- /// Export an invite link for a chat See [bots: ✓] Possible codes: 400,403 (details)
- /// Legacy flag, reproducing legacy behavior of this method: if set, revokes all previous links before creating a new one. Kept for bot API BC, should not be used by modern clients.
- /// Whether admin confirmation is required before admitting each separate user into the chat
- /// Chat
- /// Expiration date
- /// Maximum number of users that can join using this link
- /// Description of the invite link, visible only to administrators
- public static Task Messages_ExportChatInvite(this Client client, InputPeer peer, bool legacy_revoke_permanent = false, bool request_needed = false, DateTime? expire_date = null, int? usage_limit = null, string title = null)
- => client.Invoke(new Messages_ExportChatInvite
- {
- flags = (Messages_ExportChatInvite.Flags)((legacy_revoke_permanent ? 0x4 : 0) | (request_needed ? 0x8 : 0) | (expire_date != null ? 0x1 : 0) | (usage_limit != null ? 0x2 : 0) | (title != null ? 0x10 : 0)),
- peer = peer,
- expire_date = expire_date.GetValueOrDefault(),
- usage_limit = usage_limit.GetValueOrDefault(),
- title = title,
- });
-
- /// Check the validity of a chat invite link and get basic info about it See Possible codes: 400,406 (details)
- /// Invite hash in t.me/joinchat/hash or t.me/+hash
- public static Task Messages_CheckChatInvite(this Client client, string hash)
- => client.Invoke(new Messages_CheckChatInvite
- {
- hash = hash,
- });
-
- /// Import a chat invite and join a private chat/supergroup/channel See Possible codes: 400,406 (details)
- /// hash from t.me/joinchat/hash
- public static Task Messages_ImportChatInvite(this Client client, string hash)
- => client.Invoke(new Messages_ImportChatInvite
- {
- hash = hash,
- });
-
- /// Get info about a stickerset See [bots: ✓] Possible codes: 406 (details)
- /// Stickerset
- /// Hash for pagination, for more info click here
- /// a null value means messages.stickerSetNotModified
- public static Task Messages_GetStickerSet(this Client client, InputStickerSet stickerset, int hash = default)
- => client.Invoke(new Messages_GetStickerSet
- {
- stickerset = stickerset,
- hash = hash,
- });
-
- /// Install a stickerset See Possible codes: 400 (details)
- /// Stickerset to install
- /// Whether to archive stickerset
- public static Task Messages_InstallStickerSet(this Client client, InputStickerSet stickerset, bool archived)
- => client.Invoke(new Messages_InstallStickerSet
- {
- stickerset = stickerset,
- archived = archived,
- });
-
- /// Uninstall a stickerset See Possible codes: 400 (details)
- /// The stickerset to uninstall
- public static Task Messages_UninstallStickerSet(this Client client, InputStickerSet stickerset)
- => client.Invoke(new Messages_UninstallStickerSet
- {
- stickerset = stickerset,
- });
-
- /// Start a conversation with a bot using a deep linking parameter See Possible codes: 400,500 (details)
- /// The bot
- /// The chat where to start the bot, can be the bot's private chat or a group
- /// Random ID to avoid resending the same message
- /// Deep linking parameter
- public static Task Messages_StartBot(this Client client, InputUserBase bot, InputPeer peer, long random_id, string start_param)
- => client.Invoke(new Messages_StartBot
- {
- bot = bot,
- peer = peer,
- random_id = random_id,
- start_param = start_param,
- });
-
- /// Get and increase the view counter of a message sent or forwarded from a channel See Possible codes: 400 (details)
- /// Peer where the message was found
- /// ID of message
- /// Whether to mark the message as viewed and increment the view counter
- public static Task Messages_GetMessagesViews(this Client client, InputPeer peer, int[] id, bool increment)
- => client.Invoke(new Messages_GetMessagesViews
- {
- peer = peer,
- id = id,
- increment = increment,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Make a user admin in a legacy group. See Possible codes: 400 (details)
- /// The ID of the group
- /// The user to make admin
- /// Whether to make them admin
- public static Task Messages_EditChatAdmin(this Client client, long chat_id, InputUserBase user_id, bool is_admin)
- => client.Invoke(new Messages_EditChatAdmin
- {
- chat_id = chat_id,
- user_id = user_id,
- is_admin = is_admin,
- });
-
- /// ⚠ This method is only for small private Chat. See Terminology to understand what this means
Search for a similar method name starting with Channels_ if you're dealing with a Turn a legacy group into a supergroup See Possible codes: 400,403 (details)
- /// Legacy group to migrate
- public static Task Messages_MigrateChat(this Client client, long chat_id)
- => client.Invoke(new Messages_MigrateChat
- {
- chat_id = chat_id,
- });
-
- /// Search for messages and peers globally See Possible codes: 400 (details)
- /// Peer folder ID, for more info click here
- /// Query
- /// Global search filter
- /// If a positive value was specified, the method will return only messages with date bigger than min_date
- /// If a positive value was transferred, the method will return only messages with date smaller than max_date
- /// Initially 0, then set to the
- /// Offsets for pagination, for more info click here
- /// Offsets for pagination, for more info click here
- /// Offsets for pagination, for more info click here
- public static Task Messages_SearchGlobal(this Client client, string q, MessagesFilter filter, DateTime min_date = default, DateTime max_date = default, int offset_rate = default, InputPeer offset_peer = null, int offset_id = default, int limit = int.MaxValue, int? folder_id = null)
- => client.Invoke(new Messages_SearchGlobal
- {
- flags = (Messages_SearchGlobal.Flags)(folder_id != null ? 0x1 : 0),
- folder_id = folder_id.GetValueOrDefault(),
- q = q,
- filter = filter,
- min_date = min_date,
- max_date = max_date,
- offset_rate = offset_rate,
- offset_peer = offset_peer,
- offset_id = offset_id,
- limit = limit,
- });
-
- /// Reorder installed stickersets See
- /// Reorder mask stickersets
- /// New stickerset order by stickerset IDs
- public static Task Messages_ReorderStickerSets(this Client client, long[] order, bool masks = false)
- => client.Invoke(new Messages_ReorderStickerSets
- {
- flags = (Messages_ReorderStickerSets.Flags)(masks ? 0x1 : 0),
- order = order,
- });
-
- /// Get a document by its SHA256 hash, mainly used for gifs See [bots: ✓] Possible codes: 400 (details)
- /// SHA256 of file
- /// Size of the file in bytes
- /// Mime type
- public static Task Messages_GetDocumentByHash(this Client client, byte[] sha256, int size, string mime_type)
- => client.Invoke(new Messages_GetDocumentByHash
- {
- sha256 = sha256,
- size = size,
- mime_type = mime_type,
- });
-
- /// Get saved GIFs See
- /// Hash for pagination, for more info click here
- /// a null value means messages.savedGifsNotModified
- public static Task Messages_GetSavedGifs(this Client client, long hash = default)
- => client.Invoke(new Messages_GetSavedGifs
- {
- hash = hash,
- });
-
- /// Add GIF to saved gifs list See Possible codes: 400 (details)
- /// GIF to save
- /// Whether to remove GIF from saved gifs list
- public static Task Messages_SaveGif(this Client client, InputDocument id, bool unsave)
- => client.Invoke(new Messages_SaveGif
- {
- id = id,
- unsave = unsave,
- });
-
- /// Query an inline bot See Possible codes: -503,400 (details)
- /// The bot to query
- /// The currently opened chat
- /// The geolocation, if requested
- /// The query
- /// The offset within the results, will be passed directly as-is to the bot.
- public static Task Messages_GetInlineBotResults(this Client client, InputUserBase bot, InputPeer peer, string query, string offset, InputGeoPoint geo_point = null)
- => client.Invoke(new Messages_GetInlineBotResults
- {
- flags = (Messages_GetInlineBotResults.Flags)(geo_point != null ? 0x1 : 0),
- bot = bot,
- peer = peer,
- geo_point = geo_point,
- query = query,
- offset = offset,
- });
-
- /// Answer an inline query, for bots only See [bots: ✓] Possible codes: 400,403 (details)
- /// Set this flag if the results are composed of media files
- /// Set this flag if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
- /// Unique identifier for the answered query
- /// Vector of results for the inline query
- /// The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
- /// Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
- /// If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with a certain parameter.
- public static Task Messages_SetInlineBotResults(this Client client, long query_id, InputBotInlineResultBase[] results, DateTime cache_time, bool gallery = false, bool private_ = false, string next_offset = null, InlineBotSwitchPM switch_pm = null)
- => client.Invoke(new Messages_SetInlineBotResults
- {
- flags = (Messages_SetInlineBotResults.Flags)((gallery ? 0x1 : 0) | (private_ ? 0x2 : 0) | (next_offset != null ? 0x4 : 0) | (switch_pm != null ? 0x8 : 0)),
- query_id = query_id,
- results = results,
- cache_time = cache_time,
- next_offset = next_offset,
- switch_pm = switch_pm,
- });
-
- /// Send a result obtained using messages.getInlineBotResults. See Possible codes: 400,403,420,500 (details)
- /// Whether to send the message silently (no notification will be triggered on the other client)
- /// Whether to send the message in background
- /// Whether to clear the draft
- /// Whether to hide the via @botname in the resulting message (only for bot usernames encountered in the )
- /// Destination
- /// ID of the message this message should reply to
- /// Random ID to avoid resending the same query
- /// Query ID from messages.getInlineBotResults
- /// Result ID from messages.getInlineBotResults
- /// Scheduled message date for scheduled messages
- /// Send this message as the specified peer
- public static Task Messages_SendInlineBotResult(this Client client, InputPeer peer, long random_id, long query_id, string id, bool silent = false, bool background = false, bool clear_draft = false, bool hide_via = false, int? reply_to_msg_id = null, DateTime? schedule_date = null, InputPeer send_as = null)
- => client.Invoke(new Messages_SendInlineBotResult
- {
- flags = (Messages_SendInlineBotResult.Flags)((silent ? 0x20 : 0) | (background ? 0x40 : 0) | (clear_draft ? 0x80 : 0) | (hide_via ? 0x800 : 0) | (reply_to_msg_id != null ? 0x1 : 0) | (schedule_date != null ? 0x400 : 0) | (send_as != null ? 0x2000 : 0)),
- peer = peer,
- reply_to_msg_id = reply_to_msg_id.GetValueOrDefault(),
- random_id = random_id,
- query_id = query_id,
- id = id,
- schedule_date = schedule_date.GetValueOrDefault(),
- send_as = send_as,
- });
-
- /// Find out if a media message's caption can be edited See Possible codes: 400,403 (details)
- /// Peer where the media was sent
- /// ID of message
- public static Task Messages_GetMessageEditData(this Client client, InputPeer peer, int id)
- => client.Invoke(new Messages_GetMessageEditData
- {
- peer = peer,
- id = id,
- });
-
- /// Edit message See