mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-04-05 14:35:43 +00:00
Renamed OnUpdate => OnUpdates (with temporary compatibility shim)
This commit is contained in:
parent
270a7d89e6
commit
3d224afb23
12 changed files with 49 additions and 52 deletions
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TL;
|
||||
|
||||
|
|
@ -15,10 +13,10 @@ namespace WTelegramClientTest
|
|||
Console.WriteLine("The program will download photos/medias from messages you send/forward to yourself (Saved Messages)");
|
||||
using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
var user = await client.LoginUserIfNeeded();
|
||||
client.OnUpdate += Client_OnUpdate;
|
||||
client.OnUpdates += Client_OnUpdates;
|
||||
Console.ReadKey();
|
||||
|
||||
async Task Client_OnUpdate(UpdatesBase updates)
|
||||
async Task Client_OnUpdates(UpdatesBase updates)
|
||||
{
|
||||
foreach (var update in updates.UpdateList)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TL;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace WTelegramClientTest
|
|||
Client = new WTelegram.Client(store.Length == 0 ? null : Environment.GetEnvironmentVariable, store);
|
||||
using (Client)
|
||||
{
|
||||
Client.OnUpdate += Client_OnUpdate;
|
||||
Client.OnUpdates += Client_OnUpdates;
|
||||
My = await Client.LoginUserIfNeeded();
|
||||
Console.WriteLine($"We are logged-in as {My.username ?? My.first_name + " " + My.last_name} (id {My.id})");
|
||||
var dialogs = await Client.Messages_GetAllDialogs();
|
||||
|
|
@ -39,7 +39,7 @@ namespace WTelegramClientTest
|
|||
}
|
||||
}
|
||||
|
||||
private static async Task Client_OnUpdate(UpdatesBase updates)
|
||||
private static async Task Client_OnUpdates(UpdatesBase updates)
|
||||
{
|
||||
updates.CollectUsersChats(Users, Chats);
|
||||
foreach (var update in updates.UpdateList)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace WTelegramClientTest
|
|||
Client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
using (Client)
|
||||
{
|
||||
Client.OnUpdate += Client_OnUpdate;
|
||||
Client.OnUpdates += Client_OnUpdates;
|
||||
My = await Client.LoginUserIfNeeded();
|
||||
Users[My.id] = My;
|
||||
// Note: on login, Telegram may sends a bunch of updates/messages that happened in the past and were not acknowledged
|
||||
|
|
@ -33,7 +33,7 @@ namespace WTelegramClientTest
|
|||
}
|
||||
|
||||
// if not using async/await, we could just return Task.CompletedTask
|
||||
private static async Task Client_OnUpdate(UpdatesBase updates)
|
||||
private static async Task Client_OnUpdates(UpdatesBase updates)
|
||||
{
|
||||
updates.CollectUsersChats(Users, Chats);
|
||||
if (updates is UpdateShortMessage usm && !Users.ContainsKey(usm.user_id))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot.Types;
|
||||
using TL;
|
||||
|
||||
namespace WTelegramClientTest
|
||||
|
|
@ -28,7 +27,7 @@ namespace WTelegramClientTest
|
|||
private static async Task CreateAndConnect()
|
||||
{
|
||||
Client = new WTelegram.Client(Environment.GetEnvironmentVariable);
|
||||
Client.OnUpdate += Client_OnUpdate;
|
||||
Client.OnUpdates += Client_OnUpdates;
|
||||
Client.OnOther += Client_OnOther;
|
||||
var my = await Client.LoginUserIfNeeded();
|
||||
Console.WriteLine($"We are logged-in as " + my);
|
||||
|
|
@ -61,7 +60,7 @@ namespace WTelegramClientTest
|
|||
Console.WriteLine("Other: " + arg.GetType().Name);
|
||||
}
|
||||
|
||||
private static Task Client_OnUpdate(UpdatesBase updates)
|
||||
private static Task Client_OnUpdates(UpdatesBase updates)
|
||||
{
|
||||
foreach (var update in updates.UpdateList)
|
||||
Console.WriteLine(update.GetType().Name);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace WTelegramClientTest
|
|||
AppDomain.CurrentDomain.ProcessExit += (s, e) => { Secrets.Dispose(); Client.Dispose(); };
|
||||
SelectActiveChat();
|
||||
|
||||
Client.OnUpdate += Client_OnUpdate;
|
||||
Client.OnUpdates += Client_OnUpdates;
|
||||
var myself = await Client.LoginUserIfNeeded();
|
||||
Users[myself.id] = myself;
|
||||
Console.WriteLine($"We are logged-in as {myself}");
|
||||
|
|
@ -76,7 +76,7 @@ Type a command, or a message to send to the active secret chat:");
|
|||
} while (true);
|
||||
}
|
||||
|
||||
private static async Task Client_OnUpdate(UpdatesBase updates)
|
||||
private static async Task Client_OnUpdates(UpdatesBase updates)
|
||||
{
|
||||
updates.CollectUsersChats(Users, Chats);
|
||||
foreach (var update in updates.UpdateList)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue