sochix / TLSharp

Telegram client library implemented in C#
1.01k stars 380 forks source link

Start Bot Via Link #914

Open abrpr opened 4 years ago

abrpr commented 4 years ago

hi i wanna start bat with link. for example i wanna start bot X like that: https://t.me/X?start=123 how can i do it ? actually 123 is referral id and i wanna start bot with it. in my code i found and start a BOT like below: //BOT is my bot name TeleSharp.TL.Contacts.TLFound found = await this.client.SearchUserAsync(BOT); var FromUser = found.Users .Where(x => x.GetType() == typeof(TLUser)) .Cast<TLUser>() .FirstOrDefault(c => c.Username == BOT); peer = new TLInputPeerUser { UserId = FromUser.Id, AccessHash = FromUser.AccessHash.Value }; await this.client.SendMessageAsync(peer, "/start");

Muaath5 commented 3 years ago

See messages.startBot You can find this as class in TeleSharp.TL.Messages.TLRequestStartBot And do like this:

var startMsg = new TeleSharp.TL.Messages.TLRequestStartBot()
{
    Bot = peer, // Bot user
    Peer = me, // Chat or user who send message
    StartParam = "123" // Your own start parameter
};
// Send request
TelegramClient.SendRequestAsync<TeleSharp.TL.Messages.TLRequestStartBot>(startMsg);
abrpr commented 3 years ago

On Sun, Jan 17, 2021 at 10:59 مُعَاذ القَرْنِي notifications@github.com wrote:

See messages.startBot https://core.telegram.org/method/messages.startBot You can find this as class in TeleSharp.TL.Messages.TLRequestStartBot https://github.com/sochix/TLSharp/blob/master/TeleSharp.TL/TL/Messages/TLRequestStartBot.cs And do like this:

var startMsg = new TeleSharp.TL.Messages.TLRequestStartBot() { Bot = peer, // Bot user Peer = me, // Chat or user who send message StartParam = "123" // Your own start parameter };// Send requestTelegramClient.SendRequestAsync(startMsg);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sochix/TLSharp/issues/914#issuecomment-761747988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFUPUTPXQOSDOSFJXNNVVLS2KGXHANCNFSM4LD6SGKA .

Thanks a lot my friend