Browse Source

feat: add im bot i18n support

Cat 1 year ago
parent
commit
a0d2195eee

+ 51 - 96
config/settings.json

@@ -690,7 +690,16 @@
         "is_public": 0,
         "is_public": 0,
         "type": "int",
         "type": "int",
         "default": "-1",
         "default": "-1",
-        "mark": "Telegram 群组会话 ID"
+        "mark": "Telegram Group ID"
+    },
+    {
+        "item": "enable_telegram_group_notify",
+        "value": "0",
+        "class": "im",
+        "is_public": 1,
+        "type": "bool",
+        "default": "0",
+        "mark": "Enable Telegram group notify"
     },
     },
     {
     {
         "item": "telegram_bot",
         "item": "telegram_bot",
@@ -719,15 +728,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人添加节点通知"
         "mark": "是否启用Telegram机器人添加节点通知"
     },
     },
-    {
-        "item": "telegram_add_node_text",
-        "value": "%node_name% 已被添加",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "%node_name% 已被添加",
-        "mark": "Telegram机器人添加节点通知文本"
-    },
     {
     {
         "item": "telegram_update_node",
         "item": "telegram_update_node",
         "value": "1",
         "value": "1",
@@ -737,15 +737,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人修改节点通知"
         "mark": "是否启用Telegram机器人修改节点通知"
     },
     },
-    {
-        "item": "telegram_update_node_text",
-        "value": "%node_name% 已被修改",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "%node_name% 已被修改",
-        "mark": "Telegram机器人修改节点通知文本"
-    },
     {
     {
         "item": "telegram_delete_node",
         "item": "telegram_delete_node",
         "value": "1",
         "value": "1",
@@ -755,15 +746,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人删除节点通知"
         "mark": "是否启用Telegram机器人删除节点通知"
     },
     },
-    {
-        "item": "telegram_delete_node_text",
-        "value": "%node_name% 被刪除了",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "%node_name% 被刪除了",
-        "mark": "Telegram机器人删除节点通知文本"
-    },
     {
     {
         "item": "telegram_node_gfwed",
         "item": "telegram_node_gfwed",
         "value": "1",
         "value": "1",
@@ -773,15 +755,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人节点被墙通知"
         "mark": "是否启用Telegram机器人节点被墙通知"
     },
     },
-    {
-        "item": "telegram_node_gfwed_text",
-        "value": "喵喵喵~ %node_name% 节点被墙了喵~",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "喵喵喵~ %node_name% 节点被墙了喵~",
-        "mark": "Telegram机器人节点被墙通知"
-    },
     {
     {
         "item": "telegram_node_ungfwed",
         "item": "telegram_node_ungfwed",
         "value": "1",
         "value": "1",
@@ -791,15 +764,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人节点被墙恢复通知"
         "mark": "是否启用Telegram机器人节点被墙恢复通知"
     },
     },
-    {
-        "item": "telegram_node_ungfwed_text",
-        "value": "喵喵喵~ 被墙的 %node_name% 节点恢复了喵~",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "喵喵喵~ 被墙的 %node_name% 节点恢复了喵~",
-        "mark": "Telegram机器人节点被墙恢复文本"
-    },
     {
     {
         "item": "telegram_node_online",
         "item": "telegram_node_online",
         "value": "1",
         "value": "1",
@@ -809,15 +773,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人节点恢复上线通知"
         "mark": "是否启用Telegram机器人节点恢复上线通知"
     },
     },
-    {
-        "item": "telegram_node_online_text",
-        "value": "%node_name% 被修好了",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "%node_name% 被修好了",
-        "mark": "Telegram机器人节点恢复上线通知文本"
-    },
     {
     {
         "item": "telegram_node_offline",
         "item": "telegram_node_offline",
         "value": "1",
         "value": "1",
@@ -827,15 +782,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人节点离线通知"
         "mark": "是否启用Telegram机器人节点离线通知"
     },
     },
-    {
-        "item": "telegram_node_offline_text",
-        "value": "%node_name% 出现了一些故障",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "%node_name% 出现了一些故障",
-        "mark": "Telegram机器人节点离线通知文本"
-    },
     {
     {
         "item": "telegram_daily_job",
         "item": "telegram_daily_job",
         "value": "1",
         "value": "1",
@@ -845,15 +791,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人每日任务通知"
         "mark": "是否启用Telegram机器人每日任务通知"
     },
     },
-    {
-        "item": "telegram_daily_job_text",
-        "value": "成功执行每日任务",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "成功执行每日任务",
-        "mark": "Telegram机器人每日任务通知文本"
-    },
     {
     {
         "item": "telegram_diary",
         "item": "telegram_diary",
         "value": "1",
         "value": "1",
@@ -863,15 +800,6 @@
         "default": "1",
         "default": "1",
         "mark": "是否启用Telegram机器人系统运行状况通知"
         "mark": "是否启用Telegram机器人系统运行状况通知"
     },
     },
-    {
-        "item": "telegram_diary_text",
-        "value": "今日签到人数:%getTodayCheckinUser% \n 今日使用总流量:%lastday_total%",
-        "class": "im",
-        "is_public": 0,
-        "type": "string",
-        "default": "今日签到人数:%getTodayCheckinUser% \n 今日使用总流量:%lastday_total%",
-        "mark": "Telegram机器人系统运行状况通知文本"
-    },
     {
     {
         "item": "telegram_unbind_kick_member",
         "item": "telegram_unbind_kick_member",
         "value": "0",
         "value": "0",
@@ -890,15 +818,6 @@
         "default": "0",
         "default": "0",
         "mark": "是否仅允许已绑定Telegram账户的用户加入群组"
         "mark": "是否仅允许已绑定Telegram账户的用户加入群组"
     },
     },
-    {
-        "item": "enable_welcome_message",
-        "value": "0",
-        "class": "im",
-        "is_public": 0,
-        "type": "bool",
-        "default": "0",
-        "mark": "Telegram 机器人发送欢迎消息"
-    },
     {
     {
         "item": "telegram_group_quiet",
         "item": "telegram_group_quiet",
         "value": "1",
         "value": "1",
@@ -936,13 +855,13 @@
         "mark": "允许任意未知的命令触发 /help 的回复"
         "mark": "允许任意未知的命令触发 /help 的回复"
     },
     },
     {
     {
-        "item": "user_not_bind_reply",
-        "value": "您未绑定本站账号,您可以进入网站的 **资料编辑**,在右下方绑定您的账号。",
+        "item": "enable_welcome_message",
+        "value": "0",
         "class": "im",
         "class": "im",
         "is_public": 0,
         "is_public": 0,
-        "type": "string",
-        "default": "您未绑定本站账号,您可以进入网站的 **资料编辑**,在右下方绑定您的账号。",
-        "mark": "未绑定账户的回复"
+        "type": "bool",
+        "default": "0",
+        "mark": "Telegram 机器人发送欢迎消息"
     },
     },
     {
     {
         "item": "discord_bot_token",
         "item": "discord_bot_token",
@@ -980,6 +899,24 @@
         "default": "0",
         "default": "0",
         "mark": "Discord Guild ID"
         "mark": "Discord Guild ID"
     },
     },
+    {
+        "item": "discord_channel_id",
+        "value": "0",
+        "class": "im",
+        "is_public": 0,
+        "type": "int",
+        "default": "0",
+        "mark": "Discord Channel ID"
+    },
+    {
+        "item": "enable_discord_channel_notify",
+        "value": "0",
+        "class": "im",
+        "is_public": 1,
+        "type": "bool",
+        "default": "0",
+        "mark": "Enable Discord channel notify"
+    },
     {
     {
         "item": "slack_token",
         "item": "slack_token",
         "value": "",
         "value": "",
@@ -1016,6 +953,24 @@
         "default": "",
         "default": "",
         "mark": "Slack Team ID"
         "mark": "Slack Team ID"
     },
     },
+    {
+        "item": "slack_channel_id",
+        "value": "0",
+        "class": "im",
+        "is_public": 0,
+        "type": "int",
+        "default": "0",
+        "mark": "Slack Channel ID"
+    },
+    {
+        "item": "enable_slack_channel_notify",
+        "value": "0",
+        "class": "im",
+        "is_public": 1,
+        "type": "bool",
+        "default": "0",
+        "mark": "Enable Slack channel notify"
+    },
     {
     {
         "item": "crisp_id",
         "item": "crisp_id",
         "value": "",
         "value": "",

+ 2 - 0
resources/locale/en_US.php

@@ -18,5 +18,7 @@ return [
         'daily_job_run' => 'Successful execution of daily tasks',
         'daily_job_run' => 'Successful execution of daily tasks',
         'diary' => 'Number of people checking in today: %getTodayCheckinUser%' . PHP_EOL . 'Total traffic used today: %lastday_total%',
         'diary' => 'Number of people checking in today: %getTodayCheckinUser%' . PHP_EOL . 'Total traffic used today: %lastday_total%',
         'user_not_bind' => 'You have not bound your account to this website. You can enter the **Edit Account** of the website and bind your account in the lower right corner.',
         'user_not_bind' => 'You have not bound your account to this website. You can enter the **Edit Account** of the website and bind your account in the lower right corner.',
+        'user_join_welcome_free' => 'Welcome %user_name%',
+        'user_join_welcome_paid' => 'Welcome VIP%user_class% user %user_name% to join the group',
     ],
     ],
 ];
 ];

+ 2 - 0
resources/locale/ja_JP.php

@@ -18,5 +18,7 @@ return [
         'daily_job_run' => '日次タスクの正常な実行',
         'daily_job_run' => '日次タスクの正常な実行',
         'diary' => '今日チェックインした人の数: %getTodayCheckinUser%' . PHP_EOL . '今日使用された合計トラフィック: %lastday_total%',
         'diary' => '今日チェックインした人の数: %getTodayCheckinUser%' . PHP_EOL . '今日使用された合計トラフィック: %lastday_total%',
         'user_not_bind' => 'アカウントをこの Web サイトにバインドしていません。Web サイトの **データ編集** に入り、右下隅でアカウントをバインドできます。',
         'user_not_bind' => 'アカウントをこの Web サイトにバインドしていません。Web サイトの **データ編集** に入り、右下隅でアカウントをバインドできます。',
+        'user_join_welcome_free' => 'ようこそ %user_name%',
+        'user_join_welcome_paid' => 'VIP%user_class% ユーザー %user_name% のグループへの参加を歓迎します',
     ],
     ],
 ];
 ];

+ 2 - 0
resources/locale/zh_CN.php

@@ -18,5 +18,7 @@ return [
         'daily_job_run' => '成功执行每日任务',
         'daily_job_run' => '成功执行每日任务',
         'diary' => '今日签到人数:%getTodayCheckinUser%' . PHP_EOL . '今日使用总流量:%lastday_total%',
         'diary' => '今日签到人数:%getTodayCheckinUser%' . PHP_EOL . '今日使用总流量:%lastday_total%',
         'user_not_bind' => '您未绑定本站账号,您可以进入网站的 **资料编辑**,在右下方绑定您的账号。',
         'user_not_bind' => '您未绑定本站账号,您可以进入网站的 **资料编辑**,在右下方绑定您的账号。',
+        'user_join_welcome_free' => '欢迎 %user_name%',
+        'user_join_welcome_paid' => '欢迎 VIP%user_class% 用户 %user_name% 加入群组',
     ],
     ],
 ];
 ];

+ 2 - 0
resources/locale/zh_TW.php

@@ -18,5 +18,7 @@ return [
         'daily_job_run' => '成功執行每日任務',
         'daily_job_run' => '成功執行每日任務',
         'diary' => '今日簽到人數:%getTodayCheckinUser%' . PHP_EOL . '今日使用總流量:%lastday_total%',
         'diary' => '今日簽到人數:%getTodayCheckinUser%' . PHP_EOL . '今日使用總流量:%lastday_total%',
         'user_not_bind' => '您未綁定本站帳號,您可以進入網站的 **資料編輯**,在右下方綁定您的帳號。',
         'user_not_bind' => '您未綁定本站帳號,您可以進入網站的 **資料編輯**,在右下方綁定您的帳號。',
+        'user_join_welcome_free' => '歡迎 %user_name%',
+        'user_join_welcome_paid' => '歡迎 VIP%user_class% 使用者 %user_name% 加入群組',
     ],
     ],
 ];
 ];

+ 72 - 77
resources/views/tabler/admin/setting/im.tpl

@@ -62,13 +62,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">添加节点通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_add_node_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_add_node_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">修改节点通知</label>
                                             <label class="form-label col-3 col-form-label">修改节点通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -83,13 +76,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">修改节点通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_update_node_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_update_node_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">删除节点通知</label>
                                             <label class="form-label col-3 col-form-label">删除节点通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -104,13 +90,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">删除节点通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_delete_node_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_delete_node_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">节点被墙通知</label>
                                             <label class="form-label col-3 col-form-label">节点被墙通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -125,13 +104,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">节点被墙通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_node_gfwed_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_node_gfwed_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">节点被墙恢复通知</label>
                                             <label class="form-label col-3 col-form-label">节点被墙恢复通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -146,13 +118,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">节点被墙恢复通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_node_ungfwed_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_node_ungfwed_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">节点离线通知</label>
                                             <label class="form-label col-3 col-form-label">节点离线通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -167,13 +132,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">节点离线通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_node_offline_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_node_offline_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">节点上线通知</label>
                                             <label class="form-label col-3 col-form-label">节点上线通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -188,13 +146,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">节点上线通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_node_online_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_node_online_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">每日任务通知</label>
                                             <label class="form-label col-3 col-form-label">每日任务通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -209,13 +160,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">每日任务通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_daily_job_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_daily_job_text']}">
-                                            </div>
-                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">系统运行状况通知</label>
                                             <label class="form-label col-3 col-form-label">系统运行状况通知</label>
                                             <div class="col">
                                             <div class="col">
@@ -230,13 +174,6 @@
                                                 </select>
                                                 </select>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">系统运行状况通知文本</label>
-                                            <div class="col">
-                                                <input id="telegram_diary_text" type="text" class="form-control"
-                                                       value="{$settings['telegram_diary_text']}">
-                                            </div>
-                                        </div>
                                     </div>
                                     </div>
                                 </div>
                                 </div>
                                 <div class="tab-pane" id="telegram">
                                 <div class="tab-pane" id="telegram">
@@ -264,12 +201,28 @@
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">Telegram 群组会话 ID</label>
+                                            <label class="form-label col-3 col-form-label">Telegram Group ID</label>
                                             <div class="col">
                                             <div class="col">
                                                 <input id="telegram_chatid" type="text" class="form-control"
                                                 <input id="telegram_chatid" type="text" class="form-control"
                                                        value="{$settings['telegram_chatid']}">
                                                        value="{$settings['telegram_chatid']}">
                                             </div>
                                             </div>
                                         </div>
                                         </div>
+                                        <div class="form-group mb-3 row">
+                                            <label class="form-label col-3 col-form-label">
+                                                Enable Telegram group notify
+                                            </label>
+                                            <div class="col">
+                                                <select id="enable_telegram_group_notify" class="col form-select"
+                                                        value="{$settings['enable_telegram_group_notify']}">
+                                                    <option value="0" {if ! $settings['enable_telegram_group_notify']}selected{/if}>
+                                                        False
+                                                    </option>
+                                                    <option value="1" {if $settings['enable_telegram_group_notify']}selected{/if}>
+                                                        True
+                                                    </option>
+                                                </select>
+                                            </div>
+                                        </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
                                             <label class="form-label col-3 col-form-label">Telegram 机器人账号</label>
                                             <label class="form-label col-3 col-form-label">Telegram 机器人账号</label>
                                             <div class="col">
                                             <div class="col">
@@ -385,18 +338,12 @@
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">未绑定账户的回复</label>
-                                            <div class="col">
-                                                <input id="user_not_bind_reply" type="text" class="form-control"
-                                                       value="{$settings['user_not_bind_reply']}">
-                                            </div>
-                                        </div>
-                                        <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">Telegram 用户 ID</label>
+                                            <label class="form-label col-3 col-form-label">Telegram User ID</label>
                                             <input type="text" class="form-control" id="telegram_user_id" value="">
                                             <input type="text" class="form-control" id="telegram_user_id" value="">
                                             <div class="row my-3">
                                             <div class="row my-3">
                                                 <div class="col">
                                                 <div class="col">
-                                                    <button id="test-telegram" class="btn btn-primary">发送测试信息
+                                                    <button id="test-telegram" class="btn btn-primary">
+                                                        Send Test Message
                                                     </button>
                                                     </button>
                                                 </div>
                                                 </div>
                                             </div>
                                             </div>
@@ -434,11 +381,35 @@
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">Discord 用户 ID</label>
+                                            <label class="form-label col-3 col-form-label">Discord Channel ID</label>
+                                            <div class="col">
+                                                <input id="discord_channel_id" type="text" class="form-control"
+                                                       value="{$settings['discord_channel_id']}">
+                                            </div>
+                                        </div>
+                                        <div class="form-group mb-3 row">
+                                            <label class="form-label col-3 col-form-label">
+                                                Enable Discord channel notify
+                                            </label>
+                                            <div class="col">
+                                                <select id="enable_discord_channel_notify" class="col form-select"
+                                                        value="{$settings['enable_discord_channel_notify']}">
+                                                    <option value="0" {if ! $settings['enable_discord_channel_notify']}selected{/if}>
+                                                        False
+                                                    </option>
+                                                    <option value="1" {if $settings['enable_discord_channel_notify']}selected{/if}>
+                                                        True
+                                                    </option>
+                                                </select>
+                                            </div>
+                                        </div>
+                                        <div class="form-group mb-3 row">
+                                            <label class="form-label col-3 col-form-label">Discord User ID</label>
                                             <input type="text" class="form-control" id="discord_user_id" value="">
                                             <input type="text" class="form-control" id="discord_user_id" value="">
                                             <div class="row my-3">
                                             <div class="row my-3">
                                                 <div class="col">
                                                 <div class="col">
-                                                    <button id="test-discord" class="btn btn-primary">发送测试信息
+                                                    <button id="test-discord" class="btn btn-primary">
+                                                        Send Test Message
                                                     </button>
                                                     </button>
                                                 </div>
                                                 </div>
                                             </div>
                                             </div>
@@ -476,11 +447,35 @@
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                         <div class="form-group mb-3 row">
                                         <div class="form-group mb-3 row">
-                                            <label class="form-label col-3 col-form-label">Slack 用户 ID</label>
+                                            <label class="form-label col-3 col-form-label">Slack Channel ID</label>
+                                            <div class="col">
+                                                <input id="slack_channel_id" type="text" class="form-control"
+                                                       value="{$settings['slack_channel_id']}">
+                                            </div>
+                                        </div>
+                                        <div class="form-group mb-3 row">
+                                            <label class="form-label col-3 col-form-label">
+                                                Enable Slack channel notify
+                                            </label>
+                                            <div class="col">
+                                                <select id="enable_slack_channel_notify" class="col form-select"
+                                                        value="{$settings['enable_slack_channel_notify']}">
+                                                    <option value="0" {if ! $settings['enable_slack_channel_notify']}selected{/if}>
+                                                        False
+                                                    </option>
+                                                    <option value="1" {if $settings['enable_slack_channel_notify']}selected{/if}>
+                                                        True
+                                                    </option>
+                                                </select>
+                                            </div>
+                                        </div>
+                                        <div class="form-group mb-3 row">
+                                            <label class="form-label col-3 col-form-label">Slack User ID</label>
                                             <input type="text" class="form-control" id="slack_user_id" value="">
                                             <input type="text" class="form-control" id="slack_user_id" value="">
                                             <div class="row my-3">
                                             <div class="row my-3">
                                                 <div class="col">
                                                 <div class="col">
-                                                    <button id="test-slack" class="btn btn-primary">发送测试信息
+                                                    <button id="test-slack" class="btn btn-primary">
+                                                        Send Test Message
                                                     </button>
                                                     </button>
                                                 </div>
                                                 </div>
                                             </div>
                                             </div>

+ 4 - 3
src/Controllers/Admin/NodeController.php

@@ -7,6 +7,7 @@ namespace App\Controllers\Admin;
 use App\Controllers\BaseController;
 use App\Controllers\BaseController;
 use App\Models\Config;
 use App\Models\Config;
 use App\Models\Node;
 use App\Models\Node;
+use App\Services\I18n;
 use App\Services\IM\Telegram;
 use App\Services\IM\Telegram;
 use App\Utils\Tools;
 use App\Utils\Tools;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ResponseInterface;
@@ -137,7 +138,7 @@ final class NodeController extends BaseController
                     str_replace(
                     str_replace(
                         '%node_name%',
                         '%node_name%',
                         $request->getParam('name'),
                         $request->getParam('name'),
-                        Config::obtain('telegram_add_node_text')
+                        I18n::trans('bot.node_added', $_ENV['locale'])
                     )
                     )
                 );
                 );
             } catch (TelegramSDKException) {
             } catch (TelegramSDKException) {
@@ -231,7 +232,7 @@ final class NodeController extends BaseController
                     str_replace(
                     str_replace(
                         '%node_name%',
                         '%node_name%',
                         $request->getParam('name'),
                         $request->getParam('name'),
-                        Config::obtain('telegram_update_node_text')
+                        I18n::trans('bot.node_updated', $_ENV['locale'])
                     )
                     )
                 );
                 );
             } catch (TelegramSDKException) {
             } catch (TelegramSDKException) {
@@ -293,7 +294,7 @@ final class NodeController extends BaseController
                     str_replace(
                     str_replace(
                         '%node_name%',
                         '%node_name%',
                         $node->name,
                         $node->name,
-                        Config::obtain('telegram_delete_node_text')
+                        I18n::trans('bot.node_deleted', $_ENV['locale'])
                     )
                     )
                 );
                 );
             } catch (TelegramSDKException) {
             } catch (TelegramSDKException) {

+ 15 - 16
src/Controllers/Admin/Setting/ImController.php

@@ -19,29 +19,23 @@ use Telegram\Bot\Exceptions\TelegramSDKException;
 final class ImController extends BaseController
 final class ImController extends BaseController
 {
 {
     private static array $update_field = [
     private static array $update_field = [
-        'enable_telegram',
-        'telegram_token',
-        'telegram_chatid',
-        'telegram_bot',
-        'telegram_request_token',
+        // TODO: rename these to im service independent
         'telegram_add_node',
         'telegram_add_node',
-        'telegram_add_node_text',
         'telegram_update_node',
         'telegram_update_node',
-        'telegram_update_node_text',
         'telegram_delete_node',
         'telegram_delete_node',
-        'telegram_delete_node_text',
         'telegram_node_gfwed',
         'telegram_node_gfwed',
-        'telegram_node_gfwed_text',
         'telegram_node_ungfwed',
         'telegram_node_ungfwed',
-        'telegram_node_ungfwed_text',
-        'telegram_node_offline',
-        'telegram_node_offline_text',
         'telegram_node_online',
         'telegram_node_online',
-        'telegram_node_online_text',
+        'telegram_node_offline',
         'telegram_daily_job',
         'telegram_daily_job',
-        'telegram_daily_job_text',
         'telegram_diary',
         'telegram_diary',
-        'telegram_diary_text',
+        // Telegram
+        'enable_telegram',
+        'telegram_token',
+        'telegram_chatid',
+        'enable_telegram_group_notify',
+        'telegram_bot',
+        'telegram_request_token',
         'telegram_unbind_kick_member',
         'telegram_unbind_kick_member',
         'telegram_group_bound_user',
         'telegram_group_bound_user',
         'enable_welcome_message',
         'enable_welcome_message',
@@ -49,15 +43,20 @@ final class ImController extends BaseController
         'allow_to_join_new_groups',
         'allow_to_join_new_groups',
         'group_id_allowed_to_join',
         'group_id_allowed_to_join',
         'help_any_command',
         'help_any_command',
-        'user_not_bind_reply',
+        // Discord
         'discord_bot_token',
         'discord_bot_token',
         'discord_client_id',
         'discord_client_id',
         'discord_client_secret',
         'discord_client_secret',
         'discord_guild_id',
         'discord_guild_id',
+        'discord_channel_id',
+        'enable_discord_channel_notify',
+        // Slack
         'slack_token',
         'slack_token',
         'slack_client_id',
         'slack_client_id',
         'slack_client_secret',
         'slack_client_secret',
         'slack_team_id',
         'slack_team_id',
+        'slack_channel_id',
+        'enable_slack_channel_notify',
     ];
     ];
 
 
     private static string $test_msg = '这是一条测试消息';
     private static string $test_msg = '这是一条测试消息';

+ 3 - 1
src/Services/Bot/Telegram/Commands/CheckinCommand.php

@@ -6,6 +6,7 @@ namespace App\Services\Bot\Telegram\Commands;
 
 
 use App\Models\Config;
 use App\Models\Config;
 use App\Services\Bot\Telegram\Message;
 use App\Services\Bot\Telegram\Message;
+use App\Services\I18n;
 use App\Services\Reward;
 use App\Services\Reward;
 use Telegram\Bot\Actions;
 use Telegram\Bot\Actions;
 use Telegram\Bot\Commands\Command;
 use Telegram\Bot\Commands\Command;
@@ -53,13 +54,14 @@ final class CheckinCommand extends Command
         $send_user = [
         $send_user = [
             'id' => $message->getFrom()->getId(),
             'id' => $message->getFrom()->getId(),
         ];
         ];
+
         $user = Message::getUser($send_user['id']);
         $user = Message::getUser($send_user['id']);
 
 
         if ($user === null) {
         if ($user === null) {
             // 回送信息
             // 回送信息
             $response = $this->replyWithMessage(
             $response = $this->replyWithMessage(
                 [
                 [
-                    'text' => Config::obtain('user_not_bind_reply'),
+                    'text' => I18n::trans('bot.user_not_bind', $_ENV['locale']),
                     'parse_mode' => 'Markdown',
                     'parse_mode' => 'Markdown',
                     'reply_to_message_id' => $message->getMessageId(),
                     'reply_to_message_id' => $message->getMessageId(),
                 ]
                 ]

+ 2 - 1
src/Services/Bot/Telegram/Commands/MyCommand.php

@@ -7,6 +7,7 @@ namespace App\Services\Bot\Telegram\Commands;
 use App\Models\Config;
 use App\Models\Config;
 use App\Models\User;
 use App\Models\User;
 use App\Services\Bot\Telegram\Message;
 use App\Services\Bot\Telegram\Message;
+use App\Services\I18n;
 use Telegram\Bot\Actions;
 use Telegram\Bot\Actions;
 use Telegram\Bot\Commands\Command;
 use Telegram\Bot\Commands\Command;
 use function json_encode;
 use function json_encode;
@@ -66,7 +67,7 @@ final class MyCommand extends Command
             // 回送信息
             // 回送信息
             $response = $this->replyWithMessage(
             $response = $this->replyWithMessage(
                 [
                 [
-                    'text' => Config::obtain('user_not_bind_reply'),
+                    'text' => I18n::trans('bot.user_not_bind', $_ENV['locale']),
                     'reply_to_message_id' => $message_id,
                     'reply_to_message_id' => $message_id,
                     'parse_mode' => 'Markdown',
                     'parse_mode' => 'Markdown',
                 ]
                 ]

+ 2 - 1
src/Services/Bot/Telegram/Commands/UnbindCommand.php

@@ -6,6 +6,7 @@ namespace App\Services\Bot\Telegram\Commands;
 
 
 use App\Models\Config;
 use App\Models\Config;
 use App\Services\Bot\Telegram\Message;
 use App\Services\Bot\Telegram\Message;
+use App\Services\I18n;
 use Telegram\Bot\Actions;
 use Telegram\Bot\Actions;
 use Telegram\Bot\Commands\Command;
 use Telegram\Bot\Commands\Command;
 use Telegram\Bot\Exceptions\TelegramSDKException;
 use Telegram\Bot\Exceptions\TelegramSDKException;
@@ -52,7 +53,7 @@ final class UnbindCommand extends Command
                 // 回送信息
                 // 回送信息
                 $this->replyWithMessage(
                 $this->replyWithMessage(
                     [
                     [
-                        'text' => Config::obtain('user_not_bind_reply'),
+                        'text' => I18n::trans('bot.user_not_bind', $_ENV['locale']),
                         'parse_mode' => 'Markdown',
                         'parse_mode' => 'Markdown',
                     ]
                     ]
                 );
                 );

+ 16 - 3
src/Services/Bot/Telegram/Message.php

@@ -6,6 +6,7 @@ namespace App\Services\Bot\Telegram;
 
 
 use App\Models\Config;
 use App\Models\Config;
 use App\Models\User;
 use App\Models\User;
+use App\Services\I18n;
 use GuzzleHttp\Client;
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\GuzzleException;
 use GuzzleHttp\Exception\GuzzleException;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Model;
@@ -16,6 +17,7 @@ use function array_merge;
 use function implode;
 use function implode;
 use function in_array;
 use function in_array;
 use function json_decode;
 use function json_decode;
+use function str_replace;
 use const PHP_EOL;
 use const PHP_EOL;
 
 
 final class Message
 final class Message
@@ -140,12 +142,23 @@ final class Message
             }
             }
 
 
             if (Config::obtain('enable_welcome_message')) {
             if (Config::obtain('enable_welcome_message')) {
-                $text = ($new_user->class > 0 ? '欢迎 VIP' . $new_user->class .
-                    ' 用户 ' . $member['name'] . '加入群组。' : '欢迎 ' . $member['name']);
+                $text = ($new_user->class > 0 ?
+                    I18n::trans('user_join_welcome_paid', $_ENV['locale']) :
+                    I18n::trans('user_join_welcome_free', $_ENV['locale']));
 
 
                 $this->replyWithMessage(
                 $this->replyWithMessage(
                     [
                     [
-                        'text' => $text,
+                        'text' => str_replace(
+                            [
+                                '%user_name%',
+                                '%user_class%',
+                            ],
+                            [
+                                $member['name'],
+                                $new_user->class,
+                            ],
+                            $text
+                        ),
                     ]
                     ]
                 );
                 );
             }
             }

+ 4 - 4
src/Services/Cron.php

@@ -103,7 +103,7 @@ final class Cron
                     $notice_text = str_replace(
                     $notice_text = str_replace(
                         '%node_name%',
                         '%node_name%',
                         $node->name,
                         $node->name,
-                        Config::obtain('telegram_node_offline_text')
+                        I18n::trans('bot.node_offline', $_ENV['locale'])
                     );
                     );
 
 
                     try {
                     try {
@@ -135,7 +135,7 @@ final class Cron
                     $notice_text = str_replace(
                     $notice_text = str_replace(
                         '%node_name%',
                         '%node_name%',
                         $node->name,
                         $node->name,
-                        Config::obtain('telegram_node_online_text')
+                        I18n::trans('bot.node_online', $_ENV['locale'])
                     );
                     );
 
 
                     try {
                     try {
@@ -630,7 +630,7 @@ final class Cron
      */
      */
     public static function sendTelegramDailyJob(): void
     public static function sendTelegramDailyJob(): void
     {
     {
-        (new Telegram())->send(0, Config::obtain('telegram_daily_job_text'));
+        (new Telegram())->send(0, I18n::trans('bot.daily_job_run', $_ENV['locale']));
 
 
         echo Tools::toDateTime(time()) . ' 成功发送 Telegram 每日任务提示' . PHP_EOL;
         echo Tools::toDateTime(time()) . ' 成功发送 Telegram 每日任务提示' . PHP_EOL;
     }
     }
@@ -651,7 +651,7 @@ final class Cron
                     Analytics::getTodayCheckinUser(),
                     Analytics::getTodayCheckinUser(),
                     Analytics::getTodayTrafficUsage(),
                     Analytics::getTodayTrafficUsage(),
                 ],
                 ],
-                Config::obtain('telegram_diary_text')
+                I18n::trans('bot.diary', $_ENV['locale'])
             )
             )
         );
         );
 
 

+ 2 - 2
src/Services/Detect.php

@@ -64,7 +64,7 @@ final class Detect
                     $notice_text = str_replace(
                     $notice_text = str_replace(
                         '%node_name%',
                         '%node_name%',
                         $node->name,
                         $node->name,
-                        Config::obtain('telegram_node_gfwed_text')
+                        I18n::trans('bot.node_gfwed', $_ENV['locale'])
                     );
                     );
 
 
                     (new Telegram())->send(0, $notice_text);
                     (new Telegram())->send(0, $notice_text);
@@ -93,7 +93,7 @@ final class Detect
                     $notice_text = str_replace(
                     $notice_text = str_replace(
                         '%node_name%',
                         '%node_name%',
                         $node->name,
                         $node->name,
-                        Config::obtain('telegram_node_ungfwed_text')
+                        I18n::trans('bot.node_ungfwed', $_ENV['locale'])
                     );
                     );
 
 
                     (new Telegram())->send(0, $notice_text);
                     (new Telegram())->send(0, $notice_text);

+ 18 - 9
src/Services/IM/Discord.php

@@ -27,25 +27,34 @@ final class Discord extends Base
      */
      */
     public function send($to, $msg): void
     public function send($to, $msg): void
     {
     {
-        $dm_url = 'https://discord.com/api/v10/users/@me/channels';
-
         $headers = [
         $headers = [
             'Authorization' => "Bot {$this->token}",
             'Authorization' => "Bot {$this->token}",
             'User-Agent' => 'DiscordBot (' . $_ENV['appName'] . ', ' . VERSION . ')',
             'User-Agent' => 'DiscordBot (' . $_ENV['appName'] . ', ' . VERSION . ')',
             'Content-Type' => 'application/json',
             'Content-Type' => 'application/json',
         ];
         ];
 
 
-        $dm_body = [
-            'recipient_id' => $to,
-        ];
+        $channel_check_url = 'https://discord.com/api/v10/channels/' . $to;
 
 
-        $dm_response = $this->client->post($dm_url, [
+        $channel_check_response = $this->client->get($channel_check_url, [
             'headers' => $headers,
             'headers' => $headers,
-            'json' => $dm_body,
         ]);
         ]);
 
 
-        $channel_id = json_decode($dm_response->getBody()->getContents())->id;
-        $channel_url = "https://discord.com/api/v10/channels/{$channel_id}/messages";
+        if ($channel_check_response->getStatusCode() !== 200) {
+            $dm_url = 'https://discord.com/api/v10/users/@me/channels';
+
+            $dm_body = [
+                'recipient_id' => $to,
+            ];
+
+            $dm_response = $this->client->post($dm_url, [
+                'headers' => $headers,
+                'json' => $dm_body,
+            ]);
+
+            $to = json_decode($dm_response->getBody()->getContents())->id;
+        }
+
+        $channel_url = 'https://discord.com/api/v10/channels/' . $to . '/messages';
 
 
         $msg_body = [
         $msg_body = [
             'content' => $msg,
             'content' => $msg,

+ 20 - 0
src/Services/Notification.php

@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 
 namespace App\Services;
 namespace App\Services;
 
 
+use App\Models\Config;
 use App\Models\EmailQueue;
 use App\Models\EmailQueue;
 use App\Models\User;
 use App\Models\User;
 use GuzzleHttp\Exception\GuzzleException;
 use GuzzleHttp\Exception\GuzzleException;
@@ -87,4 +88,23 @@ final class Notification
             }
             }
         }
         }
     }
     }
+
+    /**
+     * @throws GuzzleException
+     * @throws TelegramSDKException
+     */
+    public static function notifyUserGroup($msg = ''): void
+    {
+        if (Config::obtain('enable_telegram_group_notify')) {
+            IM::send(Config::obtain('telegram_chatid'), $msg, 0);
+        }
+
+        if (Config::obtain('enable_discord_channel_notify')) {
+            IM::send(Config::obtain('discord_channel_id'), $msg, 1);
+        }
+
+        if (Config::obtain('enable_slack_channel_notify')) {
+            IM::send(Config::obtain('slack_channel_id'), $msg, 2);
+        }
+    }
 }
 }