A Telegram bot for searching information from open sources via DuckDuckGo and Wikipedia.
- DuckDuckGo Search: Web search without API keys or rate limits
- Wikipedia Integration: Direct Wikipedia search with
!wcommand - Smart Snippets: Prioritizes Wikipedia results and ensures complete sentences
- Multi-Environment: Works in private chats and group conversations
- Statistics Tracking: SQLite-based user activity and query tracking
- Admin Panel: Administrative commands for bot statistics
- Open Source: MIT licensed, fully free and open
- Python 3.10 or higher
- Telegram Bot Token from @BotFather
git clone https://github.com/gifsearch/gif.git
cd gifpython -m venv venv
source venv/bin/activate # Linux/macOS
# or
venv\Scripts\activate # Windowspip install -r requirements.txtcp .env.example .envEdit .env file and add your credentials:
BOT_TOKEN=your_telegram_bot_token_here
ADMINS_ID=123456789,987654321To obtain your Telegram user ID, message @userinfobot.
python main.py/start- Display welcome message/help- Show command reference/about- Information about the bot/g <query>- Search in group chats!w <query>- Wikipedia-only search/stats- View statistics (administrators only)
Send any text query directly:
Python programming language
Use the /g command prefix:
/g Linux operating system
Use the !w command for Wikipedia-specific queries:
!w Artificial Intelligence
The /stats command displays:
- Total registered users
- Total search queries
- Active users today
- Queries performed today
All configuration is managed through environment variables in the .env file.
BOT_TOKEN- Telegram Bot API token from BotFather
ADMINS_ID- Comma-separated list of administrator Telegram IDs
Configuration defaults are defined in bot/config.py:
SEARCH_RESULTS_LIMIT- Maximum search results (default: 5)REQUEST_TIMEOUT- HTTP request timeout in seconds (default: 15)USER_AGENT- User agent string for web requests
If migrating from a previous JSON-based statistics system to SQLite:
python scripts/json_to_sqlite.pyOptional arguments:
python scripts/json_to_sqlite.py --json stats.json --db stats.db --backupThe migration script automatically creates a backup of the JSON file before conversion.
docker build -t gif-bot .docker run -d --env-file .env --name gif-bot gif-botdocker-compose up -dView logs:
docker-compose logs -fgif/
├── bot/
│ ├── handlers/
│ │ ├── commands.py # Command handlers (/start, /stats, etc.)
│ │ └── messages.py # Message handlers (search, Wikipedia)
│ ├── services/
│ │ ├── search.py # DuckDuckGo and Wikipedia search
│ │ ├── database.py # SQLite database operations
│ │ └── stats.py # Statistics tracking service
│ └── config.py # Application configuration
├── scripts/
│ └── json_to_sqlite.py # Database migration utility
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── .env.example # Environment template
└── README.md # This file
- Follow PEP 8 guidelines
- Use type hints for function signatures
- Write docstrings for public functions
- Comments in English or Russian
Before submitting changes, verify:
- Bot starts without errors
- All commands function correctly
- No regression bugs introduced
Contributions are welcome. Please read CONTRIBUTING.md for guidelines on:
- Reporting bugs
- Suggesting enhancements
- Submitting pull requests
See ROADMAP.md for planned features and future development.
This project is licensed under the MIT License - see the LICENSE file for details.
- python-telegram-bot - Telegram Bot API wrapper
- DuckDuckGo - Privacy-focused search engine
- Wikipedia - Free encyclopedia
- BeautifulSoup - HTML parsing library
- Report issues: GitHub Issues
- Discussions: GitHub Discussions
- Telegram Community: t.me/gif56789f
This bot is an independent project and is not affiliated with DuckDuckGo, Wikipedia, or Telegram.
Made with dedication for the open source community.