MajMcCloud / TelegramBotFramework

This is a context based application framework for the C# TelegramBot library.
https://www.t.me/tgbotbase
MIT License
139 stars 42 forks source link

Random Bug #66

Open cheditx opened 3 weeks ago

cheditx commented 3 weeks ago

To be honest i don't know what really happened, i just got this error after receiving some updates on the bot

System.NullReferenceException: Object reference not set to an instance of an object. at TelegramBotBase.BotBase.Client_MessageLoop(Object sender, UpdateResult e) at TelegramBotBase.Base.MessageClient.OnMessageLoop(UpdateResult update) at TelegramBotBase.Base.MessageClient.HandleUpdateAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken) at Telegram.Bot.Polling.DefaultUpdateHandler.HandleUpdateAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken) at Telegram.Bot.Polling.DefaultUpdateReceiver.ReceiveAsync(IUpdateHandler updateHandler, CancellationToken cancellationToken) at Telegram.Bot.TelegramBotClientExtensions.ReceiveAsync(ITelegramBotClient botClient, IUpdateHandler updateHandler, ReceiverOptions receiverOptions, CancellationToken cancellationToken) at Telegram.Bot.TelegramBotClientExtensions.<>c__DisplayClass127_0.<b__0>d.MoveNext()

EDIT:

i ""fixed"" just by switching from the version 6.5 to 6.4

MajMcCloud commented 3 weeks ago

Hey, 6.5 has removed a lot of try/catches so you should debug a bit more into the issue. Do you have an example project to test on ?

Is this the full stack trace ? Cause there havent been changes within the last called method for a long time.

cheditx commented 3 weeks ago

Hey, 6.5 has removed a lot of try/catches so you should debug a bit more into the issue. Do you have an example project to test on ?

Is this the full stack trace ? Cause there havent been changes within the last called method for a long time.

Yes its all the console print, i used a simple example code with FormBase implementation

var bot = BotBaseBuilder.Create().QuickStart("XXXXXXXXXXXXXXXXXXXXXXXX").Build(); await bot.Start();

    Console.ReadLine();
    await bot.Stop();

  and then a class with MessagesListener : FormBase with Load(MessageResult)
MajMcCloud commented 3 weeks ago

Yes its all the console print, i used a simple example code with FormBase implementation

var bot = BotBaseBuilder.Create().QuickStart("XXXXXXXXXXXXXXXXXXXXXXXX").Build(); await bot.Start();

    Console.ReadLine();
    await bot.Stop();

  and then a class with MessagesListener : FormBase with Load(MessageResult)

I tested it as well with image

And it works as expected. I would say there is probably some issue within your StartForm. But I do not know exactly.

Did you sent a message or /start command to invoke the bot ?

MajMcCloud commented 3 weeks ago

Did you used a StartFormFactory or just a Form ?

cheditx commented 3 weeks ago

Yes its all the console print, i used a simple example code with FormBase implementation var bot = BotBaseBuilder.Create().QuickStart("XXXXXXXXXXXXXXXXXXXXXXXX").Build(); await bot.Start();

    Console.ReadLine();
    await bot.Stop();

  and then a class with MessagesListener : FormBase with Load(MessageResult)

I tested it as well with image

And it works as expected. I would say there is probably some issue within your StartForm. But I do not know exactly.

Did you sent a message or /start command to invoke the bot ?

My code worked well all the time, until i added it on a group idk what happened, i used the same FormBase as always and it just returned that error, i tried with another token and it started working again

MajMcCloud commented 3 weeks ago

Some stuff regards bot commands I groups changed. But I believe that has nothing to do, with your case.

Edit: but that's a good hint, I'll try that out to reproduce it.

Edit2: groups works different, therefore is a special form called "SplitterForm"

MajMcCloud commented 3 weeks ago

My code worked well all the time, until i added it on a group idk what happened, i used the same FormBase as always and it just returned that error, i tried with another token and it started working again

Another token means probably different group settings. If you got access to both, please check the BotFather settings for groups. There are different ones.

MajMcCloud commented 3 weeks ago

@cheditx So this issue can be closed ?

cheditx commented 3 weeks ago

@cheditx So this issue can be closed ?

i don't think so, because everytime a bot join a group the bot gets an error...

MajMcCloud commented 3 weeks ago

@cheditx So this issue can be closed ?

i don't think so, because everytime a bot join a group the bot gets an error...

Then I need more details or an example project. I added my testbot to a group and it works fine. (I used the public available TelegramBotBase.Example project)

So please give more insights on what you do exactly.

MajMcCloud commented 2 weeks ago

Fixed via #67 and version 6.5.1