public Task UnblockPartyParticipant(BubbleGroup group, DisaParticipant participant, Action<bool> result) { return Task.Factory.StartNew(() => { using (var client = new FullClientDisposable(this)) { try { var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsKickFromChannelAsync(new ChannelsKickFromChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Kicked = false, UserId = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) } })); result(true); } catch (Exception e) { DebugPrint("#### Exception " + e); result(false); } } }); }
public Task UnblockPartyParticipant(BubbleGroup group, DisaParticipant participant, Action <bool> result) { return(Task.Factory.StartNew(() => { using (var client = new FullClientDisposable(this)) { try { var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsKickFromChannelAsync(new ChannelsKickFromChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Kicked = false, UserId = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) } })); result(true); } catch (Exception e) { DebugPrint("#### Exception " + e); result(false); } } })); }
public Task DemotePartyParticipantsFromLeader(BubbleGroup group, DisaParticipant participant, Action <DemotePartyParticipantsResult> result) { return(Task.Factory.StartNew(() => { var inputUser = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) }; using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { if (!ChatAdminsEnabled(group.Address)) { result(DemotePartyParticipantsResult.AllMembersAreAdministratorsEnabled); return; } try { TelegramUtils.RunSynchronously(client.Client.Methods.MessagesEditChatAdminAsync(new MessagesEditChatAdminArgs { ChatId = uint.Parse(group.Address), IsAdmin = false, UserId = inputUser, })); result(DemotePartyParticipantsResult.Success); } catch (Exception e) { result(DemotePartyParticipantsResult.Failure); } } else { try { var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsEditAdminAsync(new ChannelsEditAdminArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Role = new ChannelRoleEmpty(), UserId = inputUser })); SendToResponseDispatcher(response, client.Client); result(DemotePartyParticipantsResult.Success); } catch (Exception e) { result(DemotePartyParticipantsResult.Failure); } } } })); }
public Task AddPartyParticipant(BubbleGroup group, DisaParticipant participant, Action <AddPartyResult> result) { return(Task.Factory.StartNew(() => { AddPartyParticipant(group, participant) .ContinueWith((task) => result(_addPartyResult)); })); }
public Task GetPartyPhoto(BubbleGroup group, DisaParticipant participant, bool preview, Action <DisaThumbnail> result) { return(Task.Factory.StartNew(() => { DisaThumbnail thumbnail; if (participant == null) { thumbnail = GetThumbnail(group.Address, group.IsParty, preview); } else { thumbnail = GetThumbnail(participant.Address, false, preview); } result(thumbnail); })); }
public Task DeletePartyParticipant(BubbleGroup group, DisaParticipant participant) { return(Task.Factory.StartNew(() => { var inputUser = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) }; using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { var update = TelegramUtils.RunSynchronously(client.Client.Methods.MessagesDeleteChatUserAsync(new MessagesDeleteChatUserArgs { ChatId = uint.Parse(group.Address), UserId = inputUser, })); SendToResponseDispatcher(update, client.Client); } else { try { var update = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsKickFromChannelAsync(new ChannelsKickFromChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Kicked = true, UserId = inputUser })); SendToResponseDispatcher(update, client.Client); } catch (Exception e) { DebugPrint("Exception " + e); } } } })); }
public Task PromotePartyParticipantToLeader(BubbleGroup group, DisaParticipant participant) { return(Task.Factory.StartNew(() => { var inputUser = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) }; using (var client = new FullClientDisposable(this)) { if (!ChatAdminsEnabled(group.Address)) { //this condition should ideally never be hit // if chat admins are disabled, everyone is an admin and hence the ui never allows anyone to be promoted to an admin } if (!group.IsExtendedParty) { TelegramUtils.RunSynchronously(client.Client.Methods.MessagesEditChatAdminAsync(new MessagesEditChatAdminArgs { ChatId = uint.Parse(group.Address), IsAdmin = true, UserId = inputUser, })); } else { TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsEditAdminAsync(new ChannelsEditAdminArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Role = new ChannelRoleModerator(), UserId = inputUser })); } } })); }
public Task AddPartyParticipant(BubbleGroup group, DisaParticipant participant) { var inputUser = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) }; return(Task.Factory.StartNew(() => { using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { var update = TelegramUtils.RunSynchronously(client.Client.Methods.MessagesAddChatUserAsync(new MessagesAddChatUserArgs { UserId = inputUser, ChatId = uint.Parse(group.Address), FwdLimit = 0 })); SendToResponseDispatcher(update, client.Client); } else { var update = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsInviteToChannelAsync(new ChannelsInviteToChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Users = new List <IInputUser> { inputUser } })); SendToResponseDispatcher(update, client.Client); } } })); }
public Task AddPartyParticipant(BubbleGroup group, DisaParticipant participant) { var inputUser = new InputUser { UserId = uint.Parse(participant.Address) }; return Task.Factory.StartNew(() => { using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { var update = TelegramUtils.RunSynchronously(client.Client.Methods.MessagesAddChatUserAsync(new MessagesAddChatUserArgs { UserId = inputUser, ChatId = uint.Parse(group.Address), FwdLimit = 0 })); SendToResponseDispatcher(update, client.Client); } else { var update = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsInviteToChannelAsync(new ChannelsInviteToChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Users = new List<IInputUser> { inputUser } })); SendToResponseDispatcher(update, client.Client); } } }); }
public Task DeletePartyParticipant(BubbleGroup group, DisaParticipant participant) { return Task.Factory.StartNew(() => { var inputUser = new InputUser {UserId = uint.Parse(participant.Address)}; using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { var update = TelegramUtils.RunSynchronously(client.Client.Methods.MessagesDeleteChatUserAsync(new MessagesDeleteChatUserArgs { ChatId = uint.Parse(group.Address), UserId = inputUser, })); SendToResponseDispatcher(update, client.Client); } else { var update = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsKickFromChannelAsync(new ChannelsKickFromChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Kicked = true, UserId = inputUser })); SendToResponseDispatcher(update, client.Client); } } }); }
public Task GetPartyPhoto(BubbleGroup group, DisaParticipant participant, bool preview, Action<DisaThumbnail> result) { return Task.Factory.StartNew(() => { DisaThumbnail thumbnail; if (participant == null) { thumbnail = GetThumbnail(group.Address, group.IsParty, preview); } else { thumbnail = GetThumbnail(participant.Address, false, preview); } result(thumbnail); }); }
public override Task GetBubbleGroupPartyParticipantPhoto(DisaParticipant participant, Action<DisaThumbnail> result) { throw new NotImplementedException(); }
public override Task GetBubbleGroupPartyParticipantPhoto(DisaParticipant participant, Action<DisaThumbnail> result) { return Task.Factory.StartNew(() => { result(GetThumbnail(participant.Address, false, true)); }); }
public Task DemotePartyParticipantsFromLeader(BubbleGroup group, DisaParticipant participant, Action<DemotePartyParticipantsResult> result) { return Task.Factory.StartNew(() => { var inputUser = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) }; using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { if (!ChatAdminsEnabled(group.Address)) { result(DemotePartyParticipantsResult.AllMembersAreAdministratorsEnabled); return; } try { TelegramUtils.RunSynchronously(client.Client.Methods.MessagesEditChatAdminAsync(new MessagesEditChatAdminArgs { ChatId = uint.Parse(group.Address), IsAdmin = false, UserId = inputUser, })); result(DemotePartyParticipantsResult.Success); } catch (Exception e) { result(DemotePartyParticipantsResult.Failure); } } else { try { var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsEditAdminAsync(new ChannelsEditAdminArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Role = new ChannelRoleEmpty(), UserId = inputUser })); SendToResponseDispatcher(response, client.Client); result(DemotePartyParticipantsResult.Success); } catch (Exception e) { result(DemotePartyParticipantsResult.Failure); } } } }); }
public Task PromotePartyParticipantToLeader(BubbleGroup group, DisaParticipant participant) { return Task.Factory.StartNew(() => { var inputUser = new InputUser {UserId = uint.Parse(participant.Address)}; using (var client = new FullClientDisposable(this)) { if (!ChatAdminsEnabled(group.Address)) { //this condition should ideally never be hit // if chat admins are disabled, everyone is an admin and hence the ui never allows anyone to be promoted to an admin } if (!group.IsExtendedParty) { TelegramUtils.RunSynchronously(client.Client.Methods.MessagesEditChatAdminAsync(new MessagesEditChatAdminArgs { ChatId = uint.Parse(group.Address), IsAdmin = true, UserId = inputUser, })); } else { TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsEditAdminAsync(new ChannelsEditAdminArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Role = new ChannelRoleModerator(), UserId = inputUser })); } } }); }
public override Task GetBubbleGroupPartyParticipantPhoto(DisaParticipant participant, Action<DisaThumbnail> result) { return Task.Factory.StartNew(() => { //TODO: results from partyparticipants need to be cached // GetThumbnails should then search those as well, // because _dialog.Users does not contain all users in participant list result(GetThumbnail(participant.Address, false, true)); }); }
public override Task GetBubbleGroupPartyParticipantPhoto(DisaParticipant participant, Action <DisaThumbnail> result) { throw new NotImplementedException(); }
public Task AddPartyParticipant(BubbleGroup group, DisaParticipant participant) { _addPartyResult = AddPartyResult.Success; var inputUser = new InputUser { UserId = uint.Parse(participant.Address), AccessHash = GetUserAccessHashIfForeign(participant.Address) }; return(Task.Factory.StartNew(() => { var user = _dialogs.GetUser(uint.Parse(participant.Address)) as User; if (user.BotNochats != null) { _addPartyResult = AddPartyResult.BotNoChat; return; } using (var client = new FullClientDisposable(this)) { if (!group.IsExtendedParty) { try { var update = TelegramUtils.RunSynchronously(client.Client.Methods.MessagesAddChatUserAsync(new MessagesAddChatUserArgs { UserId = inputUser, ChatId = uint.Parse(group.Address), FwdLimit = 0 })); SendToResponseDispatcher(update, client.Client); } catch (Exception ex) { Utils.DebugPrint("Failed Telegram MessagesAddChatUserAsync: " + ex.Message); if (ex.Message.Contains("PEER_FLOOD")) { _addPartyResult = AddPartyResult.Flood; } else { _addPartyResult = AddPartyResult.Error; } return; } } else { try { var update = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsInviteToChannelAsync(new ChannelsInviteToChannelArgs { Channel = new InputChannel { ChannelId = uint.Parse(group.Address), AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address))) }, Users = new List <IInputUser> { inputUser } })); SendToResponseDispatcher(update, client.Client); } catch (Exception ex) { Utils.DebugPrint("Failed Telegram ChannelsInviteToChannelAsync: " + ex.Message); if (ex.Message.Contains("PEER_FLOOD")) { _addPartyResult = AddPartyResult.Flood; } else { _addPartyResult = AddPartyResult.Error; } return; } } } })); }