예제 #1
0
        public static int InputPeerToId(TLInputPeerBase inputPeer, TLInt selfId)
        {
            var chat = inputPeer as TLInputPeerChat;

            if (chat != null)
            {
                return(chat.ChatId.Value);
            }

            var contact = inputPeer as TLInputPeerContact;

            if (contact != null)
            {
                return(contact.UserId.Value);
            }

            var foreign = inputPeer as TLInputPeerForeign;

            if (foreign != null)
            {
                return(foreign.UserId.Value);
            }

            var self = inputPeer as TLInputPeerSelf;

            if (self != null)
            {
                return(selfId.Value);
            }

            return(-1);
        }
예제 #2
0
 public override TLMessagesSaveDraft ToSaveDraftObject(TLInputPeerBase peer)
 {
     return(new TLMessagesSaveDraft
     {
         Peer = peer,
         Message = string.Empty
     });
 }
예제 #3
0
        public override TLObject FromBytes(byte[] bytes, ref int position)
        {
            bytes.ThrowExceptionIfIncorrect(ref position, Signature);

            Peer = GetObject <TLInputPeerBase>(bytes, ref position);

            return(this);
        }
예제 #4
0
        public static TLPeerBase InputPeerToPeer(TLInputPeerBase inputPeer, int selfId)
        {
            var channel = inputPeer as TLInputPeerChannel;

            if (channel != null)
            {
                return(new TLPeerChannel {
                    Id = channel.ChatId
                });
            }

            var broadcast = inputPeer as TLInputPeerBroadcast;

            if (broadcast != null)
            {
                return(new TLPeerBroadcast {
                    Id = broadcast.ChatId
                });
            }

            var chat = inputPeer as TLInputPeerChat;

            if (chat != null)
            {
                return(new TLPeerChat {
                    Id = chat.ChatId
                });
            }

            var contact = inputPeer as TLInputPeerContact;

            if (contact != null)
            {
                return(new TLPeerUser {
                    Id = contact.UserId
                });
            }

            var foreign = inputPeer as TLInputPeerForeign;

            if (foreign != null)
            {
                return(new TLPeerUser {
                    Id = foreign.UserId
                });
            }

            var self = inputPeer as TLInputPeerSelf;

            if (self != null)
            {
                return(new TLPeerUser {
                    Id = new TLInt(selfId)
                });
            }

            return(null);
        }
예제 #5
0
 public override TLSaveDraft ToSaveDraftObject(TLInputPeerBase peer)
 {
     return(new TLSaveDraft
     {
         Flags = new TLInt(0),
         Peer = peer,
         Message = TLString.Empty
     });
 }
예제 #6
0
        public static TLPeerBase InputPeerToPeer(TLInputPeerBase inputPeer, int selfId)
        {
            var channel = inputPeer as TLInputPeerChannel;

            if (channel != null)
            {
                return(new TLPeerChannel {
                    Id = channel.ChannelId
                });
            }

            // Broadcast are no more supported.
            //var broadcast = inputPeer as TLInputPeerBroadcast;
            //if (broadcast != null)
            //{
            //    return new TLPeerBroadcast { Id = broadcast.ChatId };
            //}

            var chat = inputPeer as TLInputPeerChat;

            if (chat != null)
            {
                return(new TLPeerChat {
                    Id = chat.ChatId
                });
            }

            var user = inputPeer as TLInputPeerUser;

            if (user != null)
            {
                return(new TLPeerUser {
                    Id = user.UserId
                });
            }

            var self = inputPeer as TLInputPeerSelf;

            if (self != null)
            {
                return(new TLPeerUser {
                    Id = selfId
                });
            }

            return(null);
        }
예제 #7
0
        public override TLMessagesSaveDraft ToSaveDraftObject(TLInputPeerBase peer)
        {
            var obj = new TLMessagesSaveDraft
            {
                ReplyToMsgId = ReplyToMsgId,
                Peer         = peer,
                Message      = Message,
                Entities     = Entities,
            };

            if (IsNoWebPage)
            {
                obj.IsNoWebPage = true;
            }

            return(obj);
        }
예제 #8
0
        public override TLSaveDraft ToSaveDraftObject(TLInputPeerBase peer)
        {
            var obj = new TLSaveDraft
            {
                Flags        = new TLInt(0),
                ReplyToMsgId = ReplyToMsgId,
                Peer         = peer,
                Message      = Message,
                Entities     = Entities,
            };

            if (NoWebpage)
            {
                obj.DisableWebPagePreview();
            }

            return(obj);
        }
예제 #9
0
        public static int InputPeerToId(TLInputPeerBase inputPeer, int?selfId)
        {
            var chat = inputPeer as TLInputPeerChat;

            if (chat != null)
            {
                return(chat.ChatId);
            }

            var channel = inputPeer as TLInputPeerChannel;

            if (channel != null)
            {
                return(channel.ChannelId);
            }

            // TODO: is this needed?
            //var contact = inputPeer as TLInputPeerContact;
            //if (contact != null)
            //{
            //    return contact.UserId.Value;
            //}

            //var foreign = inputPeer as TLInputPeerForeign;
            //if (foreign != null)
            //{
            //    return foreign.UserId.Value;
            //}

            var self = inputPeer as TLInputPeerSelf;

            if (self != null)
            {
                return(selfId.Value);
            }

            return(-1);
        }
예제 #10
0
 public abstract TLSaveDraft ToSaveDraftObject(TLInputPeerBase peer);
예제 #11
0
        public override TLObject FromStream(Stream input)
        {
            Peer = GetObject <TLInputPeerBase>(input);

            return(this);
        }