mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
use Users_GetUsers instead of Updates_GetState in login so we update our User info
This commit is contained in:
parent
42348166f0
commit
b872e58e28
|
|
@ -24,8 +24,11 @@ namespace WTelegramClientTest
|
||||||
if (arg is not Updates { updates: var updates }) return;
|
if (arg is not Updates { updates: var updates }) return;
|
||||||
foreach (var update in updates)
|
foreach (var update in updates)
|
||||||
{
|
{
|
||||||
if (update is not UpdateNewMessage { message: Message message } || message.peer_id.ID != user.ID)
|
if (update is not UpdateNewMessage { message: Message message })
|
||||||
continue; // if it's not a new saved message, ignore it
|
continue; // if it's not about a new message, ignore the update
|
||||||
|
if (message.peer_id.ID != user.ID)
|
||||||
|
continue; // if it's not in the "Saved messages" chat, ignore it
|
||||||
|
|
||||||
if (message.media is MessageMediaDocument { document: Document document })
|
if (message.media is MessageMediaDocument { document: Document document })
|
||||||
{
|
{
|
||||||
int slash = document.mime_type.IndexOf('/'); // quick & dirty conversion from MIME type to file extension
|
int slash = document.mime_type.IndexOf('/'); // quick & dirty conversion from MIME type to file extension
|
||||||
|
|
@ -44,7 +47,7 @@ namespace WTelegramClientTest
|
||||||
fileStream.Close(); // necessary for the renaming
|
fileStream.Close(); // necessary for the renaming
|
||||||
Console.WriteLine("Download finished");
|
Console.WriteLine("Download finished");
|
||||||
if (type is not Storage_FileType.unknown and not Storage_FileType.partial)
|
if (type is not Storage_FileType.unknown and not Storage_FileType.partial)
|
||||||
File.Move(filename, $"{photo.id}.{type}"); // rename extension
|
File.Move(filename, $"{photo.id}.{type}", true); // rename extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -916,8 +916,10 @@ namespace WTelegram
|
||||||
{
|
{
|
||||||
if (prevUser.id == int.Parse(botToken.Split(':')[0]))
|
if (prevUser.id == int.Parse(botToken.Split(':')[0]))
|
||||||
{
|
{
|
||||||
var udpatesState = await this.Updates_GetState(); // this call enables incoming Updates
|
// Update our info about the user, and reenable incoming Updates
|
||||||
OnUpdate(udpatesState);
|
var users = await this.Users_GetUsers(new[] { InputUser.Self });
|
||||||
|
if (users.Length > 0 && users[0] is User self)
|
||||||
|
_session.User = prevUser = self;
|
||||||
return prevUser;
|
return prevUser;
|
||||||
}
|
}
|
||||||
Helpers.Log(3, $"Current logged user {prevUser.id} mismatched bot_token. Logging out and in...");
|
Helpers.Log(3, $"Current logged user {prevUser.id} mismatched bot_token. Logging out and in...");
|
||||||
|
|
@ -965,8 +967,10 @@ namespace WTelegram
|
||||||
if (sameUser)
|
if (sameUser)
|
||||||
{
|
{
|
||||||
// TODO: implement a more complete Updates gaps handling system? https://core.telegram.org/api/updates
|
// TODO: implement a more complete Updates gaps handling system? https://core.telegram.org/api/updates
|
||||||
var udpatesState = await this.Updates_GetState(); // this call enables incoming Updates
|
// Update our info about the user, and reenable incoming Updates
|
||||||
OnUpdate(udpatesState);
|
var users = await this.Users_GetUsers(new[] { InputUser.Self });
|
||||||
|
if (users.Length > 0 && users[0] is User self)
|
||||||
|
_session.User = prevUser = self;
|
||||||
return prevUser;
|
return prevUser;
|
||||||
}
|
}
|
||||||
Helpers.Log(3, $"Current logged user {prevUser.id} mismatched user_id or phone_number. Logging out and in...");
|
Helpers.Log(3, $"Current logged user {prevUser.id} mismatched user_id or phone_number. Logging out and in...");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue