|
@@ -851,23 +851,23 @@ bot.onText(/\/help/, (msg) => {
|
|
|
🤖 <b>机器人使用指南</b>
|
|
|
|
|
|
<b>📝 快捷命令</b>
|
|
|
-• <code>+数字</code> 快速记录入款
|
|
|
-• <code>-数字</code> 快速记录入款修正
|
|
|
-• <code>下发数字</code> 快速记录下发
|
|
|
-• <code>下发-数字</code> 快速记录下发修正
|
|
|
+• <code>+数字</code> - 快速记录入款
|
|
|
+• <code>-数字</code> - 快速记录入款修正
|
|
|
+• <code>下发数字</code> - 快速记录下发
|
|
|
+• <code>下发-数字</code> - 快速记录下发修正
|
|
|
|
|
|
<b>⚙️ 设置命令</b>
|
|
|
-• <code>设置费率数字</code> 同时设置入款和出款费率
|
|
|
-• <code>设置入款费率数字</code> 设置入款费率
|
|
|
-• <code>设置出款费率数字</code> 设置出款费率
|
|
|
-• <code>设置汇率数字</code> 同时设置入款和出款汇率
|
|
|
-• <code>设置入款汇率数字</code> 设置入款汇率
|
|
|
-• <code>设置出款汇率数字</code> 设置出款汇率
|
|
|
-• <code>设置操作人@用户名</code> 设置群组操作人
|
|
|
+• <code>设置费率数字</code> - 同时设置入款和出款费率
|
|
|
+• <code>设置入款费率数字</code> - 设置入款费率
|
|
|
+• <code>设置出款费率数字</code> - 设置出款费率
|
|
|
+• <code>设置汇率数字</code> - 同时设置入款和出款汇率
|
|
|
+• <code>设置入款汇率数字</code> - 设置入款汇率
|
|
|
+• <code>设置出款汇率数字</code> - 设置出款汇率
|
|
|
+• <code>回复消息"设置操作人"</code> - 将回复的用户设为群组操作人
|
|
|
|
|
|
<b>📊 查询命令</b>
|
|
|
-• <code>/bill</code> 查看当前账单
|
|
|
-• <code>/help</code> 显示此帮助信息
|
|
|
+• <code>/bill</code> - 查看当前账单
|
|
|
+• <code>/help</code> - 显示此帮助信息
|
|
|
|
|
|
<b>💡 使用提示</b>
|
|
|
• 所有金额输入请使用数字
|
|
@@ -878,83 +878,6 @@ bot.onText(/\/help/, (msg) => {
|
|
|
});
|
|
|
|
|
|
// - 4.群组信息更新
|
|
|
-// 机器人被添加到群组
|
|
|
-bot.on('new_chat_members', async (msg) => {
|
|
|
- // 获取机器人ID
|
|
|
- const botInfo = await bot.getMe();
|
|
|
- // console.log('机器人信息:', botInfo);
|
|
|
-
|
|
|
- // 检查是否机器人被添加
|
|
|
- const botMember = msg.new_chat_members.find(member => member.id === botInfo.id);
|
|
|
- if (!botMember) {
|
|
|
- console.log('机器人未被添加,忽略事件');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- const chatId = msg.chat.id.toString();
|
|
|
- const chatTitle = msg.chat.title || '未命名群组';
|
|
|
- const creatorId = msg.from.id.toString();
|
|
|
-
|
|
|
- // 检查群组是否已存在
|
|
|
- const [existingGroup] = await pool.query(
|
|
|
- 'SELECT * FROM groups WHERE group_id = ?',
|
|
|
- [chatId]
|
|
|
- );
|
|
|
-
|
|
|
- if (!existingGroup || existingGroup.length === 0) {
|
|
|
- // 创建新群组记录
|
|
|
- await pool.query(`
|
|
|
- INSERT INTO groups (
|
|
|
- group_id,
|
|
|
- group_name,
|
|
|
- creator_id,
|
|
|
- in_fee_rate,
|
|
|
- out_fee_rate,
|
|
|
- in_exchange_rate,
|
|
|
- out_exchange_rate,
|
|
|
- last_join_time,
|
|
|
- created_at,
|
|
|
- updated_at,
|
|
|
- operators
|
|
|
- ) VALUES (?, ?, ?, 0, 0, 1, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '[]')
|
|
|
- `, [chatId, chatTitle, creatorId]);
|
|
|
-
|
|
|
- // 将群组添加到允许列表
|
|
|
- if (!data.allowedGroups.includes(chatId)) {
|
|
|
- data.allowedGroups.push(chatId);
|
|
|
- saveData();
|
|
|
- }
|
|
|
-
|
|
|
- // 发送欢迎消息
|
|
|
- await sendMessage(msg.chat.id, `感谢您添加我进入群组!\n\n我已初始化群组账单系统,您可以使用以下命令开始使用:\n\n• <code>/help</code> 查看使用指南\n• <code>/bill</code> 查看当前账单`);
|
|
|
-
|
|
|
- console.log(`新群组初始化成功 - 群组: ${chatTitle}, ID: ${chatId}, 创建者: ${creatorId}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- } else {
|
|
|
- // 更新群组信息
|
|
|
- await pool.query(`
|
|
|
- UPDATE groups
|
|
|
- SET group_name = ?,
|
|
|
- last_join_time = CURRENT_TIMESTAMP,
|
|
|
- updated_at = CURRENT_TIMESTAMP
|
|
|
- WHERE group_id = ?
|
|
|
- `, [chatTitle, chatId]);
|
|
|
-
|
|
|
- // 确保群组在允许列表中
|
|
|
- if (!data.allowedGroups.includes(chatId)) {
|
|
|
- data.allowedGroups.push(chatId);
|
|
|
- saveData();
|
|
|
- }
|
|
|
-
|
|
|
- await sendMessage(msg.chat.id, `我已重新加入群组!\n\n您可以使用 <code>/help</code> 查看使用指南`);
|
|
|
- console.log(`群组信息更新成功 - 群组: ${chatTitle}, ID: ${chatId}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('处理新群组失败:', error);
|
|
|
- await sendMessage(msg.chat.id, '初始化群组失败,请稍后重试');
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
// 处理机器人成员状态更新(包括被邀请到新群组)
|
|
|
bot.on('my_chat_member', async (msg) => {
|
|
|
try {
|