Leask / halbot

Just another `ChatGPT` / `Gemini` / `Mistral (by ollama)` Telegram bob, which is simple design, easy to use, extendable and fun.
https://leaskh.com/post/711636926789271552/halbot
MIT License
101 stars 16 forks source link

should be only one telegram bot instance running #31

Closed mccoysc closed 1 year ago

mccoysc commented 1 year ago

as the title image

Leask commented 1 year ago

This is an API error only triggered by the telegram server, meaning your bot token is used in another bot, maybe Hotbot or another bot program. Check your token first. If you are not sure, please create another bot token.

mccoysc commented 1 year ago

This is an API error only triggered by the telegram server, meaning your bot token is used in another bot, maybe Hotbot or another bot program. Check your token first. If you are not sure, please create another bot token.

no,i have fixed the issue by

if(process.bot) return process.bot;

process.bot=bot

the old code may call init multiply times.

Leask commented 1 year ago

That does not make any sense.

mccoysc commented 1 year ago

That does not make any sense.

the issue is a bug,not as you said "use bot at other place". it's caused by call "init" multiply times

Leask commented 1 year ago

You should only initiate one time for a bot. And using process.bot is a bad idea for this "fix". You can keep your own version, but I am not going to follow. Sorry.

mccoysc commented 1 year ago

You should only initiate one time for a bot. And using process.bot is a bad idea for this "fix". You can keep your own version, but I am not going to follow. Sorry.

the init called many times in utilitas/lib/bot.js.

it should be fixed by some way

Leask commented 1 year ago

Could you tell me how you initiated the bot multiple times?

mccoysc commented 1 year ago

Could you tell me how you initiated the bot multiple times?

image

image

Leask commented 1 year ago

No, init func will not create a new instance. It will get the instance one instead because these two lines call the init func without options: https://github.com/Leask/utilitas/blob/master/lib/bot.mjs#LL680C5-L680C5

Leask commented 1 year ago

Init means get or init.

mccoysc commented 1 year ago

Init means get or init.

but after i add THE CODE,the issue is fixed

Leask commented 1 year ago

There should be another issue hidden. We run more than ten different instances. You are the first one facing this. This func is stable enough.

Leask commented 1 year ago

Try removing your fix and creating a new token. If you can reproduce this issue, please let me know.

mccoysc commented 1 year ago

image image

after this,all error disapeared.

from this point, there are definitely cases where init is called repeatedly.

mccoysc commented 1 year ago

Try removing your fix and creating a new token. If you can reproduce this issue, please let me know.

the token is newly created for the deploy,no any one else know it.

Leask commented 1 year ago

I cloned your branch removed this fix, and can not reproduce this issue. 🤔️ Please just let me reproduce it.

mccoysc commented 1 year ago

you can deploy it without the fix to railway for test

mccoysc commented 1 year ago

I cloned your branch removed this fix, and can not reproduce this issue. 🤔️ Please just let me reproduce it.

i have modified the dependency to my fixed version in package.json

maybe you are still using my version