Exemple #1
0
 public Task SetPartyType(BubbleGroup group, PartyOptionsSettingsPartyType type, Action <bool> result)
 {
     return(Task.Factory.StartNew(() =>
     {
         try
         {
             if (type == PartyOptionsSettingsPartyType.Public)
             {
                 var randomUserName = RandomString(32);
                 DebugPrint("The random username is " + randomUserName);
                 using (var client = new FullClientDisposable(this))
                 {
                     var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsUpdateUsernameAsync(new SharpTelegram.Schema.ChannelsUpdateUsernameArgs
                     {
                         Channel = new InputChannel
                         {
                             ChannelId = uint.Parse(group.Address),
                             AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address)))
                         },
                         Username = randomUserName
                     }));
                     result(response);
                 }
             }
             else
             {
                 using (var client = new FullClientDisposable(this))
                 {
                     var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsUpdateUsernameAsync(new SharpTelegram.Schema.ChannelsUpdateUsernameArgs
                     {
                         Channel = new InputChannel
                         {
                             ChannelId = uint.Parse(group.Address),
                             AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address)))
                         },
                         Username = ""
                     }));
                     result(response);
                 }
             }
         }
         catch (Exception e)
         {
             DebugPrint("##### Exeption while setting group type " + e);
             result(false);
         }
     }));
 }
 public Task SetPartyType(BubbleGroup group, PartyOptionsSettingsPartyType type, Action<bool> result)
 {
     return Task.Factory.StartNew(() =>
     {
         try
         {
             if (type == PartyOptionsSettingsPartyType.Public)
             {
                 var randomUserName = RandomString(32);
                 DebugPrint("The random username is " + randomUserName);
                 using (var client = new FullClientDisposable(this))
                 {
                     var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsUpdateUsernameAsync(new SharpTelegram.Schema.ChannelsUpdateUsernameArgs
                     {
                         Channel = new InputChannel
                         {
                             ChannelId = uint.Parse(group.Address),
                             AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address)))
                         },
                         Username = randomUserName
                     }));
                     result(response);
                 }
             }
             else
             {
                 using (var client = new FullClientDisposable(this))
                 {
                     var response = TelegramUtils.RunSynchronously(client.Client.Methods.ChannelsUpdateUsernameAsync(new SharpTelegram.Schema.ChannelsUpdateUsernameArgs
                     {
                         Channel = new InputChannel
                         {
                             ChannelId = uint.Parse(group.Address),
                             AccessHash = TelegramUtils.GetChannelAccessHash(_dialogs.GetChat(uint.Parse(group.Address)))
                         },
                         Username = ""
                     }));
                     result(response);
                 }
             }
         }
         catch (Exception e)
         {
             DebugPrint("##### Exeption while setting group type " + e);
             result(false);
         }
     });
 }