Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
GentelmeN-CorE (GeNCorE) is a multifunctional Telegram bot integrated with AI capabilities (Groq, Hugging Face), cryptocurrency market data (KuCoin), and web search (Brave). This guide outlines the system architecture, configuration requirements, and deployment steps necessary to initialize the GeNCorE environment.
Sources: core/commands.py:100-117, core/bot.py:15-30
System Prerequisites
To run the GeNCorE bot, the following dependencies must be installed via pip:
| Dependency | Purpose |
|---|---|
pyTelegramBotAPI | Telegram Bot API wrapper |
requests | HTTP requests for external APIs |
groq | AI Chat and Audio Transcription |
ccxt | Cryptocurrency market data (KuCoin) |
psycopg2-binary | PostgreSQL database adapter |
Sources: requirements.txt:1-6
Environment Configuration
The application requires several environment variables to authenticate with third-party services and the database.
Required Variables
TELEGRAM_TOKEN: The API token from BotFather.GROQ_KEY: API key for Groq AI services.DATABASE_URL: PostgreSQL connection string.
Optional Integrations
BRAVE_API_KEY: Enables the/szukajweb search command.HF_TOKEN: Enables image generation via Hugging Face (/rysuj).KUCOIN_API_KEY,KUCOIN_SECRET,KUCOIN_PASSWORD: Required for private wallet functions like/balance.ADMIN_ID: Telegram user ID allowed to manage price alerts.OWNER_USER_ID: Telegram user ID authorized to check KuCoin balances.
Sources: core/bot.py:11-30, core/commands.py:11-12, core/integrations.py:6-7
Architecture Overview
GeNCorE uses a modular architecture where the entry point (bot.py) triggers the core logic located in the core/ directory.
The diagram shows the initialization flow from the root entry point to the background monitoring threads and external integrations.
Sources: bot.py:4-7, core/bot.py:32-75
Initialization Logic
The bot initializes in several stages:
- Environment Validation: The system checks for
TELEGRAM_TOKENandGROQ_KEYand terminates if they are missing. - Database Setup:
init_db()creates theusersandalertstables if they do not exist. - Handler Registration: Commands are mapped to functions defined in
core/commands.py. - Background Threads: A
price_monitorthread starts to poll market prices every 60 seconds for active user alerts.
Database Schema
The database maintains user preferences (language, AI model) and price notification settings.
Sources: core/database.py:11-30, core/bot.py:32-75
Deployment
The project is configured for deployment on Railway using the RAILPACK builder.
Deployment Configuration
The railway.json file defines the deployment parameters:
- Start Command:
python bot.py - Restart Policy:
ON_FAILURE(up to 10 retries) - Replicas: 1
Sources: railway.json:1-15
Local Execution
To start the bot locally:
- Install dependencies:
pip install -r requirements.txt - Set environment variables.
- Run the entry script:
# bot.py entry point logic
import runpy
from pathlib import Path
base_dir = Path(__file__).resolve().parent
core_bot_path = base_dir / "core" / "bot.py"
runpy.run_path(str(core_bot_path))
Sources: bot.py:1-7, requirements.txt:1-6
Core Command Set
Once started, the bot responds to several primary commands:
| Command | Action | File Reference |
|---|---|---|
/start | Initializes user session and database entry | core/commands.py |
/llama, /fast, /qwen | Switches the AI backend model | core/commands.py |
/cena [sym] | Fetches current price from KuCoin | core/commands.py |
/rysuj [prompt] | Generates an image via Hugging Face | core/integrations.py |
/szukaj [query] | Performs a web search via Brave | core/integrations.py |
Sources: core/commands.py:100-117, core/integrations.py:9-45
Summary
Setting up GentelmeN-CorE requires configuring a PostgreSQL database and obtaining API keys for Telegram, Groq, and optionally KuCoin, Brave, and Hugging Face. The system leverages multi-threading to handle real-time cryptocurrency price monitoring while providing an extensible command-based interface for AI interactions.