TelegramBotFramework icon indicating copy to clipboard operation
TelegramBotFramework copied to clipboard

Random Bug

Open cheditx opened this issue 1 year ago • 11 comments

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.<<StartReceiving>b__0>d.MoveNext()

EDIT:

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

cheditx avatar Jul 01 '24 03:07 cheditx

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.

MajMcCloud avatar Jul 01 '24 11:07 MajMcCloud

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<MessagesListener>("XXXXXXXXXXXXXXXXXXXXXXXX").Build(); await bot.Start();

    Console.ReadLine();
    await bot.Stop();
    
  and then a class with MessagesListener : FormBase with Load(MessageResult)

cheditx avatar Jul 01 '24 15:07 cheditx

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 avatar Jul 01 '24 15:07 MajMcCloud

Did you used a StartFormFactory or just a Form ?

MajMcCloud avatar Jul 01 '24 15:07 MajMcCloud

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

cheditx avatar Jul 01 '24 18:07 cheditx

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 avatar Jul 01 '24 19:07 MajMcCloud

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 avatar Jul 01 '24 19:07 MajMcCloud

@cheditx So this issue can be closed ?

MajMcCloud avatar Jul 03 '24 12:07 MajMcCloud

@cheditx So this issue can be closed ?

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

cheditx avatar Jul 04 '24 01:07 cheditx

@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 avatar Jul 04 '24 20:07 MajMcCloud

Fixed via #67 and version 6.5.1

MajMcCloud avatar Jul 10 '24 12:07 MajMcCloud