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); }
public override TLMessagesSaveDraft ToSaveDraftObject(TLInputPeerBase peer) { return(new TLMessagesSaveDraft { Peer = peer, Message = string.Empty }); }
public override TLObject FromBytes(byte[] bytes, ref int position) { bytes.ThrowExceptionIfIncorrect(ref position, Signature); Peer = GetObject <TLInputPeerBase>(bytes, ref position); return(this); }
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); }
public override TLSaveDraft ToSaveDraftObject(TLInputPeerBase peer) { return(new TLSaveDraft { Flags = new TLInt(0), Peer = peer, Message = TLString.Empty }); }
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); }
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); }
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); }
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); }
public abstract TLSaveDraft ToSaveDraftObject(TLInputPeerBase peer);
public override TLObject FromStream(Stream input) { Peer = GetObject <TLInputPeerBase>(input); return(this); }