Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [VK bot](https://github.com/linksplatform/Bot/tree/main/python)
This bot is created for programmers by programmers. Features are: personal Karma tracking, programmer's personal information storage, Wikipedia access, GitHub Copilot access.

## [Telegram bot](https://github.com/linksplatform/Bot/tree/main/telegram)
Modern LinksBot implementation for Telegram with cleaner code and enhanced features. Includes karma system, programming language profiles, GitHub integration, and Wikipedia search - all without SQL dependencies.

## [GitHub bot](https://github.com/linksplatform/Bot/tree/main/csharp/Platform.Bot)
Bot that can create "hello world" and have some other useful features.
## [Discord bot](https://github.com/linksplatform/Bot/tree/AddDiscrodBot/csharp/DiscordBot)
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ wikipedia
requests
datetime
regex

# Telegram bot dependencies
aiogram>=3.0.0
aiohttp>=3.8.0
31 changes: 31 additions & 0 deletions telegram/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Data files (contains user data)
data/

# Python cache
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
*.so

# Bot token (keep private)
config.py

# Logs
*.log

# IDE
.vscode/
.idea/
*.swp
*.swo

# Virtual environment
venv/
env/
.env

# OS
.DS_Store
Thumbs.db
153 changes: 153 additions & 0 deletions telegram/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# LinksBot for Telegram

A modern Telegram bot implementation for programmers with karma tracking, programming language profiles, GitHub integration, and Wikipedia search.

## Features

- **User Profiles**: Track programming languages and GitHub profiles
- **Karma System**: Community-driven reputation system with voting
- **Programming Languages**: Support for 130+ programming languages
- **GitHub Integration**: Link your GitHub profile to your bot account
- **Wikipedia Search**: Quick access to Wikipedia information
- **Group Chat Support**: Full functionality in group chats and channels

## Commands

### General Commands
- `/start` - Start using the bot
- `/help` - Show help message with all commands
- `/info` - Show your profile information (or reply to see someone else's)
- `/update` - Update your profile information

### Programming Languages
- `/add_lang <language>` - Add a programming language to your profile
- `/remove_lang <language>` - Remove a programming language from your profile

### GitHub Profile
- `/add_github <username>` - Add your GitHub profile
- `/remove_github` - Remove your GitHub profile

### Karma System
- `/karma` - Show your karma (or reply to a message to see someone's karma)
- `/top [number]` - Show top users by karma (default: 10)
- `/bottom [number]` - Show bottom users by karma (default: 10)
- `+` (reply to message) - Vote to increase someone's karma
- `-` (reply to message) - Vote to decrease someone's karma

### Information
- `/people` - Show all chat members with their profiles
- `/what_is <query>` - Search Wikipedia for information

## Karma System

The karma system is community-driven with the following rules:

- **Positive karma**: Requires 2 votes to increase karma by 1
- **Negative karma**: Requires 3 votes to decrease karma by 1
- **Voting cooldown**: Based on your karma level (higher karma = shorter cooldown)
- **Protection**: Users with negative karma cannot be voted down further

### Voting Cooldowns
| Karma Range | Cooldown |
|-------------|----------|
| ≀ -20 | 8 hours |
| -19 to -2 | 4 hours |
| -1 to 2 | 2 hours |
| 2 to 20 | 1 hour |
| β‰₯ 20 | 30 min |

## Programming Languages

The bot supports 130+ programming languages including:
- **Popular**: Python, JavaScript, TypeScript, Java, C++, C#, Go, Rust
- **Functional**: Haskell, F#, Scala, Clojure, Erlang, Elixir
- **System**: C, C++, Rust, Go, Assembly
- **Web**: JavaScript, TypeScript, PHP, Ruby, Python
- **Mobile**: Swift, Kotlin, Dart, Objective-C
- **And many more!**

## Installation

### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)

### Setup

1. **Clone the repository**:
```bash
git clone https://github.com/linksplatform/Bot.git
cd Bot/telegram
```

2. **Install dependencies**:
```bash
pip install -r requirements.txt
```

3. **Configuration**:
- Create a Telegram bot by messaging [@BotFather](https://t.me/botfather)
- Get your bot token
- Edit `config.py` and set your `BOT_TOKEN`

4. **Run the bot**:
```bash
python main.py
```

## Configuration

Edit `telegram/config.py` to customize:

- `BOT_TOKEN` - Your Telegram bot token (required)
- `POSITIVE_VOTES_PER_KARMA` - Votes needed for positive karma (default: 2)
- `NEGATIVE_VOTES_PER_KARMA` - Votes needed for negative karma (default: 3)
- `KARMA_LIMIT_HOURS` - Cooldown periods by karma level
- `DEFAULT_PROGRAMMING_LANGUAGES` - Supported programming languages

## Data Storage

The bot uses simple JSON file storage (no database required):
- `data/users.json` - User profiles and karma
- `data/karma_votes.json` - Voting history

This approach follows the project's preference for avoiding SQL databases while maintaining clean, readable data.

## Development

The bot follows a modular architecture:

- `main.py` - Bot initialization and command routing
- `config.py` - Configuration settings
- `modules/storage.py` - Data storage management (JSON-based)
- `modules/commands.py` - Command handlers and business logic

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test the bot functionality
5. Submit a pull request

## License

This project is licensed under the MIT License - see the [LICENSE](../LICENSE) file for details.

## Support

- **Repository**: https://github.com/linksplatform/Bot
- **Issues**: https://github.com/linksplatform/Bot/issues
- **Discussions**: https://github.com/linksplatform/Bot/discussions

## Architecture

The Telegram bot is designed with clean architecture principles:

- **No SQL Dependencies**: Uses simple JSON storage as preferred by the project
- **Modular Design**: Separated concerns for storage, commands, and bot logic
- **Async/Await**: Modern Python async programming with aiogram 3.x
- **Type Hints**: Full type annotations for better code quality
- **Error Handling**: Graceful error handling and user feedback

This implementation provides all the core features of the original VK bot while being optimized for the Telegram platform.
2 changes: 2 additions & 0 deletions telegram/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
"""LinksBot for Telegram implementation."""
62 changes: 62 additions & 0 deletions telegram/config.template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
"""Configuration template for Telegram bot.

Copy this file to config.py and fill in your bot token.
"""

# Bot settings - REQUIRED
# Get your bot token from @BotFather on Telegram
BOT_TOKEN = "YOUR_BOT_TOKEN_HERE"

# Karma system configuration
POSITIVE_VOTES_PER_KARMA = 2 # Votes needed to increase karma by 1
NEGATIVE_VOTES_PER_KARMA = 3 # Votes needed to decrease karma by 1

# Karma cooldown periods (in hours) based on user karma
KARMA_LIMIT_HOURS = [
{"min_karma": None, "max_karma": -19, "limit": 8}, # Very low karma: 8 hours
{"min_karma": -19, "max_karma": -1, "limit": 4}, # Low karma: 4 hours
{"min_karma": -1, "max_karma": 2, "limit": 2}, # Neutral karma: 2 hours
{"min_karma": 2, "max_karma": 20, "limit": 1}, # Good karma: 1 hour
{"min_karma": 20, "max_karma": None, "limit": 0.5}, # High karma: 30 minutes
]

# Available programming languages (you can modify this list)
DEFAULT_PROGRAMMING_LANGUAGES = [
"Assembler", "JavaScript", "TypeScript", "Java", "Python", "PHP", "Ruby",
"C++", "C", "Shell", "C#", "Objective-C", "R", "VimL", "Go", "Perl",
"CoffeeScript", "TeX", "Swift", "Kotlin", "F#", "Scala", "Scheme",
"Emacs Lisp", "Lisp", "Haskell", "Lua", "Clojure", "TLA+", "PlusCal",
"Matlab", "Groovy", "Puppet", "Rust", "PowerShell", "Pascal", "Delphi",
"SQL", "Nim", "1Π‘", "ΠšΡƒΠœΠΈΡ€", "Scratch", "Prolog", "GLSL", "HLSL",
"Whitespace", "Basic", "Visual Basic", "Parser", "Erlang", "Wolfram",
"Brainfuck", "Pawn", "Cobol", "Fortran", "Arduino", "Makefile", "CMake",
"D", "Forth", "Dart", "Ada", "Julia", "Malbolge", "Π›ΠΎΠ³ΠΎ", "Verilog",
"VHDL", "Altera", "Processing", "MetaQuotes", "Algol", "Piet",
"Shakespeare", "G-code", "Whirl", "Chef", "BIT", "Ook", "MoonScript",
"PureScript", "Idris", "Elm", "Minecraft", "Crystal", "C--", "Go!",
"Tcl", "Solidity", "AssemblyScript", "Vimscript", "Pony", "LOLCODE",
"Elixir", "X#", "NVPTX", "Nemerle"
]

# GitHub Copilot integration settings (future feature)
GITHUB_COPILOT_LANGUAGES = {
'Python': ['.py', 'python'],
'JavaScript': ['.js', 'javascript'],
'TypeScript': ['.ts', 'typescript'],
'C#': ['.cs', 'csharp'],
'Go': ['.go', 'go'],
'Java': ['.java', 'java'],
'Kotlin': ['.kt', 'kotlin'],
'Ruby': ['.rb', 'ruby'],
'PHP': ['.php', 'php'],
'C': ['.c', 'c'],
'C++': ['.cpp', 'cpp'],
}

GITHUB_COPILOT_TIMEOUT = 120 # seconds

# Data storage configuration (JSON-based, no SQL required)
DATA_DIR = "data"
USERS_FILE = f"{DATA_DIR}/users.json"
KARMA_VOTES_FILE = f"{DATA_DIR}/karma_votes.json"
Loading
Loading