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

How to run? #2

Closed JokerQyou closed 1 year ago

JokerQyou commented 1 year ago

When I run halbot locally:

cat ~/.halbot.json

{
  "telegramToken": "123456:BOT_TOKEN",
  "chatGptKey": "sk-KEY",
  "chatType": ["mention", "private"]
}

npx halbot
[HALBOT] AssertionError [ERR_ASSERTION]: Telegram Bot API Token is required.

DEBUG=1 npx halbot
file:///Users/joker/.npm/_npx/c35c4739108a4593/node_modules/utilitas/lib/utilitas.mjs:17
const newError = (msg, status, opt) => extError(new Error(msg), status, opt);
                                                ^

Error: AssertionError [ERR_ASSERTION]: Telegram Bot API Token is required.
    at newError (file:///Users/joker/.npm/_npx/c35c4739108a4593/node_modules/utilitas/lib/utilitas.mjs:17:49)
    at Module.throwError (file:///Users/joker/.npm/_npx/c35c4739108a4593/node_modules/utilitas/lib/utilitas.mjs:18:50)
    at file:///Users/joker/.npm/_npx/c35c4739108a4593/node_modules/halbot/bin/halbot.mjs:34:34 {
  status: undefined
}

When running inside docker container:

docker run --rm -ti --entrypoint=bash -v $(pwd)/halbot.json:/root/.halbot.json:ro node:lts-slim
npm install -g halbot
whoami
root

cat ~/.halbot.json
{
  "telegramToken": "123456:BOT_TOKEN",
  "chatGptKey": "sk-KEY",
  "chatType": ["mention", "private"]
}

halbot
[BOT 2023-03-16T10:19:13.535Z] SKILLS: /usr/local/lib/node_modules/halbot/skills
[BOT 2023-03-16T10:19:13.592Z] Training: subconscious
[BOT 2023-03-16T10:19:13.593Z] Training: laws
[BOT 2023-03-16T10:19:13.594Z] Training: authenticate
[BOT 2023-03-16T10:19:13.595Z] Training: stt
[BOT 2023-03-16T10:19:13.596Z] Training: cmd
[BOT 2023-03-16T10:19:13.596Z] Training: translate
[BOT 2023-03-16T10:19:13.597Z] Training: ai
[BOT 2023-03-16T10:19:13.598Z] Training: tts
[BOT 2023-03-16T10:19:13.598Z] Training: closure

But the bot does not respond to anything in private chat.

Leask commented 1 year ago

I tested my code on macOS and Linux, including the Docker environment, and everything worked. However, if you are running the code on macOS, make sure it has the necessary permissions to read the config file.

When launching the program in Docker, try using the '/echo' command first to see if you receive a reply.

If you're having trouble getting a response from the bot, check the logs to see if it's receiving the messages you send. The bot logs every new message it receives and attempts to respond to each one.

Please keep me updated on your progress. Thank you!

ushuz commented 1 year ago

utilitas seems to have trouble locating the .halbot.json in my setup.

I just installed halbot to the current directory inside a contaienr with npm i halbot, but the config file path somehow got resolved to /root/..json.

image
Leask commented 1 year ago

You are right. I will check about this.

Leask commented 1 year ago

Fixed in this commit: https://github.com/Leask/halbot/commit/e7297fe1f4169224ffad31e86c798851e433b498. Thank you all for caring about this!

ushuz commented 1 year ago

@Leask Thanks for the speedy fix and sharing the project. It's really fun to interact with halbot on Telegram.

Leask commented 1 year ago

🍻

elliclee commented 1 year ago

@JokerQyou Hi, I got the same problem, how did you fix this problem at last?

Leask commented 1 year ago

It’s already fixed: https://github.com/Leask/halbot/commit/e7297fe1f4169224ffad31e86c798851e433b498

JokerQyou commented 1 year ago

I did not. I was stuck with this issue for several hours, and after spending some more time after creating the issue I have to move to other ChatGPT bot implementations.

Leask commented 1 year ago

@JokerQyou @elliclee Still not working? Please update to the latest version. It's been fixed. If there is still an issue, please come back and share some more info to help me to fix it.

elliclee commented 1 year ago

@Leask I have solved the problem. Just remove the comments in the JSON file. Thx