diff --git a/src/Client.cs b/src/Client.cs index 73ca7ba..e379ac5 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -140,8 +140,11 @@ namespace WTelegram private static string AskConfig(string config) { - if (config == "session_key") return null; - if (config == "api_hash") Console.WriteLine("Welcome! You can obtain your api_id/api_hash at https://my.telegram.org/apps"); + if (config == "session_key") + { + Console.WriteLine("Welcome! You can obtain your api_id/api_hash at https://my.telegram.org/apps"); + return null; + } Console.Write($"Enter {config.Replace('_', ' ')}: "); return Console.ReadLine(); } diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs index c890f6c..2ed8094 100644 --- a/src/TL.Helpers.cs +++ b/src/TL.Helpers.cs @@ -50,19 +50,19 @@ namespace TL { public override string ToString() => "user " + user_id; public override long ID => user_id; - internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => users[user_id]; + internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => users.TryGetValue(user_id, out var user) ? user : null; } partial class PeerChat { public override string ToString() => "chat " + chat_id; public override long ID => chat_id; - internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => chats[chat_id]; + internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => chats.TryGetValue(chat_id, out var chat) ? chat : null; } partial class PeerChannel { public override string ToString() => "channel " + channel_id; public override long ID => channel_id; - internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => chats[channel_id]; + internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => chats.TryGetValue(channel_id, out var chat) ? chat : null; } partial class UserBase : IPeerInfo diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index 3bb3bee..e91dab6 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -488,7 +488,7 @@ namespace TL /// Latitide public double lat; /// Longtitude - public double long_; + public double lon; /// The estimated horizontal accuracy of the location, in meters; as defined by the sender. [IfFlag(0)] public int accuracy_radius; @@ -2279,7 +2279,7 @@ namespace TL /// Flags, see TL conditional fields public Flags flags; /// Longtitude - public double long_; + public double lon; /// Latitude public double lat; /// Access hash @@ -4187,20 +4187,24 @@ namespace TL } /// Object which is perceived by the client without a call on its part when an event occurs. Derived classes: , , , , , , See - public abstract partial class UpdatesBase : IObject + public abstract partial class UpdatesBase : IObject, IPeerResolver { /// date public abstract DateTime Date { get; } + /// returns a or for the given Peer + public abstract IPeerInfo UserOrChat(Peer peer); } /// Too many updates, it is necessary to execute updates.getDifference. See [TLDef(0xE317AF7E)] - public partial class UpdatesTooLong : UpdatesBase + public partial class UpdatesTooLong : UpdatesBase, IPeerResolver { public override DateTime Date => default; + /// returns a or for the given Peer + public override IPeerInfo UserOrChat(Peer peer) => null; } /// Info about a message sent to (received from) another user See [TLDef(0x313BC7F8)] - public partial class UpdateShortMessage : UpdatesBase + public partial class UpdateShortMessage : UpdatesBase, IPeerResolver { /// Flags, see TL conditional fields public Flags flags; @@ -4251,10 +4255,12 @@ namespace TL /// date public override DateTime Date => date; + /// returns a or for the given Peer + public override IPeerInfo UserOrChat(Peer peer) => null; } /// Shortened constructor containing info on one new incoming text message from a chat See [TLDef(0x4D6DEEA5)] - public partial class UpdateShortChatMessage : UpdatesBase + public partial class UpdateShortChatMessage : UpdatesBase, IPeerResolver { /// Flags, see TL conditional fields public Flags flags; @@ -4307,10 +4313,12 @@ namespace TL /// date public override DateTime Date => date; + /// returns a or for the given Peer + public override IPeerInfo UserOrChat(Peer peer) => null; } /// Shortened constructor containing info on one update not requiring auxiliary data See [TLDef(0x78D4DEC1)] - public partial class UpdateShort : UpdatesBase + public partial class UpdateShort : UpdatesBase, IPeerResolver { /// Update public Update update; @@ -4319,6 +4327,8 @@ namespace TL /// Date of event public override DateTime Date => date; + /// returns a or for the given Peer + public override IPeerInfo UserOrChat(Peer peer) => null; } /// Constructor for a group of updates. See [TLDef(0x725B04C3)] @@ -4340,7 +4350,7 @@ namespace TL /// Current date public override DateTime Date => date; /// returns a or for the given Peer - public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } /// Full constructor of updates See [TLDef(0x74AE4240)] @@ -4360,11 +4370,11 @@ namespace TL /// Current date public override DateTime Date => date; /// returns a or for the given Peer - public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } /// Shortened constructor containing info on one outgoing message to a contact (the destination chat has to be extracted from the method call that returned this object). See [TLDef(0x9015E101)] - public partial class UpdateShortSentMessage : UpdatesBase + public partial class UpdateShortSentMessage : UpdatesBase, IPeerResolver { /// Flags, see TL conditional fields public Flags flags; @@ -4397,6 +4407,8 @@ namespace TL /// date public override DateTime Date => date; + /// returns a or for the given Peer + public override IPeerInfo UserOrChat(Peer peer) => null; } /// Full list of photos with auxiliary data. See diff --git a/src/TL.Secret.cs b/src/TL.Secret.cs index cf0bcac..4b00823 100644 --- a/src/TL.Secret.cs +++ b/src/TL.Secret.cs @@ -111,7 +111,7 @@ namespace TL /// Latitude of point public double lat; /// Longtitude of point - public double long_; + public double lon; } /// Contact attached to an encrypted message. See [TLDef(0x588A0A97)] @@ -459,7 +459,7 @@ namespace TL /// Latitude of venue public double lat; /// Longitude of venue - public double long_; + public double lon; /// Venue name public string title; /// Address