blob: 20fc0d5e743c783ecd96fb2f5c91f21c7993d77f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# Team Issues Parser and Sender
Script for parsing GitHub issues creation results and sending separate messages for each team to Telegram.
## Quick Start
```bash
python .github/scripts/telegram/parse_and_send_team_issues.py \
--file "created_issues.txt" \
--bot-token "YOUR_BOT_TOKEN" \
--team-channels '{"channels": {"main": "1234567890/1"}, "teams": {"team1": {"channel": "main", "responsible": ["@lead1"]}}, "default_channel": "main"}'
```
## Parameters
- `--file` - Path to results file (required)
- `--bot-token` - Telegram bot token (or TELEGRAM_BOT_TOKEN env var)
- `--team-channels` - JSON string mapping teams to their channel configurations (or TEAM_CHANNELS env var) (required)
- `--message-thread-id` - Thread ID for group messages (optional)
- `--delay` - Delay between messages in seconds (default: 2)
- `--dry-run` - Parse only without sending messages
- `--max-retries` - Maximum number of retry attempts for failed messages (default: 5)
- `--retry-delay` - Delay between retry attempts in seconds (default: 10)
## Message Format
```
🔇 **07-09-24 new muted tests in `main` for [team-name](https://github.com/orgs/ydb-platform/teams/team-name)** #teamname
🎯 `Issue Title` [#12345](https://github.com/...)
🎯 `Another Issue Title` [#12346](https://github.com/...)
📊 **[Total muted tests: 150](https://datalens.yandex/4un3zdm0zcnyr?owner_team=team-name) 🔴+5 muted /🟢-2 unmuted**
fyi: @responsible1 @responsible2
```
## Team Channels Configuration
```json
{
"channels": {
"main": "1234567890/1",
"secondary": "1234567890/5"
},
"teams": {
"engineering": {
"channel": "secondary",
"responsible": ["@engineering-lead"]
},
"appteam": {
"channel": "secondary",
"responsible": ["@appteam-lead"]
},
"docs": {
"channel": "main",
"responsible": ["@docs-lead"]
}
},
"default_channel": "main"
}
```
### Channel Selection Logic
1. **Team-specific channel**: If team exists in `teams` → use its `channel` from `channels`
2. **Default channel**: If team not found → use `default_channel` from `channels`
3. **Fallback**: If no `TEAM_CHANNELS` or `default_channel` → use `--chat-id` parameter
### Configuration Structure
- **`channels`** - Maps channel names to actual chat IDs
- **`teams`** - Maps team names to their channel and responsible users
- **`default_channel`** - Default channel name for teams not specified
### Responsible Users Logic
1. **From `teams[team].responsible`**: If team has `responsible` → use it
2. **Empty**: If no responsible found → no responsible users in message
## Supported Input File Format
```
🆕 **CREATED ISSUES**
─────────────────────────────
👥 **TEAM** @ydb-platform/team1
🎯 https://github.com/ydb-platform/ydb/issues/12345 - `Issue Title 1`
🎯 https://github.com/ydb-platform/ydb/issues/12346 - `Issue Title 2`
```
## Features
- ✅ Separate messages for each team
- ✅ Markdown formatting with proper escaping
- ✅ Responsible user mentions in messages
- ✅ Message thread support
- ✅ Dry run mode for testing
- ✅ Automatic retry mechanism (5 retries with 10s delay by default)
- ✅ Detailed error logging with failed message content
- ✅ Automatic chat_id/thread_id parsing from "2018419243/1" format
|