✅ Need help fixing CallbackData

CCashmout3/9/2023
     [TelegramCommand("ping", false, false)]
        public static async Task Ping(Update update, List<string> args)
        {
            // Create a new inline keyboard button with the text "Ping" and the callback data "ping"
            var button = new InlineKeyboardButton
            {
                Text = "Ping",
                CallbackData = "ping"
            };

            // Create a new inline keyboard markup with the button we just created
            var keyboard = new InlineKeyboardMarkup(new[] { new[] { button } });

            // Send a message with the text ":robot: Bot is online" and the inline keyboard markup we just created
            await Telegram.client.SendMessageAsync(update.Message.Chat.Id, ":robot: Bot is online", replyMarkup: keyboard);
        }
CCashmout3/9/2023
error
[TELEGRAM] CallbackQuery: ping Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array. at Estate_Example.Telegram.HandleUpdate(Update update) in C:\Users\B\Downloads\Telegram Desktop\Estate Example\Estate Example\Telegram.cs:line 93 at Estate_Example.Telegram.<>c__DisplayClass5_0.<PollingThread>b__0() in C:\Users\B\Downloads\Telegram Desktop\Estate Example\Estate Example\Telegram.cs:line 68 at System.Threading.Thread.StartCallback()
Pphaseshift3/9/2023
Is telegram.cs your code file?
CCashmout3/9/2023
Yes.
CCashmout3/9/2023
Image
Pphaseshift3/9/2023
Well what's line 93
Pphaseshift3/9/2023
I bet it has square brackets
Pphaseshift3/9/2023
It's going to be the messageid line, isn't it?
CCashmout3/9/2023
Image
Pphaseshift3/9/2023
The line numbers don't match up
Pphaseshift3/9/2023
But it's probably the messageid line. Maybe there is no : in the string
CCashmout3/9/2023
But the error msg both have to do with Callbackdata
CCashmout3/9/2023
Image
CCashmout3/9/2023
Image
CCashmout3/9/2023
case UpdateType.CallbackQuery:
    Console.WriteLine("[TELEGRAM] CallbackQuery: " + update.CallbackQuery.Data);
    var query = update.CallbackQuery;
    string[] data = query.Data.Split(':');
    if (data.Length != 2) return; // return if delimiter not found
    string querydata = data[0];
    string messageid = data[1];
    try { Telegram.client.AnswerCallbackQuery(query.Id); } catch { }
    HandleCommand(update, "", new List<string>() { messageid }, querydata);
    break;
CCashmout3/9/2023
maybe?
CCashmout3/10/2023
I can try this 1 second
CCashmout3/10/2023
it printed in cmd prompt
[TELEGRAM] CallbackQuery: ping
CCashmout3/10/2023
Image
CCashmout3/10/2023
but nothing printed.
CCashmout3/10/2023
Image
CCashmout3/10/2023
now its just loading
Pphaseshift3/10/2023
What are you confused about?
CCashmout3/10/2023
it should be printing right>
CCashmout3/10/2023
Image
Pphaseshift3/10/2023
Printing what?
CCashmout3/10/2023
"ping"
CCashmout3/10/2023
because callback?
Pphaseshift3/10/2023
Where are you sending ping in callback?
Pphaseshift3/10/2023
You exit early
CCashmout3/10/2023
Nono
CCashmout3/10/2023
I do /ping in telegram
CCashmout3/10/2023
it shows the button
CCashmout3/10/2023
when i click the button nothing happens
CCashmout3/10/2023
just shows the callback in cmd prompt
Pphaseshift3/10/2023
Yeah, because you exit early
CCashmout3/10/2023
not printing in telegram
CCashmout3/10/2023
why so
Pphaseshift3/10/2023
Thats what 'return' does
CCashmout3/10/2023
        [TelegramCommand("ping", false, false)]
        public static async Task Ping(Update update, List<string> args)
        {
            // Create a new inline keyboard button with the text "Ping" and the callback data "ping"
            var button = new InlineKeyboardButton
            {
                Text = "Ping",
                CallbackData = "ping"
            };

            // Create a new inline keyboard markup with the button we just created
            var keyboard = new InlineKeyboardMarkup(new[] { new[] { button } });

            // Send a message with the text "🤖 Bot is online" and the inline keyboard markup we just created
            Telegram.client.SendMessage(update.Message.Chat.Id, "🤖 Bot is online", replyMarkup: keyboard);
CCashmout3/10/2023
but this is the command?
CCashmout3/10/2023
so do return after?
Pphaseshift3/10/2023
That obviously happens, correct?
CCashmout3/10/2023
Sure
Pphaseshift3/10/2023
So...
Pphaseshift3/10/2023
The problem is not there
Pphaseshift3/10/2023
Like you just changed some code in the call back so it does nothing now
CCashmout3/10/2023
well theres no error?
Pphaseshift3/10/2023
And you're asking why the call back doesn't do anything?
CCashmout3/10/2023
it just prints
CCashmout3/10/2023
ping
HHowNiceOfYou3/10/2023
pong
CCashmout3/10/2023
[TELEGRAM] CallbackQuery: ping?
CCashmout3/10/2023
instead of printing ping in telegram
Pphaseshift3/10/2023
Why would it send anything to telegram client
Pphaseshift3/10/2023
You don't call anything to make it
CCashmout3/10/2023
Telegram.client.SendMessage(update.Message.Chat.Id, ":robot: Bot is online", replyMarkup: keyboard);
CCashmout3/10/2023
so what would it be than to send message
Pphaseshift3/10/2023
That one is already sent
Pphaseshift3/10/2023
You've shown it
CCashmout3/10/2023
AH
CCashmout3/10/2023
[TelegramCommand("BUTTON:Ping", false, false)]
public static async Task Ping(Update update, List<string> args) => Console.WriteLine("[ESTATE] " + await Estate.TriggerEvent("Ping", args[0]));
CCashmout3/10/2023
nvm
NNox3/10/2023
@HowNiceOfYou my guy
NNox3/10/2023
You seem to actually have a brain in that head of yours judging by your questions and everything, but self-botting is against Discord's Terms of Service
NNox3/10/2023
Please disable it if you wish to participate in this server.
NNox3/10/2023
I'll check again in a day and if not, you will be removed.
AAccord3/11/2023
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
CCashmout3/12/2023
o
CCashmout3/12/2023
[TelegramCommand("ping", false, false, "BUTTON:Ping")]
        public static async Task Ping(Update update, List<string> args)
        {
            // Create a new inline keyboard button with the text "Ping" and the callback data "ping"
            var button = new InlineKeyboardButton
            {
                Text = "Ping",
                CallbackData = "ping"
            };

            // Create a new inline keyboard markup with the button we just created
            var keyboard = new InlineKeyboardMarkup(new[] { new[] { button } });

            // Send a message with the text "🤖 Bot is online" and the inline keyboard markup we just created
            await Telegram.client.SendMessageAsync(update.Message.Chat.Id, "🤖 Bot is online", replyMarkup: keyboard);
        }
CCashmout3/12/2023
tried this but it only gives a callback to console instead of sending to the bot
CCashmout3/12/2023
y