Skip to content

bobberdolle1/holy-c-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🙏 HOLY C TELEGRAM BOT 🙏

"God said 640x480 is a covenant like circumcision." - Terry A. Davis

The world's most advanced Telegram bot written in pure HolyC with AI, RAG memory, and divine wisdom

License: HCPL Language: HolyC Powered by: Ollama In Memory: Terry A. Davis

In memory of Terry A. Davis (1969-2018), the greatest programmer who ever lived.


🌟 What is this divine creation?

A fully functional Telegram bot where the entire bot logic is written in pure HolyC - the holiest programming language ever created, as revealed to Terry A. Davis through divine inspiration.

Since TempleOS (God's Temple) has no networking stack by design, we use a C++ bridge adapter to handle earthly I/O while maintaining the spiritual purity of HolyC logic.

📱 Telegram → ⚡ C++ Bridge → ⛪ HolyC Logic → 🤖 Ollama AI → 🧠 RAG Memory → 📱 Response

✨ Divine Features

Core Features

  • 🙏 Pure HolyC bot logic - TempleOS-compatible syntax, blessed by Terry
  • C++ Bridge (NEW!) - Native performance, 50-100x faster than Python
  • 🤖 AI-Powered - Ollama integration with Terry's personality
  • 🧠 RAG Memory - Semantic search with vector embeddings
  • 💾 SQLite Persistence - User context and message history
  • 📊 Statistics Tracking - Command usage and bot metrics
  • 🎲 Divine Algorithms - Random oracle, text transformation
  • 🔌 Plugin System - 15 HolyC plugins with 65+ commands
  • 📚 Core Libraries - 6 HolyC modules (string, math, crypto, JSON, HTTP)
  • 🎮 Divine Growth Game - 24h cooldown, leaderboard, random oracle

Advanced Features

  • 📡 Group/Supergroup Support - Works in private chats and groups
  • ⌨️ Typing Indicator - Professional UX with "typing..." status
  • 🎯 Smart Group Behavior - Responds to @mentions and replies only
  • 🔐 Admin Commands - Protected statistics and management
  • 🌐 Context-Aware AI - Uses memory and RAG for intelligent responses
  • 🎨 Divine Text Processing - Transformation and oracle generation
  • 🔢 Number Theory - Prime, Fibonacci, GCD, perfect numbers
  • 🔐 Cryptography - Hash, cipher, Base64, key generation
  • 🎮 Games - Dice, coin, RPS, 8-ball, jokes, riddles, growth game
  • 🌌 Astronomy - Cosmos facts, planet database
  • 💡 Wisdom - Programming quotes, life proverbs
  • 🏆 Leaderboard - Growth game rankings with pagination

Technical Excellence

  • 🚀 Maximum Speed - Optimized with -O3 -march=native -flto
  • 💾 Tiny Binary - <2MB executable with all dependencies
  • 🌍 Cross-Platform - C++ on Windows, Python fallback for Unix
  • 📈 Scalable - Handles multiple users with SQLite backend
  • 📦 Modular Architecture - 21 HolyC files, clean separation
  • 🎯 65+ Commands - Comprehensive feature set in pure HolyC
  • 🎲 Divine Randomness - Terry's oracle for game mechanics

📋 Sacred Requirements

C++ Bridge (Recommended):

  • ⚡ MinGW-w64 (GCC/G++)
  • 📚 SQLite3 library
  • 🤖 Ollama
  • 🧠 nomic-embed-text model (for RAG)
  • 📱 Telegram Bot Token from @BotFather
  • 🙏 Respect for Terry A. Davis

Python Bridge (Alternative):

  • 🐍 Python 3.8+
  • 📦 python-telegram-bot, requests
  • 🤖 Ollama
  • 🧠 nomic-embed-text model
  • 📱 Telegram Bot Token
  • 🙏 Respect for Terry A. Davis

🚀 Installation (The Path to Enlightenment)

Option 1: C++ Bridge (⚡ MAXIMUM SPEED - RECOMMENDED)

Requirements:

  • MinGW-w64 (GCC for Windows)
  • SQLite3 library
  • Ollama
  • Telegram Bot Token

Setup:

# Install MinGW-w64
# Download from https://www.mingw-w64.org/

# Install Ollama
winget install Ollama.Ollama

# Start Ollama and pull models
ollama serve
ollama pull llama3.2
ollama pull nomic-embed-text

# Configure bot
cp config.txt.example config.txt
# Edit config.txt with:
# Line 1: Your bot token
# Line 2: Ollama model (llama3.2)
# Line 3: Your admin chat ID (optional)

# Compile C++ bridge (with maximum optimizations)
compile_fast.bat

# Run
run_fast.bat

Performance:

  • 🚀 50-100x faster than Python
  • ⚡ Native compiled binary
  • 💾 <2MB executable
  • 🔥 Instant startup
  • 📉 Minimal memory usage

Option 2: Python Bridge (🐌 Slower, but easier)

Setup:

pip install -r requirements.txt

# Start Ollama and pull models
ollama serve
ollama pull llama3.2
ollama pull nomic-embed-text

# Configure bot
cp config.txt.example config.txt
# Edit config.txt

# Run
python holyc_bridge.py

🎮 Usage (Communicating with the Divine)

Starting the Bot

C++ Bridge (Fast):

run_fast.bat

Python Bridge (Slow):

run_holyc.bat

Then:

  1. 📱 Open Telegram and find your bot
  2. 💬 Send /start to receive divine greeting
  3. 🤖 Send any message - receive AI-powered wisdom with RAG context
  4. ❓ Use /help to see all sacred commands

Available Commands

Core Commands

Command Description
/start Initialize divine connection
/help Display sacred commands
/info Show bot information
/version Version information
/commands Full command list (65+)
/sysinfo System information
/plugins List all plugins
/libraries List all libraries
/stats Bot statistics (admin only)
Any text AI response with RAG context

Games

Command Description
/grow Divine growth game (24h cooldown)
/growtop Growth leaderboard with pagination
/dice Roll divine dice
/coin Flip divine coin
/rps <choice> Rock paper scissors
/8ball <question> Magic 8-ball oracle

Mathematics & Numbers

Command Description
/calc <expr> Simple calculator (5+3, 10*2)
/math Divine mathematics
/prime <n> Check if prime
/fib <n> Fibonacci number
/factor <n> Factorization
/perfect <n> Perfect number check
/collatz <n> Collatz conjecture
/digitsum <n> Digit analysis
/matrix Random matrix with determinant
/stats <numbers> Statistics (mean, min, max)
/sequence <n> Number sequences

Cryptography

Command Description
/hash <text> Hash text (DJB2, checksum, hex)
/encode <text> Encode text (ROT13, Caesar, Base64)
/decode <text> Decode text
/genkey <len> Generate random key
/password <pass> Check password strength

Text Processing

Command Description
/echo <text> Echo your words back
/transform <text> Divine text transformation
/reverse <text> Reverse text
/count <text> Character count analysis
/palindrome <text> Check if palindrome
/wordcount <text> Count words
/upper <text> Convert to UPPERCASE
/lower <text> Convert to lowercase

TempleOS Features

Command Description
/ascii Generate TempleOS ASCII art
/colors TempleOS 16-color palette
/terry Facts about Terry A. Davis
/templeos About TempleOS
/holyc About HolyC language
/640x480 About the covenant
/legacy Terry's legacy

Astronomy & Science

Command Description
/cosmos Cosmic facts
/planet <name> Planet information

Wisdom & Quotes

Command Description
/wisdom Programming wisdom
/proverb Life proverbs
/quote Terry's quotes
/bible Random Bible verse
/divine Divine random number
/oracle <question> Ask the divine oracle

Fun & Entertainment

Command Description
/joke Programming joke
/riddle Brain riddle
/fact Tech fact
/compliment Get a compliment

Time & Utilities

Command Description
/time Current time

Memory System

Command Description
/memory save <text> Save to persistent memory
/memory load Load your memory
/memory clear Clear memory

Group/Supergroup Usage

The bot works in groups and supergroups:

  • Mention the bot: @yourbot question
  • Reply to bot's message
  • Use commands normally: /help

🏗️ Project Structure (The Temple Architecture)

holy-c-telegram-bot/
├── 📜 telegram_bot.HC       # Pure HolyC bot logic (THE HOLY GRAIL)
├── ⚡ holyc_bridge.cpp       # C++ runtime bridge (MAXIMUM SPEED)
├── 🐍 holyc_bridge.py       # Python bridge (fallback, slower)
├── 🔨 compile_fast.bat      # C++ compilation with optimizations
├── 🚀 run_fast.bat          # C++ launcher
├── 🐌 run_holyc.bat         # Python launcher
├── 📦 requirements.txt      # Python dependencies (optional)
├── ⚙️  config.txt.example   # Configuration template
├── 🧠 personality.txt       # Terry's personality for AI
├── 💾 memory.db             # SQLite database (auto-created)
├── 🔌 plugins/              # HolyC Plugin System (15 plugins)
│   ├── oracle.HC           # Divine oracle with random answers
│   ├── weather.HC          # Divine weather predictions
│   ├── astronomy.HC        # Cosmos facts and planet info
│   ├── wisdom.HC           # Programming wisdom and proverbs
│   ├── games.HC            # Dice, coin, rock-paper-scissors
│   ├── calculator.HC       # Simple math calculations
│   ├── time.HC             # Time display and countdown
│   ├── crypto.HC           # Hash, encode, decode, keys
│   ├── text.HC             # Text processing utilities
│   ├── number.HC           # Number theory functions
│   ├── fun.HC              # Jokes, riddles, facts, 8-ball
│   ├── advanced_math.HC    # Matrix, statistics, sequences
│   ├── system.HC           # System info and version
│   ├── templeos.HC         # Terry tribute and TempleOS info
│   └── grow_game.HC        # Divine growth game with leaderboard
├── 📚 lib/                  # HolyC Core Libraries (5 modules)
│   ├── string_utils.HC     # String manipulation library
│   ├── math_divine.HC      # Mathematical functions
│   ├── crypto_holy.HC      # Cryptography primitives
│   ├── json_parser.HC      # JSON parsing utilities
│   └── http_client.HC      # HTTP interface definitions
├── 🙈 .gitignore            # Git exclusions
├── 📖 README.md             # This sacred text
└── ⚖️  LICENSE              # The Holy C Public License (HCPL)

⚡ Performance Comparison

Runtime Startup Time Memory Usage Response Time RAG Search Speed
C++ Bridge <50ms ~10MB <10ms <5ms ⚡⚡⚡⚡⚡
Python Bridge ~500ms ~80MB ~50ms ~20ms 🐌

C++ Bridge is 50-100x faster than Python!

🏛️ Architecture (Divine Design)

┌─────────────────────────────────────────────────────────────┐
│                    👤 USER (Mortal Realm)                    │
└───────────────────────────┬─────────────────────────────────┘
                            │
                    📱 Telegram Message
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│              🌐 Telegram Bot API (Cloud)                     │
└───────────────────────────┬─────────────────────────────────┘
                            │
                    HTTPS Request
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│         ⚡ C++ Bridge (holyc_bridge.cpp) - FAST!            │
│         • Native compiled performance                        │
│         • WinINet for HTTP/HTTPS                            │
│         • SQLite for persistence                            │
│         • RAG semantic search                               │
│         • Typing indicator support                          │
│         • Group/supergroup logic                            │
│         • 50-100x faster than Python                        │
└───────────────────────────┬─────────────────────────────────┘
                            │
                    Function Calls
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│         ⛪ HolyC Bot Logic (telegram_bot.HC)                 │
│         • Pure HolyC syntax                                  │
│         • TempleOS-compatible                                │
│         • Divine command processing                          │
│         • Text transformation algorithms                     │
│         • Oracle generation                                  │
│         • Memory management                                  │
└───────────────────────────┬─────────────────────────────────┘
                            │
                    AI Request + RAG Context
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│         🤖 Ollama AI (localhost:11434)                       │
│         • Local LLM inference (llama3.2)                     │
│         • Terry's personality system prompt                  │
│         • Vector embeddings (nomic-embed-text)              │
│         • Context-aware responses                            │
└───────────────────────────┬─────────────────────────────────┘
                            │
                            ▼
┌─────────────────────────────────────────────────────────────┐
│         💾 SQLite Database (memory.db)                       │
│         • User memory persistence                            │
│         • Message history with embeddings                    │
│         • RAG semantic search                                │
│         • Statistics tracking                                │
└───────────────────────────┬─────────────────────────────────┘
                            │
                    Response Flow ↑
                            │
                    Back to User 📱

🧠 RAG Memory System

The bot uses Retrieval-Augmented Generation for intelligent context:

  1. Message Storage: All messages saved with vector embeddings
  2. Semantic Search: Finds relevant past messages using cosine similarity
  3. Context Injection: Top-3 relevant messages added to AI prompt
  4. Persistent Memory: User-specific context stored in SQLite

Benefits:

  • Remembers conversation history semantically
  • Provides relevant context automatically
  • Works across sessions
  • Scales to thousands of messages

🎨 Divine Algorithms

Text Transformation

  • UPPERCASE (God speaks in capitals)
  • lowercase (humble before God)
  • Reverse (God's perspective)

Oracle Generation

  • Random divine words
  • Numerical oracle signs
  • Terry's wisdom integration

Plugin System

  • Load custom commands from .HC files
  • Dynamic registration
  • Extensible architecture

🙏 In Memory of Terry A. Davis

This project is dedicated to Terry A. Davis (1969-2018), the creator of TempleOS and the HolyC programming language. Terry was a brilliant programmer who, despite struggling with mental illness, created an entire operating system from scratch as a "temple" for communication with God.

Key Facts about Terry:

  • Created TempleOS entirely alone over 10+ years
  • Wrote HolyC, a variant of C designed for divine simplicity
  • Built a complete OS with compiler, kernel, and graphics in 640x480 16-color VGA
  • Believed he was on a mission from God to create the Third Temple
  • His work demonstrates extraordinary technical skill and dedication

"God said 640x480 is a covenant like circumcision." - Terry A. Davis

If you or someone you know is struggling with mental health issues, please seek help:

🤝 Contributing (Join the Divine Mission)

Contributions are welcome! Please:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b divine-feature)
  3. 💾 Commit your changes (git commit -m 'Add divine feature')
  4. 📤 Push to the branch (git push origin divine-feature)
  5. 🎯 Open a Pull Request

Contribution Guidelines:

  • Maintain HolyC syntax purity in .HC files
  • Follow Terry's coding style (spaces, not tabs)
  • Keep functions under 100 lines
  • Add comments for clarity
  • Test with both C++ and Python bridges
  • Respect the memory of Terry A. Davis

📜 License

This project is licensed under the Holy C Public License (HCPL) - see the LICENSE file for divine details.

🌟 Acknowledgments

  • Terry A. Davis - Creator of TempleOS and HolyC, the greatest programmer who ever lived
  • TempleOS Community - Keeping Terry's legacy alive
  • Ollama Team - For making local AI accessible
  • Telegram - For their excellent Bot API
  • You - For appreciating divine code

📚 Resources


📊 Project Stats

  • HolyC Code: 2809 lines (65%+ of codebase)
  • Plugins: 15 modules
  • Libraries: 6 modules
  • Commands: 65+
  • Functions: 130+
  • Games: Divine growth game with leaderboard

🔧 Troubleshooting

"Ollama not responding"

  • Make sure Ollama is running: ollama serve
  • Check if models are downloaded: ollama list
  • Pull models if needed: ollama pull llama3.2 && ollama pull nomic-embed-text

"Module not found" (Python)

  • Install dependencies: pip install -r requirements.txt

"G++ not found" (C++)

"SQLite error"

  • Ensure SQLite3 library is installed
  • Check write permissions in bot directory

"Bot not responding in Telegram"

  • Check bot token in config.txt
  • Verify internet connection
  • Check console for error messages

"RAG not working"

  • Install embedding model: ollama pull nomic-embed-text
  • Check Ollama is running
  • Verify memory.db has write permissions

"Bot ignores messages in groups"

  • Mention the bot: @yourbot message
  • Reply to bot's message
  • Use commands: /help

⛪ May Terry's Temple Stand Eternal ⛪

"I've learned a lot. I've become like a scientist, and God has been my assistant."
— Terry A. Davis

Made with 🙏 and HolyC

Features: AI • RAG Memory • Divine Wisdom • Groups • Typing Indicator • Plugins • Admin • Stats