@@ -10,32 +10,82 @@ const fetch = require('node-fetch');
10
10
// 'start' - standard bot command
11
11
bot . start ( ctx =>
12
12
ctx . reply (
13
- 'Привет , я Хассан и я скоро поумнею . Набери /help для списка команд.'
13
+ 'Привіт , я Хасан і я скоро порозумнішаю . Набери /help для списку команд.'
14
14
)
15
15
) ;
16
16
17
17
// 'help' command, can be reworked to show action buttons
18
18
bot . help ( ctx =>
19
19
ctx . reply (
20
- '/who - показать кто в мире\n' +
21
- '/cat - случайный котик\n' +
22
- '/cat says/meow meow - кот с надписью\n' +
23
- '/cat hat/says/hello - кот с тегом hat и надписью\n' +
24
- '/cat gif - анимированный кот\n' +
25
- '/cat says/hello?color=orange - кот с надписью оранжевым цветом\n' +
26
- '/cat says/aloha?color=red&filter=sepia - кот с надписью красным цветом в сепии\n' +
27
- ' доступны опции:\n' +
28
- ' color - цвет текста;\n' +
29
- ' size - размер шрифта;\n' +
20
+ '/who - показати хто в світі\n' +
21
+ '/who [імʼя] - інформація про конкретного гравця\n' +
22
+ '/bug - відправити баг-репорт\n' +
23
+ '/typo - повідомити про друкарську помилку\n' +
24
+ '/idea - відправити ідею\n' +
25
+ '/nohelp - повідомити про відсутність розділу допомоги\n' +
26
+ '/cat - випадковий котик\n' +
27
+ '/cat says/meow meow - кіт з написом\n' +
28
+ '/cat hat/says/hello - кіт з тегом hat і написом\n' +
29
+ '/cat gif - анімований кіт\n' +
30
+ '/cat says/hello?color=orange - кіт з написом помаранчевим кольором\n' +
31
+ '/cat says/aloha?color=red&filter=sepia - кіт з написом червоним кольором в сепії\n' +
32
+ ' доступні опції:\n' +
33
+ ' color - колір тексту;\n' +
34
+ ' size - розмір шрифту;\n' +
30
35
' type - тип картинки (small, medium, square, original);\n' +
31
- ' filter - фильтр (blur,mono,sepia,negative,paint,pixel);\n' +
32
- ' width|height - ширина или высота картинки в пикселях ;\n' +
33
- 'Подробности в https://cataas.com/'
36
+ ' filter - фільтр (blur,mono,sepia,negative,paint,pixel);\n' +
37
+ ' width|height - ширина або висота картинки в пікселях ;\n' +
38
+ 'Деталі на https://cataas.com/'
34
39
)
35
40
) ;
36
41
37
42
bot . use ( commandArgsMiddleware ( ) ) ;
38
43
44
+ bot . command ( 'bug' , async ctx => {
45
+ await handleReportCommand ( ctx , 'bug' ) ;
46
+ } ) ;
47
+
48
+ bot . command ( 'typo' , async ctx => {
49
+ await handleReportCommand ( ctx , 'typo' ) ;
50
+ } ) ;
51
+
52
+ bot . command ( 'idea' , async ctx => {
53
+ await handleReportCommand ( ctx , 'idea' ) ;
54
+ } ) ;
55
+
56
+ bot . command ( 'nohelp' , async ctx => {
57
+ await handleReportCommand ( ctx , 'nohelp' ) ;
58
+ } ) ;
59
+
60
+ async function handleReportCommand ( ctx , type ) {
61
+ const args = ctx . state . command . args ;
62
+
63
+ if ( ! args || typeof args !== 'string' || args . trim ( ) === '' ) {
64
+ return ctx . reply (
65
+ `Будь ласка, вкажіть опис після команди /${ ctx . state . command . command } .`
66
+ ) ;
67
+ }
68
+
69
+ const userId = ctx . from . username
70
+ ? `@${ ctx . from . username } `
71
+ : ctx . from . first_name ;
72
+
73
+ const reportData = {
74
+ id : userId ,
75
+ message : args ,
76
+ } ;
77
+
78
+ try {
79
+ const response = await dreamland . sendReport ( type , reportData ) ;
80
+ ctx . replyWithMarkdown ( response ) ;
81
+ } catch ( error ) {
82
+ console . error ( 'Помилка під час надсилання повідомлення:' , error ) ;
83
+ ctx . reply (
84
+ 'Сталася помилка під час надсилання повідомлення. Спробуйте пізніше.'
85
+ ) ;
86
+ }
87
+ }
88
+
39
89
bot . command ( 'who' , async ctx => {
40
90
const args = { message : ctx . state . command . args } ;
41
91
@@ -61,7 +111,7 @@ bot.catch(err => {
61
111
console . log ( err ) ;
62
112
} ) ;
63
113
64
- // 'cat' command for my dear Tahi.
114
+ // 'cat' command for my dear Tahi.
65
115
const parser = ( str , numb ) => {
66
116
let result = '' ;
67
117
let matches = str . match (
@@ -120,9 +170,9 @@ bot.command('cat', async ctx => {
120
170
}
121
171
122
172
if ( response . status === 404 )
123
- return ctx . reply ( 'Неправильный запрос, читайте /help' ) ;
173
+ return ctx . reply ( 'Неправильний запит читайте /help' ) ;
124
174
125
- return ctx . reply ( 'Какая-то ошибка, попробуйте позже .' ) ;
175
+ return ctx . reply ( 'Якась помилка, спробуйте пізніше .' ) ;
126
176
} ) ;
127
177
128
178
bot . launch ( ) ;
0 commit comments