|
1 | 1 | # VLDC nyan bot ^_^ |
2 | 2 |
|
3 | | -The official [VLDC](https://vldc.org) telegram group bot. |
| 3 | +The official [VLDC](https://vldc.org) telegram group bot. Written in Go. |
4 | 4 |
|
5 | 5 |  |
6 | 6 |
|
7 | | -[](https://github.com/vldc-hq/vldc-bot/actions?query=workflow%3A%22Nyan+Bot%22) |
8 | | -[](https://codeclimate.com/github/vldc-hq/vldc-bot/maintainability) |
9 | | - |
| 7 | +[](https://github.com/vldc-hq/vldc-bot/actions/workflows/ci.yml) |
10 | 8 |
|
11 | 9 | ### Skills |
12 | | -* 😼 core – core |
13 | | -* 😼 version – show this message |
14 | | -* 😻 still – do u remember it? |
15 | | -* 😾 uwu – don't uwu! |
16 | | -* 🤭 mute – mute user for N minutes |
17 | | -* 🔫 roll – life is so cruel... isn't it? |
18 | | -* ⚔️ banme – commit sudoku |
19 | | -* 🔪 ban – ban! ban! ban! |
20 | | -* 🎄 tree – advent of code time! |
21 | | -* ⛔🤬 coc – VLDC/GDG VL Code of Conduct |
22 | | -* 🛠 more than 70k? – try to hire! |
23 | | -* 💻 got sk1lzz? – put them to use! |
24 | | -* 👁 smell like PRISM? nononono! |
25 | | -* 💰 kozula Don't argue with kozula rate! |
26 | | -* 🤫 buktopuha Let's play a game 🤡 |
| 10 | +* core - core bot functionality |
| 11 | +* version - show bot version |
| 12 | +* still - do u remember it? |
| 13 | +* uwu - don't uwu! |
| 14 | +* mute - mute user for N minutes |
| 15 | +* roll - life is so cruel... isn't it? |
| 16 | +* banme - commit sudoku |
| 17 | +* ban - ban! ban! ban! |
| 18 | +* tree - Advent of Code time! |
| 19 | +* coc - VLDC/GDG VL Code of Conduct |
| 20 | +* 70k - try to hire! |
| 21 | +* pr - got sk1lzz? put them to use! |
| 22 | +* prism - smell like PRISM? nononono! |
| 23 | +* kozula - Don't argue with kozula rate! |
| 24 | +* buktopuha - Let's play a game |
| 25 | +* length - measure your instrument |
| 26 | +* nya - Simon says wat? |
| 27 | +* trusted - in god we trust |
| 28 | +* aoc - Advent of Code tracker |
27 | 29 |
|
28 | 30 | ### Modes |
29 | | -* 😼 smile mode – allow only stickers in the chat |
30 | | -* 🛠 since mode – under construction |
31 | | -* 🧼 towel mode – anti bot |
32 | | -* 🙃 fools mode – what? not again! |
33 | | -* 🤫 nastya mode – stop. just stop |
34 | | -* 🙃 chat mode - chatty Nyan |
35 | | - |
36 | | -## Usage via VS Code (Easy Way) |
37 | | -Clone repository locally and open it up via VS Code and click Open in Container. Create `.env` file as described below. |
38 | | -Mongo will be available at `MONGO_HOST=localhost`. And you're done, you can run bot by clicking `F5` or `Run -> Launch Bot`. |
| 31 | +* smile mode - allow only stickers in the chat |
| 32 | +* since mode - under construction |
| 33 | +* towel mode - anti bot |
| 34 | +* fools mode - what? not again! |
| 35 | +* nastya mode - stop. just stop |
| 36 | +* chat mode - chatty Nyan |
39 | 37 |
|
40 | | -Other option is to use [Codespaces](https://github.com/vldc-hq/vldc-bot/codespaces) from GitHub itself. |
41 | | - |
42 | | -## Usage |
43 | | -Setup your env vars in `example.env` and rename it to `.env`. Don't push `.env` to public repos! |
| 38 | +## Quick Start |
44 | 39 |
|
| 40 | +1. Copy `example.env` to `.env` and fill in your bot token and chat ID: |
45 | 41 | ``` |
46 | | -make up |
| 42 | +cp example.env .env |
47 | 43 | ``` |
48 | 44 |
|
49 | | -## Local venv (no Docker) |
50 | | -Create a virtual environment and install dependencies locally: |
51 | | - |
| 45 | +2. Run with Docker: |
52 | 46 | ``` |
53 | | -make venv |
54 | | -source .venv/bin/activate |
| 47 | +docker-compose -f docker-compose-dev.yml up |
55 | 48 | ``` |
56 | 49 |
|
57 | | -Run the bot locally: |
| 50 | +Or run locally: |
58 | 51 | ``` |
59 | | -PYTHONPATH=./bot python bot/main.py |
| 52 | +make run |
60 | 53 | ``` |
61 | 54 |
|
62 | | -Then run linters/tests with: |
63 | | -``` |
64 | | -make lint |
65 | | -make test |
66 | | -``` |
| 55 | +## Usage |
67 | 56 |
|
68 | | -## Build local image |
| 57 | +### Environment Variables |
| 58 | + |
| 59 | +| Variable | Required | Description | |
| 60 | +|---|---|---| |
| 61 | +| `TOKEN` | Yes | Telegram bot token | |
| 62 | +| `CHAT_ID` | Yes | Telegram group chat ID | |
| 63 | +| `SQLITE_DB_PATH` | No | Path to SQLite database (default: `bot.db`) | |
| 64 | +| `SENTRY_DSN` | No | Sentry DSN for error tracking | |
| 65 | +| `AOC_SESSION` | No | Advent of Code session cookie | |
| 66 | +| `GOOGLE_PROJECT_ID` | No | Google Cloud project ID (for translation) | |
| 67 | +| `GOOGLE_APPLICATION_CREDENTIALS` | No | Path to Google service account JSON | |
| 68 | +| `GEMINI_API_KEY` | No | Gemini API key (translation fallback) | |
| 69 | +| `OPENAI_API_KEY` | No | OpenAI API key | |
| 70 | +| `DEBUG` | No | Enable debug logging | |
| 71 | + |
| 72 | +### Make targets |
69 | 73 |
|
70 | 74 | ``` |
71 | | -make build |
| 75 | +make build Build the bot binary |
| 76 | +make run Run the bot locally |
| 77 | +make test Run all tests |
| 78 | +make test-cover Run tests with coverage report |
| 79 | +make lint Run golangci-lint |
| 80 | +make format Format code with goimports |
| 81 | +make tidy Run go mod tidy |
| 82 | +make docker-build Build Docker image |
| 83 | +make docker-up Run with docker-compose |
| 84 | +make docker-down Stop docker-compose |
72 | 85 | ``` |
73 | 86 |
|
74 | 87 | ## Developing |
75 | | -Create test Telegram bot, and store TOKEN and chat id, you will need it for developing. |
76 | | - |
77 | | -User `make` to up dev services: |
78 | 88 |
|
79 | | -```shell script |
80 | | -Usage: make [task] |
| 89 | +Create a test Telegram bot via [@BotFather](https://t.me/BotFather), store the token and your chat ID in `.env`. |
81 | 90 |
|
82 | | -task help |
83 | | ------- ---- |
84 | | -build Build all |
85 | | -up Up All and show logs |
86 | | -update Restart bot after files changing |
87 | | -stop Stop all |
88 | | -down Down all |
89 | | -test Run tests |
90 | | -lint Run linters (black, flake8, mypy, pylint) |
91 | | -format Format code (black) |
92 | | - |
93 | | -help Show help message |
| 91 | +Run linters and tests before committing: |
| 92 | +``` |
| 93 | +make lint |
| 94 | +make test |
94 | 95 | ``` |
95 | 96 |
|
96 | | -Don't forget run `make lint` and `make test` before commit! For code formatting we are use [black](https://github.com/psf/black), so, just run `make format` to fire it :3 |
97 | | - |
98 | | -### Setting Up Debugger in VS Code |
| 97 | +## Project Structure |
99 | 98 |
|
100 | | -Create `launch.json` under your `.vscode` directory in project, add the following content onto it: |
101 | 99 | ``` |
102 | | -{ |
103 | | - "version": "0.2.0", |
104 | | - "configurations": [ |
105 | | - { |
106 | | - "name": "Docker Python", |
107 | | - "type": "python", |
108 | | - "request": "attach", |
109 | | - "port": 5678, |
110 | | - "host": "localhost", |
111 | | - "pathMappings": [ |
112 | | - { |
113 | | - "localRoot": "${workspaceFolder}", |
114 | | - "remoteRoot": "/app" |
115 | | - } |
116 | | - ], |
117 | | - } |
118 | | - ] |
119 | | -} |
| 100 | +cmd/bot/ - entry point |
| 101 | +internal/ |
| 102 | + bot/ - bot core, skill registration, middleware |
| 103 | + config/ - configuration loading |
| 104 | + db/ - SQLite database layer |
| 105 | + mode/ - mode state management |
| 106 | + skill/ - all bot skills (one file per skill) |
| 107 | + util/ - shared utilities (cleanup, etc.) |
| 108 | + ai/ - AI client helpers |
120 | 109 | ``` |
121 | 110 |
|
122 | | -Also, put `DEBUGGER=True` into your `.env` file. After that you can do debugging with VS Code, by running containerized application and hitting `Run -> Start Debugging` or `F5` button. |
123 | | - |
124 | 111 | # Contributing |
125 | 112 | Bug reports, bug fixes and new features are always welcome. |
126 | 113 | Please open issues and submit pull requests for any new code. |
0 commit comments