Open AndrewChan0513 opened 7 years ago
I found the bot Button is just pass the text only. So I just need to get the message from bot and get the button text :
But when I SendRequestAsync using : TLMessagesSlice it have a Exception.
var dialogs = await client.GetUserDialogsAsync();
var chat = dialogs.users.lists
.Where(c => c.GetType() == typeof(TLUser))
.Cast<TLUser>()
.FirstOrDefault(c => c.username == "villagegamebot");
var inputPeer = new TLInputPeerUser() { user_id = chat.id };
var res = await client.SendRequestAsync<TLMessagesSlice>(new TLRequestGetHistory() { peer = inputPeer });
chat var : inputPeer :
Exception :
System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=PEER_ID_INVALID Source=TLSharp.Core StackTrace: 於 TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 288 於 TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 193 於 TLSharp.Core.Network.MtProtoSender.
d9.MoveNext() 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 144 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 TLSharp.Core.TelegramClient. d 151.MoveNext() 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\TelegramClient.cs: 行 153 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() 於 WindowsFormsApplication3.Form1.d__82.MoveNext() 於 C:\Users\andrewchan\Documents\Visual Studio 2015\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs: 行 490 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 於 WindowsFormsApplication3.Form1. d__108.MoveNext() 於 C:\Users\andrewchan\Documents\Visual Studio 2015\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs: 行 890 InnerException:
Seems like you couldn't get messages from bot with gethistory method. You should explore telegram api for the different method
10 нояб. 2016 г. 7:37 пользователь "AndrewChan0513" < notifications@github.com> написал:
I found the bot Button is just pass the text only. So I just need to get the message from bot and get the button text : [image: image] https://cloud.githubusercontent.com/assets/20835419/20164652/1ca0ffea-a741-11e6-98fe-146e01eea8b7.png
But when I SendRequestAsync using : TLMessagesSlice https://core.telegram.org/constructor/messages.messagesSlice it have a Exception.
var dialogs = await client.GetUserDialogsAsync(); var chat = dialogs.users.lists .Where(c => c.GetType() == typeof(TLUser)) .Cast<TLUser>() .FirstOrDefault(c => c.username == "villagegamebot"); var inputPeer = new TLInputPeerUser() { user_id = chat.id }; var res = await client.SendRequestAsync<TLMessagesSlice>(new TLRequestGetHistory() { peer = inputPeer });
chat var : [image: image] https://cloud.githubusercontent.com/assets/20835419/20164713/b064e476-a741-11e6-9ca1-519275f97b71.png inputPeer : [image: image] https://cloud.githubusercontent.com/assets/20835419/20164766/43315a3c-a742-11e6-846f-ded325ed3fe0.png
Exception :
System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=PEER_ID_INVALID Source=TLSharp.Core StackTrace: 於 TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 288 於 TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 193 於 TLSharp.Core.Network.MtProtoSender.d9.MoveNext() 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 144 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) 於 TLSharp.Core.TelegramClient.d151.MoveNext() 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\TelegramClient.cs: 行 153 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() 於 WindowsFormsApplication3.Form1.d82.MoveNext() 於 C:\Users\andrewchan\Documents\Visual Studio 2015\Projects\ WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs: 行 490 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 於 WindowsFormsApplication3.Form1.d108.MoveNext() 於 C:\Users\andrewchan\Documents\Visual Studio 2015\Projects\ WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs: 行 890 InnerException:
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sochix/TLSharp/issues/299#issuecomment-259599933, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd-YpnCP-akfLnSP8AAuq2odZucmmT_ks5q8p-AgaJpZM4KuM-o .
I've changed to use TLInputPeerChat :
var dialogs = await client.GetUserDialogsAsync();
var chat = dialogs.users.lists
.Where(c => c.GetType() == typeof(TLUser))
.Cast<TLUser>()
.FirstOrDefault(c => c.username == "villagegamebot");
var inputPeer = new TLInputPeerChat() { chat_id = chat.id };
var res = await client.SendRequestAsync<TLMessagesSlice>(new TLRequestGetHistory() { peer = inputPeer });
But it still trough exception :
System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=PEER_ID_INVALID Source=TLSharp.Core StackTrace: 於 TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 288 於 TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 193 於 TLSharp.Core.Network.MtProtoSender.
d9.MoveNext() 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs: 行 144 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 TLSharp.Core.TelegramClient. d 151.MoveNext() 於 Y:\TLSharp-master\TLSharp-master\TLSharp.Core\TelegramClient.cs: 行 153 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() 於 WindowsFormsApplication3.Form1.d__82.MoveNext() 於 C:\Users\andrewchan\Documents\Visual Studio 2015\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs: 行 490 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 於 WindowsFormsApplication3.Form1. d__108.MoveNext() 於 C:\Users\andrewchan\Documents\Visual Studio 2015\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs: 行 890 InnerException:
I've review TeleSharp.TL.Messages.TLRequestGetHistory method is using -1347868602 ( afa92846 ) :
It can accept inputPeerChat too.
Telegram Documention is Outdated so don't use it.
Any updates ?
Any updates for this topic?
@tuandoi1 @eko24ive
Made a quick code on getting the buttons and url from them 👍 Since i didn't see any help thought i would try!
TLInputPeerUser peer = new TLInputPeerUser {UserId = user.Id, AccessHash = user.AccessHash.Value};
TLAbsMessages tlAbsMessages = await client.GetHistoryAsync(peer, 0, -1, 100);
var tlMessages = (TLMessages) tlAbsMessages;
foreach (TLAbsMessage tlAbsMessage in tlMessages.Messages)
{
if (!(tlAbsMessage is TLMessage message)) continue;
if (!(message.ReplyMarkup is TLReplyInlineMarkup replyMarkup)) continue;
TLVector<TLKeyboardButtonRow> rows = replyMarkup.Rows;
Console.WriteLine($"Rows {rows.Count}");
foreach (TLKeyboardButtonRow keyRow in rows)
{
TLVector<TLAbsKeyboardButton> buttons = keyRow.Buttons;
Console.WriteLine($"Buttons {buttons.Count}");
if (buttons.Count <= 0) continue;
foreach (TLAbsKeyboardButton keyBtn in buttons)
{
var key = (TLKeyboardButtonUrl) keyBtn;
Console.WriteLine(key.Url);
}
}
}
This works fine for me! It can be optimized just say thank you if you use it or share code if you made it more simple 👍
@Erinio Thanks for repply.
I want click to button. I can help me.
Many thanks
TLVector<TLAbsKeyboardButton> buttons = keyRow.Buttons;
Console.WriteLine($"Buttons {buttons.Count}");
if (buttons.Count <= 0) continue;
foreach (TLAbsKeyboardButton keyBtn in buttons)
{
var key = (TLKeyboardButtonUrl) keyBtn;
Console.WriteLine(key.Url);
}
That part is for the button data (Text, Url) etc. go ahead and check it. @tuandoi1
@Erinio thank you, I will try
@Erinio thank you, I will try
Any updates?
Just like this button :
http://stackoverflow.com/questions/38376354/how-can-i-show-keyboard-buttons-in-a-telegram-bot-integrated-with-api-ai
AND inline keyboard button :
https://core.telegram.org/bots/2-0-intro