public async Task <TLAbsUpdates> addUserIntoChannel(string userID, TLChannel channel) { if (string.IsNullOrEmpty(userID)) { return(null); } switch (_isbot) { case BotTypeApi.REAL_BOT: break; case BotTypeApi.USER_BOT: { try { var users = new TLVector <TLAbsInputUser>(); if (userID.StartsWith("@")) { var u = await UserbotPeer.GetPeerUserWithAccessHash(userID.Substring(1), _userbotClient); TLAbsInputUser input2 = new TLInputUser { AccessHash = u.AccessHash, UserId = u.UserId }; users.Add(input2); } else { users.Add(UserbotPeer.GetPeerUserFromdId(Convert.ToInt32(userID))); } var tLInputChannel = new TLInputChannel { ChannelId = channel.Id }; if (channel.AccessHash != null) { tLInputChannel.AccessHash = channel.AccessHash.Value; } var r = await _userbotClient.ChannelsInviteToChannel(tLInputChannel, users); return(r); } catch (Exception e) { ; } } break; case BotTypeApi.DISGUISED_BOT: break; } return(null); }
// get list of strings with paths to pictures files in folder pfile private static TLVector <string> GetPicturesPaths(string pfile = null) { string folder = null; if (null != pfile && Directory.Exists(pfile)) { folder = pfile; } else { folder = TLAPIData.attachmentsFolder; } string[] paths = null; TLVector <string> filePaths = new TLVector <string>(); string[] searchPattern = new string[] { "*.jpg", "*.jpeg", "*.gif", "*.png", "*.bmp" }; foreach (string pattenr in searchPattern) { paths = Directory.GetFiles(folder, pattenr, SearchOption.TopDirectoryOnly); foreach (string path in paths) { filePaths.Add(path); } } return(filePaths); }
//**********************************************************// //** Below is Members routines **// //**********************************************************// // Return members list from specified group Name private static TLVector <TLAbsUser> GetGroupMembers(string gname, string ufile = null) { long hash = 0; int gid = GetGroupIdByName(gname, out hash); TeleSharp.TL.Messages.TLChatFull ch = GetGroupFullById(gid, hash); if (0 == hash && MembersLogAndSave(ch.Users, ufile, gname)) { return(ch.Users); } int offset = 0; TLChannelParticipants ps = null; TLVector <TLAbsUser> users = new TLVector <TLAbsUser>(); do { ps = client.GetChannelParticipants(gid, hash, offset, 5000).GetAwaiter().GetResult(); foreach (TLUser u in ps.Users) { users.Add(u); } offset += ps.Users.Count; } while (users.Count < ps.Count && 0 != ps.Users.Count); MembersLogAndSave(users, ufile, gname); return(users); }
private void DeleteMessagesInternal(TLObject owner, TLMessageBase lastMessage, IList <TLMessageBase> messages) { var ids = new TLVector <TLInt>(); for (int i = 0; i < messages.Count; i++) { ids.Add(messages[i].Id); } // duplicate: deleting performed through updates CacheService.DeleteMessages(ids); BeginOnUIThread(() => { for (var i = 0; i < messages.Count; i++) { for (var j = 0; j < Items.Count; j++) { var dialog = Items[j] as TLDialog; if (dialog != null && dialog.TopMessage != null && dialog.TopMessage.Id.Value == messages[i].Index) { Items.RemoveAt(j); break; } } } }); EventAggregator.Publish(new DeleteMessagesEventArgs { Owner = owner, Messages = messages }); }
private void SearchStickerSet(string text) { IsWorking = true; MTProtoService.GetStickerSetAsync(new TLInputStickerSetShortName { ShortName = new TLString(text) }, result => Execute.BeginOnUIThread(() => { IsWorking = false; var objects = new TLVector <TLObject>(); foreach (var sticker in result.Documents) { objects.Add(new TLStickerItem { Document = sticker }); } result.Set.Stickers = objects; Set(result.Set, false); }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Set(new TLStickerSetNotFound(), false); })); }
public TLVector <TLKeyboardButtonRow> GetMatrixTlKeyboardButton() { if (_list == null) { return(null); } var r = new TLVector <TLKeyboardButtonRow>(); foreach (var v1 in _list) { var buttons = new TLVector <TLAbsKeyboardButton>(); foreach (var v2 in v1) { buttons.Add(new TLKeyboardButton { Text = v2.Text }); } var row = new TLKeyboardButtonRow { Buttons = buttons }; r.Add(row); } return(r); }
public async Task <MTObject> Handle(IMessageContext <TLLogOut> context) { var result = new TLVector <bool>(); result.Add(true); return(result); }
private IList <TLBotCommand> GetCommands() { if (_commands != null) { return(_commands); } var user = With as TLUserBase; if (user != null) { if (user.BotInfo == null) { return(null); } var botInfo = user.BotInfo as TLBotInfo; if (botInfo != null) { foreach (var command in botInfo.Commands) { command.Bot = user; } _commands = botInfo.Commands; } } var chat = With as TLChat; if (chat != null) { if (chat.BotInfo == null) { return(null); } var commands = new TLVector <TLBotCommand>(); foreach (var botInfoBase in chat.BotInfo) { var botInfo = botInfoBase as TLBotInfo; if (botInfo != null) { user = CacheService.GetUser(botInfo.UserId); foreach (var command in botInfo.Commands) { command.Bot = user; commands.Add(command); } } } _commands = commands; } return(_commands); }
public void Load() { if (_messages == null) { return; } var messages = TLUtils.OpenObjectFromMTProtoFile <TLVector <TLMessageBase> >(_liveLocationsSyncRoot, Constants.LiveLocationsFileName) ?? new TLVector <TLMessageBase>(); var m = new List <TLMessage>(); lock (_liveLocationsSyncRoot) { _messages.Clear(); foreach (var messageBase in messages) { var message = messageBase as TLMessage70; if (message != null) { if (message.InputPeer == null) { return; } var mediaGeoLive = message.Media as TLMessageMediaGeoLive; if (mediaGeoLive != null) { mediaGeoLive.EditDate = message.EditDate; mediaGeoLive.Date = message.Date; if (!mediaGeoLive.Active) { continue; } } _messages.Add(messageBase); m.Add(message); } } } _eventAggregator.Publish(new LiveLocationLoadedEventArgs { Messages = m }); }
private async static Task <TLVector <TLAbsMessage> > CounterPostsAsync( TLChannel channel, TelegramClient client, bool IsAll, int countPost = 100) { Thread.Sleep(TimeSpan.FromSeconds(1)); if (IsAll) { countPost = 100; } var posts = new TLVector <TLAbsMessage>(); TLInputPeerChannel inputPeer = new TLInputPeerChannel() { ChannelId = channel.Id, AccessHash = (long)channel.AccessHash }; int offset = 0; TLChannelMessages res; int target = 0; while (true) { try { res = await client.SendRequestAsync <TLChannelMessages> (new TLRequestGetHistory() { Peer = inputPeer, Limit = countPost, AddOffset = offset, OffsetId = 0 }); } catch (Exception e) { return(posts); } var msgs = res.Messages; if (posts.Count == 100 && IsAll) { break; } offset += countPost; foreach (var post in msgs) { posts.Add(post); } if (msgs.Count >= countPost && (IsAll == false)) { break; } } return(posts); }
private void UpdateSets(IStickers iStickers) { _stickers = iStickers; _emoticons.Clear(); _stickerSets.Clear(); for (var i = 0; i < iStickers.Documents.Count; i++) { var document22 = iStickers.Documents[i] as TLDocument22; if (document22 != null) { if (document22.StickerSet != null) { var setId = document22.StickerSet.Name; TLVector <TLStickerItem> stickers; if (_stickerSets.TryGetValue(setId, out stickers)) { stickers.Add(new TLStickerItem { Document = document22 }); } else { _stickerSets[setId] = new TLVector <TLStickerItem> { new TLStickerItem { Document = document22 } }; } } } } var firstChunkSize = 10; var count = 0; var delayedItems = new List <TLStickerSetBase>(); for (var i = 0; i < iStickers.Sets.Count; i++) { var set = iStickers.Sets[i]; var setName = set.Id.ToString(); TLVector <TLStickerItem> stickers; if (_stickerSets.TryGetValue(setName, out stickers)) { var objects = new TLVector <TLObject>(); foreach (var sticker in stickers) { objects.Add(sticker); } set.Stickers = objects; } } }
public async Task <MTObject> Handle_Deperacted(IMessageContext <TLGetHistory> context) { await Task.CompletedTask; var chats = new TLVector <TLAbsChat>(); var chat = new NET.Schema.Layer72.TLChat { Title = "draft12", Flags = 0, Id = 101, admin = true, Photo = new TLChatPhotoEmpty { } //Photo = new TLChatPhoto { // Flags = 0, // HasVideo = false, // PhotoBig = new TLFileLocationToBeDeprecated { }, // PhotoSmall = new TLFileLocationToBeDeprecated { } //} }; chats.Add(chat); var message = new MTProto.NET.Schema.Layer72.TLMessage { Message = "hi therexxx", ToId = new TLPeerUser { UserId = 12, } }; var messages = new TLVector <TLAbsMessage> { }; messages.Add(message); var users = new TLVector <TLAbsUser>() { }; //users.Add(new TLUserEmpty { }); users.Add(new NET.Schema.Layer72.TLUser { Id = 1, FirstName = "Ahmad" }); var result = new TLMessages() { Messages = messages, // new TLVector<TLAbsMessage> { }, Chats = chats, Users = users }; return(result); }
// Get members list from a members.txt file (yo use for spam or assignment to an another Group) private static TLVector <TLAbsUser> GetMembersFromFile(string ufile) { TLVector <TLAbsUser> users = new TLVector <TLAbsUser>(); string[] members = File.ReadAllLines(ufile); foreach (string m in members) { if (m == members[0]) { continue; } TLUser user = null; string[] props = m.Split(';'); if (!String.IsNullOrWhiteSpace(m) && 5 == props.Length) { int userId = 0; user = new TLUser(); foreach (string p in props) { string[] keyval = p.Split('='); if ("Id" == keyval[0]) { user.Id = (int.TryParse(keyval[1], out userId)) ? userId : 0; } else if ("Phone" == keyval[0]) { user.Phone = keyval[1]; } else if ("First" == keyval[0]) { user.FirstName = keyval[1]; } else if ("Last" == keyval[0]) { user.LastName = keyval[1]; } else if ("Nick" == keyval[0]) { user.Username = keyval[1]; } } } if (null != user) { user.Id = GetMemberIdByNickname(user); users.Add(user); } } MembersLogAndSave(users, ufile, "READ MEMEBERS FILE"); return(users); }
public static void ImportContactsAsync(IFileManager fileManager, ContactsOperationToken token, IList <TLUserBase> contacts, Action <Telegram.Api.WindowsPhone.Tuple <int, int> > progressCallback, System.Action cancelCallback) { #if WP8 Execute.BeginOnThreadPool(async() => { //var contacts = _cacheService.GetContacts(); var totalCount = contacts.Count; if (totalCount == 0) { return; } var store = await ContactStore.CreateOrOpenAsync(); var importedCount = 0; var delayedContacts = new TLVector <TLInt>(); foreach (var contact in contacts) { if (token.IsCanceled) { cancelCallback.SafeInvoke(); return; } try { var delayedContact = await UpdateContactInternalAsync(contact, fileManager, store, true); if (delayedContact != null) { delayedContacts.Add(delayedContact.Id); } } catch (Exception ex) { // continue import after failed contact } //Thread.Sleep(100); importedCount++; progressCallback.SafeInvoke(new Telegram.Api.WindowsPhone.Tuple <int, int>(importedCount, totalCount)); //var duration = importedCount == totalCount ? 0.5 : 2.0; //_mtProtoService.SetMessageOnTime(duration, string.Format("Sync contacts ({0} of {1})...", importedCount, totalCount)); } var result = new TLVector <TLInt>(); foreach (var delayedContact in delayedContacts) { result.Add(delayedContact); } SaveDelayedContactsAsync(result); }); #endif }
public static TLVector <T> Deserialize(BinaryReader reader) { TLVector <T> vector = new TLVector <T>(); // Babak //uint constructor = reader.ReadUInt32(); //if (constructor != vector.Constructor) throw new InvalidOperationException("Vector deserialization failed, this is not a vector!"); //int count = reader.ReadInt32(); uint count_or_constructor = reader.ReadUInt32(); uint count = 0; if (count_or_constructor < 1000) { count = count_or_constructor; } else if (count_or_constructor != vector.Constructor) { throw new InvalidOperationException("Vector deserialization failed, this is not a vector!"); } else { count = reader.ReadUInt32(); } for (int i = 0; i < count; i++) { if (typeof(MTObject).IsAssignableFrom(typeof(T))) { vector.Add((T)(object)MTObjectSerializer.Deserialize(reader)); } else { vector.Add((T)SerializationContext.Deserialize(reader, typeof(T))); } } return(vector); }
private void CleanupQueue() { var itemsToRemove = new List <HistoryItem>(); lock (_sendingQueueSyncRoot) { var now = DateTime.Now; for (var i = 0; i < _sendingQueue.Count; i++) { var historyItem = _sendingQueue[i]; if (historyItem.SendBeforeTime > now) { continue; } itemsToRemove.Add(historyItem); _sendingQueue.RemoveAt(i--); } if (_sendingQueue.Count == 0) { StopSendingTimer(); } } lock (_historyRoot) { for (var i = 0; i < itemsToRemove.Count; i++) { _history.Remove(itemsToRemove[i].Hash); } } var actions = new TLVector <TLObject>(); for (var i = 0; i < itemsToRemove.Count; i++) { actions.Add(itemsToRemove[i].Object); } RemoveActionInfoFromFile(actions); Helpers.Execute.BeginOnThreadPool(() => { foreach (var item in itemsToRemove) { item.FaultQueueCallback?.Invoke(new TLRPCError { ErrorCode = 404, ErrorMessage = "MTProtoService.CleanupQueue" }); } }); }
private string GetUserName(TLUser user, TLVector <TLMessageEntityBase> entities, int offset) { string name; if (user == null) { name = string.Empty; } else { name = user.FullName; } if (offset >= 0) { var entity = new TLMessageEntityMentionName(); entity.UserId = user.Id; entity.Offset = offset; entity.Length = name.Length; entities.Add(entity); } if (string.IsNullOrEmpty(user.Username)) { return(name); } if (offset >= 0) { var entity = new TLMessageEntityMentionName(); entity.UserId = user.Id; entity.Offset = (name.Length + offset) + 2; entity.Length = user.Username.Length + 1; entities.Add(entity); } return(String.Format("{0} (@{1})", name, user.Username)); }
private async void CallDeleteExecute(TLCallGroup group) { var confirm = await TLMessageDialog.ShowAsync(Strings.Android.ConfirmDeleteCallLog, Strings.Android.AppName, Strings.Android.OK, Strings.Android.Cancel); if (confirm != ContentDialogResult.Primary) { return; } var messages = new TLVector <int>(group.Items.Select(x => x.Id).ToList()); Task <MTProtoResponse <TLMessagesAffectedMessages> > task; var peer = group.Message.Parent.ToInputPeer(); if (peer is TLInputPeerChannel channelPeer) { task = ProtoService.DeleteMessagesAsync(new TLInputChannel { ChannelId = channelPeer.ChannelId, AccessHash = channelPeer.AccessHash }, messages); } else { task = ProtoService.DeleteMessagesAsync(messages, false); } var response = await task; if (response.IsSucceeded) { var cachedMessages = new TLVector <long>(); var remoteMessages = new TLVector <int>(); for (int i = 0; i < messages.Count; i++) { if (group.Items[i].RandomId.HasValue && group.Items[i].RandomId != 0L) { cachedMessages.Add(group.Items[i].RandomId.Value); } if (group.Items[i].Id > 0) { remoteMessages.Add(group.Items[i].Id); } } CacheService.DeleteMessages(peer.ToPeer(), null, remoteMessages); CacheService.DeleteMessages(cachedMessages); Items.Remove(group); } }
public virtual void Create() { if (string.IsNullOrEmpty(Title)) { MessageBox.Show(AppResources.PleaseEnterGroupSubject, AppResources.Error, MessageBoxButton.OK); return; } var participants = new TLVector <TLInputUserBase>(); foreach (var item in SelectedUsers) { participants.Add(item.ToInputUser()); } if (participants.Count == 0) { MessageBox.Show(AppResources.PleaseChooseAtLeastOneParticipant, AppResources.Error, MessageBoxButton.OK); return; } IsWorking = true; MTProtoService.CreateChatAsync(participants, new TLString(Title), statedMessage => { IsWorking = false; foreach (var item in Items) { item.IsSelected = false; } var updates = statedMessage as TLUpdates; if (updates != null) { StateService.With = updates.Chats.First(); StateService.RemoveBackEntry = true; BeginOnUIThread(() => NavigationService.UriFor <DialogDetailsViewModel>().Navigate()); } }, error => Execute.BeginOnUIThread(() => { IsWorking = false; if (error.CodeEquals(ErrorCode.FLOOD)) { MessageBox.Show(AppResources.FloodWaitString + Environment.NewLine + "(" + error.Message + ")", AppResources.Error, MessageBoxButton.OK); } })); }
public void ClearQueue() { var itemsToRemove = new List <HistoryItem>(); lock (_sendingQueueSyncRoot) { var now = DateTime.Now; for (var i = 0; i < _sendingQueue.Count; i++) { var historyItem = _sendingQueue[i]; itemsToRemove.Add(historyItem); _sendingQueue.RemoveAt(i--); } if (_sendingQueue.Count == 0) { StopSendingTimer(); } } lock (_historyRoot) { for (var i = 0; i < itemsToRemove.Count; i++) { _history.Remove(itemsToRemove[i].Hash); } } var actions = new TLVector <TLObject>(); for (var i = 0; i < itemsToRemove.Count; i++) { actions.Add(itemsToRemove[i].Object); } ClearActionInfoFile(); Helpers.Execute.BeginOnThreadPool(() => { foreach (var item in itemsToRemove) { item.FaultQueueCallback.SafeInvoke(new TLRPCError { Code = new TLInt(404), Message = new TLString("MTProtoService.CleanupQueue") }); } }); }
private void AddResult(TLVector <TLDifference> results, TLDifference result) { if (results.Count > 0) { var firstResult = results.FirstOrDefault(); var usersCache = new Dictionary <int, TLUserBase>(); var chatsCache = new Dictionary <int, TLChatBase>(); foreach (var user in firstResult.Users) { usersCache[user.Index] = user; } foreach (var chat in firstResult.Chats) { chatsCache[chat.Index] = chat; } foreach (var user in result.Users) { usersCache[user.Index] = user; } foreach (var chat in result.Chats) { chatsCache[chat.Index] = chat; } result.Users = new TLVector <TLUserBase>(); result.Chats = new TLVector <TLChatBase>(); var users = new TLVector <TLUserBase>(); foreach (var user in usersCache.Values) { users.Add(user); } firstResult.Users = users; var chats = new TLVector <TLChatBase>(); foreach (var chat in chatsCache.Values) { chats.Add(chat); } firstResult.Chats = chats; } _results.Add(result); }
private void SaveImportedPhones(Dictionary <string, string> importedPhonesCache, List <string> importingPhones) { foreach (var importingPhone in importingPhones) { importedPhonesCache[importingPhone] = importingPhone; } var importedPhones = new TLVector <TLString>(importedPhonesCache.Keys.Count); foreach (var importedPhone in importedPhonesCache.Keys) { importedPhones.Add(new TLString(importedPhone)); } TLUtils.SaveObjectToMTProtoFile(_importedPhonesRoot, Constants.ImportedPhonesFileName, importedPhones); }
public async Task SendLocalVideoAsync(YVideo video, VideoStreamInfo videoStream, string path) { if (video == null) { throw new ArgumentNullException("video"); } if (videoStream == null) { throw new ArgumentNullException("videoStream"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } FileInfo file = new FileInfo(path); if (!file.Exists) { throw new Exception(string.Format("Файл по адресу {0} не найден", path)); } TLAbsInputFile fileResult = this.UploadLocalFileToTelegram(path, video.Title); string mimeType = "video/mp4"; TLDocumentAttributeVideo attr1 = new TLDocumentAttributeVideo() { Duration = (int)video.Duration.TotalSeconds + 1, H = videoStream.Resolution.Height, W = videoStream.Resolution.Width, }; TLVector <TLAbsDocumentAttribute> attrs = new TLVector <TLAbsDocumentAttribute>(); attrs.Add(attr1); TLInputPeerUser peer = new TLInputPeerUser() { UserId = this.CurrentAuthUser.Id }; var sendTask = this.TClient.SendUploadedDocument( peer, fileResult, video.Title, mimeType, attrs); sendTask.Wait(); }
public void TLVectorSerialization() { var intvec = new TLVector<TLInt>(testedInts.Length); foreach(var i in testedInts) { intvec.Add(new TLInt(i)); } var buffer = intvec.ToBytes(); CollectionAssert.AreEqual(bufferInt, buffer); using (var stream = new MemoryStream()) { intvec.ToStream(stream); stream.Read(buffer, 0, 28); // Observed through debugging CollectionAssert.AreEqual(bufferInt, buffer); } }
private void DeleteMessagesInternal(TLObject owner, TLMessageBase lastMessage, IList <TLMessageBase> messages) { var ids = new TLVector <TLInt>(); for (int i = 0; i < messages.Count; i++) { ids.Add(messages[i].Id); } // duplicate: deleting performed through updates CacheService.DeleteMessages(ids); DeleteLinksInternal(messages); EventAggregator.Publish(new DeleteMessagesEventArgs { Owner = owner, Messages = messages }); }
public override async Task <TlFileToSend> GetMediaTl(TelegramClient client) { _stream.Seek(0, SeekOrigin.Begin); var streamReader = new StreamReader(_stream); var r = await client.UploadFile(_fileName, streamReader); var attributes = new TLVector <TLAbsDocumentAttribute>(); TLAbsDocumentAttribute att1 = new TLDocumentAttributeFilename { FileName = _fileName }; attributes.Add(att1); return(r switch { null => null, TLInputFile r2 => new TlFileToSend(r2, _mimeType, attributes), _ => null });
public async Task <TLImportedContacts> AddContact(string phoneNumber, string firstName, string lastName) { var contacts = new TLVector <TLInputPhoneContact>(); contacts.Add(new TLInputPhoneContact { Phone = phoneNumber, FirstName = firstName, LastName = lastName }); var req = new TLRequestImportContacts() { Contacts = contacts }; return(await telegramClient?.SendRequestAsync <TLImportedContacts>(req)); }
private void DeleteMessagesInternal(TLMessageBase lastMessage, IList <TLMessageBase> messages) { var cachedMessages = new TLVector <long>(); var remoteMessages = new TLVector <int>(); for (int i = 0; i < messages.Count; i++) { if (messages[i].RandomId.HasValue && messages[i].RandomId != 0L) { cachedMessages.Add(messages[i].RandomId.Value); } if (messages[i].Id > 0) { remoteMessages.Add(messages[i].Id); } } CacheService.DeleteMessages(Peer.ToPeer(), lastMessage, remoteMessages); CacheService.DeleteMessages(cachedMessages); var dialog = CacheService.GetDialog(_peer.ToPeer()); if (dialog != null) { Aggregator.Publish(new MessagesRemovedEventArgs(dialog, messages)); } Execute.BeginOnUIThread(() => { for (int j = 0; j < messages.Count; j++) { Media.All(x => x.Remove(messages[j] as TLMessage)); Files.All(x => x.Remove(messages[j] as TLMessage)); Links.All(x => x.Remove(messages[j] as TLMessage)); Music.All(x => x.Remove(messages[j] as TLMessage)); } RaisePropertyChanged(() => With); SelectionMode = ListViewSelectionMode.None; //this.IsEmptyDialog = (this.Items.get_Count() == 0 && this.LazyItems.get_Count() == 0); //this.NotifyOfPropertyChange<TLObject>(() => this.With); }); }
private void DeleteMessagesInternal(TLMessageBase lastMessage, IList <TLMessageBase> messages) { var cachedMessages = new TLVector <long>(); var remoteMessages = new TLVector <int>(); for (int i = 0; i < messages.Count; i++) { if (messages[i].RandomId.HasValue && messages[i].RandomId != 0L) { cachedMessages.Add(messages[i].RandomId.Value); } if (messages[i].Id > 0) { remoteMessages.Add(messages[i].Id); } } CacheService.DeleteMessages(Peer.ToPeer(), lastMessage, remoteMessages); CacheService.DeleteMessages(cachedMessages); Execute.BeginOnUIThread(() => { for (int j = 0; j < messages.Count; j++) { if (_editedMessage != null && _editedMessage.Id == messages[j].Id) { ClearReplyCommand.Execute(); } else if (ReplyInfo != null && ReplyInfo.ReplyToMsgId == messages[j].Id) { ClearReplyCommand.Execute(); } Messages.Remove(messages[j]); } RaisePropertyChanged(() => With); SelectionMode = ListViewSelectionMode.None; //this.IsEmptyDialog = (this.Items.get_Count() == 0 && this.LazyItems.get_Count() == 0); //this.NotifyOfPropertyChange<TLObject>(() => this.With); }); }
// Return active / inactive members list from specified group Name private static TLVector <TLAbsUser> GetGroupActiveMembers(string gname, bool active, string ufile = null) { long hash = 0; int gid = GetGroupIdByName(gname, out hash); TLVector <TLAbsUser> au = new TLVector <TLAbsUser>(); TLVector <TLAbsUser> users = GetGroupMembers(gname); foreach (TLUser u in users) { bool a = IsMemberActive(u, gid); if (active && a || !active && !a) { au.Add(u); } } MembersLogAndSave(au, ufile, gname); return(au); }
public static TLVector <T> Deserialize(BinaryReader reader) { TLVector <T> vector = new TLVector <T>(); uint constructor = reader.ReadUInt32(); if (constructor != vector.Constructor) { throw new InvalidOperationException("Vector deserialization failed, this is not a vector!"); } int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { vector.Add((T)SerializationContext.Deserialize(reader, typeof(T))); } return(vector); }