Messengers, especially Telegram, offer an exceptionally convenient platform for interacting with generative AI models. They are accessible on all devices and are designed for dialogues and the rapid exchange and forwarding of text and graphic information with minimal requirements for internet connection speed.
Sebastian is a Telegram bot written using the aiogram asynchronous framework. It provides access to the most advanced modern AI models (currently only GPT-4 and DALLE), designed for seamless interaction with them through the Telegram.
Thus, most of the tasks are divided into two categories:
The latter category essentially involves working on numerous, often unnoticed details that, nevertheless, constitute an important part of the user experience.
chxxxxbot/ # The main project's directory
├── secrets/ # Directory for build secrets.
│ ├── bot_token.txt # Telegram Bot Token (provided by @BotFather)
│ ├── db_password.txt # Database password (arbitrary)
│ ├── openai_token.txt # OpenAI API token (provided by OpenAI)
│ └── webhook_secret.txt # Webhook secret (arbitrary
├── src/ # Directory for bot source code
│ ├── main.py # Bot entrypoint
│ ├── core/ # Directory for core chatbot functionality
│ │ ├── chat_completion.py # Text processing
│ │ └── image_generation.py # Image processing
│ ├── database/ # Directory for database-related python code
│ │ └── queries.py # Wrapper functions over psycopg calls
│ ├── handlers/ # Directory for Telegram API updates handlers
│ │ ├── callbacks.py # Inline keyboards events
│ │ ├── hidden_cmds.py # Commands that aren't visible in Telegram interface
│ │ ├── other_upds.py # Payment updates
│ │ ├── privileged_cmds.py # Commands that are available only for bot owner
│ │ └── public_cmds.py # Commands that are shown in Telegram interface
│ ├── templates/ # Directory for documentation and keyboards templates
│ │ ├── bot_menu.py # Dict structure that store Telegram Bot Menu commands
│ │ ├── scripted_dialogues.py # Dict structure for all docs and buttons texts
│ │ ├── keyboards/ # Directory for keyboards templates
│ │ │ ├── inline_kbd.py # Templates and a factory for inline keyboards
│ │ │ └── reply_kbd.py # Templates for reply keyboards
│ │ └── tutorial/ # Directory for tutorial's media
│ │ ├── generation.mp4 # Video for image generation functionality
│ │ ├── latex.mp4 # Video for latex detection and compilation functionality
│ │ ├── prompt.mp4 # Video for chat completion functionality
│ │ ├── recognition.mp4 # Video for image recognition functionality
│ │ ├── tokens.mp4 # Video about describing what are tokens
│ │ └── videos.py # Dict structure for tutorial videos file_ids
│ └── utils/ # Directory for auxiliary functions and temprorary data
│ ├── formatting.py # Functions for text parsing and formatting
│ ├── globals.py # Storage for bot object, openai client and global constants
│ ├── validations.py # Functions for input validations
│ ├── analytics/ # Directory for administration tools and logging
│ │ ├── analytics.py # Analytics auxiliary function
│ │ └── logging.py # Logging wrapper
│ └── temp/ # Directory for data sent to users or obtained from them
│ ├── documents/ # Directory for all temporary files that are not images
│ └── images/ # Directory for images that are obtained from user
├── .dockerignore # Ignore files that should not be in Bot's docker container
├── .gitignore # Ignore secret and temporary files
├── .env # Storage for all environment variables
├── botpic.jpg # An image that is used as a bot picture in Telegram
├── compose.yaml # Docker compose file
├── Dockerfile # Bot container's Dockerfile
├── nginx.conf.template # NGINX reverse proxy servers configuration
├── pgdb_scheme.sql # File for PostgreSQL database initialization
├── pyproject.toml # Configuration file for bot's source code build system
├── LICENSE # Project's license
└── README.md # The file you are currently looking at
git clone https://github.com/trxxxxkov/chxxxxbot.git
chxxxxbot/.env
file, for example:### BOT ENVIRONMENT VARIABLES
OWNER_TG_ID=000000000
### WEBSERVER ENVIRONMENT VARIABLES
[email protected]
NGINX_HOST=example.com
chxxxxbot/secret/
folder:chxxxxbot/secrets/bot_token.txt
;chxxxxbot/secrets/openai_token.txt
;chxxxxbot/secrets/db_password.txt
;chxxxxbot/secrets/webhook_secret.txt
;docker compose up
The project needs help not only with improvements and additions to the codebase but also with ideas! The main goal of the project can only be achieved by working through numerous details that are hard to foresee in advance, but when encountered, make you think, "Oh! This is so natural and convenient!"