public override TLObject FromBytes(byte[] bytes, ref int position) { bytes.ThrowExceptionIfIncorrect(ref position, Signature); Flags = GetObject <TLInt>(bytes, ref position); Id = GetObject <TLInt>(bytes, ref position); UserId = GetObject <TLInt>(bytes, ref position); Message = GetObject <TLString>(bytes, ref position); Pts = GetObject <TLInt>(bytes, ref position); PtsCount = GetObject <TLInt>(bytes, ref position); Date = GetObject <TLInt>(bytes, ref position); if (IsSet(Flags, (int)MessageFlags.Fwd)) { FwdFrom = GetObject <TLPeerBase>(bytes, ref position); FwdDate = GetObject <TLInt>(bytes, ref position); } if (IsSet(Flags, (int)MessageFlags.Reply)) { ReplyToMsgId = GetObject <TLInt>(bytes, ref position); } if (IsSet(Flags, (int)MessageFlags.Entities)) { Entities = GetObject <TLVector <TLMessageEntityBase> >(bytes, ref position); } #if DEBUG var messageString = Message.ToString(); var logString = string.Format("TLUpdateShortMessage40 id={0} flags={1} user_id={2} message={3} pts={4} pts_count={5} date={6} fwd_from={7} fwd_date={8} reply_to_msg_id={9} entities={10}", Id, TLMessageBase.MessageFlagsString(Flags), UserId, messageString.Substring(0, Math.Min(messageString.Length, 5)), Pts, PtsCount, Date, FwdFrom, FwdDate, ReplyToMsgId, Entities); Logs.Log.Write(logString); #endif return(this); }
public override TLObject FromBytes(byte[] bytes, ref int position) { bytes.ThrowExceptionIfIncorrect(ref position, Signature); Peer = GetObject <TLPeerBase>(bytes, ref position); return(this); }
public static TLMessage36 GetMessage( TLInt fromId, TLPeerBase toId, MessageStatus status, TLBool outFlag, TLBool unreadFlag, TLInt date, TLString message, TLMessageMediaBase media, TLLong randomId, TLInt replyToMsgId) { #if LAYER_40 var m = new TLMessage40 { Flags = new TLInt(0), FromId = fromId, ToId = toId, _status = status, Out = outFlag, Unread = unreadFlag, _date = date, Message = message, _media = media, RandomId = randomId, ReplyToMsgId = replyToMsgId }; if (m.FromId != null) { m.SetFromId(); } if (m._media != null) { m.SetMedia(); } if (m.ReplyToMsgId != null) { m.SetReply(); } #else var m = new TLMessage36 { FromId = fromId, ToId = toId, _status = status, Out = outFlag, Unread = unreadFlag, _date = date, Message = message, _media = media, RandomId = randomId, ReplyToMsgId = replyToMsgId }; #endif return(m); }
public static TLMessage GetMessage( int fromId, TLPeerBase toId, TLMessageState state, bool outFlag, bool unreadFlag, int date, string message, TLMessageMediaBase media, long randomId, int?replyToMsgId) { #if LAYER_40 var m = new TLMessage { FromId = fromId, ToId = toId, State = state, IsOut = outFlag, IsUnread = unreadFlag, Date = date, Message = message, Media = media, RandomId = randomId, ReplyToMsgId = replyToMsgId }; if (m.FromId != null) { m.HasFromId = true; } if (m.Media != null) { m.HasMedia = true; } if (m.ReplyToMsgId != null) { m.HasReplyToMsgId = true; } #else var m = new TLMessage { FromId = fromId, ToId = toId, _status = status, Out = outFlag, Unread = unreadFlag, _date = date, Message = message, _media = media, RandomId = randomId, ReplyToMsgId = replyToMsgId }; #endif return(m); }
public static TLMessage40 GetShortMessage( TLInt id, TLInt fromId, TLPeerBase toId, TLInt date, TLString message) { #if LAYER_40 var m = new TLMessage40 { Flags = new TLInt(0), Id = id, FromId = fromId, ToId = toId, Out = TLBool.False, _date = date, Message = message, _media = new TLMessageMediaEmpty() }; if (m.FromId != null) { m.SetFromId(); } if (m._media != null) { m.SetMedia(); } #else var m = new TLMessage36 { Id = id, FromId = fromId, ToId = toId, Out = TLBool.False, _date = date, Message = message, _media = new TLMessageMediaEmpty() }; #endif return(m); }
public static TLPeerBase GetPeerFromMessage(TLDecryptedMessageBase message) { TLPeerBase peer = null; var commonMessage = message; if (commonMessage != null) { if (commonMessage.ChatId != null) { peer = new TLPeerEncryptedChat { Id = commonMessage.ChatId }; } } else { WriteLine("Cannot get peer from non TLDecryptedMessage", LogSeverity.Error); } return(peer); }
public static TLMessage GetShortMessage(int id, int fromId, TLPeerBase toId, int date, string message) { #if LAYER_40 var m = new TLMessage { Id = id, FromId = fromId, ToId = toId, IsOut = false, Date = date, Message = message, Media = new TLMessageMediaEmpty(), IsUnread = true, }; if (m.FromId > 0) { m.HasFromId = true; } if (m.Media != null) { m.HasMedia = true; } #else var m = new TLMessage { Id = id, FromId = fromId, ToId = toId, Out = false, _date = date, Message = message, _media = new TLMessageMediaEmpty() }; #endif return(m); }
// TODO: Secrets //public static TLPeerBase GetPeerFromMessage(TLDecryptedMessageBase message) //{ // TLPeerBase peer = null; // var commonMessage = message; // if (commonMessage != null) // { // if (commonMessage.ChatId != null) // { // peer = new TLPeerEncryptedChat{ Id = commonMessage.ChatId }; // } // } // else // { // WriteLine("Cannot get peer from non TLDecryptedMessage", LogSeverity.Error); // } // return peer; //} public static TLPeerBase GetPeerFromMessage(TLMessageBase message) { TLPeerBase peer = null; var commonMessage = message as TLMessageCommonBase; if (commonMessage != null) { if (commonMessage.ToId is TLPeerChannel) { peer = commonMessage.ToId; } else if (commonMessage.ToId is TLPeerChat) { peer = commonMessage.ToId; } else { if (commonMessage.IsOut) { peer = commonMessage.ToId; } else { peer = new TLPeerUser { Id = commonMessage.FromId.Value }; } } } else { WriteLine("Cannot get peer from non TLMessage", LogSeverity.Error); } return(peer); }
public override TLObject FromStream(Stream input) { Peer = GetObject <TLPeerBase>(input); return(this); }