Sign inSign up

pengshp/pokitoki

By pengshp

•Updated over 2 years ago

a Telegram chat bot built using the ChatGPT

Image
0

510

pengshp/pokitoki repository overview

ChatGPT Telegram Bot

This is a Telegram chat bot built using the ChatGPT (GPT-3.5 or GPT-4) language model from OpenAI.

Notable features:

Both one-on-one and group chats.
Direct questions, mentions, follow-ups.
Access external links (articles, code, data).
Shortcuts (custom AI commands).
Custom chat-wide prompts.
Image generation.
On-the-fly configuration.

⁠Configuration

Use the /config command to change almost any setting on the fly, without restarting the bot.

  • Add or remove users and chats allowed to interact with the bot (telegram.usernames and telegram.chat_ids).
  • Adjust the AI model (openai.model), prompt (openai.prompt) and params (openai.params).
  • Enable or disable image generation (imagine.enabled).
  • Add or change AI shortcuts (shortcuts).
  • Change any other config property.

To view a specific config property, put its name after /config:

/config telegram.usernames
/config openai.prompt
/config imagine.enabled

To change a specific config property, put its name and value after /config:

/config telegram.usernames ["alice", "bob", "cindy"]
/config openai.prompt "You are an evil AI bot"
/config imagine.enabled none

When working with list properties like telegram.usernames, you can add or remove individual items instead of redefining the whole list:

/config telegram.usernames +cindy
/config telegram.usernames -bob

The /config command is only available to admins - users listed in the telegram.admins property.

⁠Message limits

Heated discussions with the bot in large groups can lead to high usage of the OpenAI API. To avoid spending your entire budget, set message limits for groups with the conversation.message_limit config property.

You can limit the number of messages from a user over a period of time. For example:

  • 10 messages per user per hour:
message_limit:
    count: 10
    period: hour
  • 1 message per user per minute:
message_limit:
    count: 1
    period: minute
  • 30 messages per user per day:
message_limit:
    count: 30
    period: day

⁠Setup

  1. Get your OpenAI API⁠ key
  2. Get your Telegram bot token from @BotFather⁠
  3. compose.yaml
---
version: "3"
services:
  pokitoki:
    image: pengshp/pokitoki:latest
    container_name: pokitoki
    restart: unless-stopped
    volumes:
      - ./config.yml:/code/config.yml
      - data:/code/data
volumes:
  data:
$ wget https://github.com/nalgeon/pokitoki/raw/main/config.example.yml
  1. Copy config.example.yml to config.yml and specify your tokens there. Add yourself to the telegram.usernames property, otherwise the bot will be available to everyone.
  2. Start the bot:
docker compose up -d

To stop the bot:

docker compose stop

Tag summary

Content type

Image

Digest

sha256:5399e3bb4…

Size

29.3 MB

Last updated

over 2 years ago

docker pull pengshp/pokitoki