|
@@ -365,6 +365,42 @@ bot.on('message', async (msg) => {
|
|
|
await sendMessage(msg.chat.id, '汇率设置失败,请输入大于0的数字');
|
|
|
}
|
|
|
}
|
|
|
+ // 处理TRX地址
|
|
|
+ else if (/^T[A-Za-z0-9]{33}$/.test(text)) {
|
|
|
+ try {
|
|
|
+ // 检查地址是否已存在
|
|
|
+ const [existingAddress] = await pool.query(
|
|
|
+ 'SELECT * FROM trx_addresses WHERE address = ?',
|
|
|
+ [text]
|
|
|
+ );
|
|
|
+
|
|
|
+ if (existingAddress && existingAddress.length > 0) {
|
|
|
+ // 更新使用次数和最后出现时间
|
|
|
+ await pool.query(`
|
|
|
+ UPDATE trx_addresses
|
|
|
+ SET usage_count = usage_count + 1,
|
|
|
+ last_seen_time = CURRENT_TIMESTAMP
|
|
|
+ WHERE address = ?
|
|
|
+ `, [text]);
|
|
|
+
|
|
|
+ const newCount = existingAddress[0].usage_count + 1;
|
|
|
+ await sendMessage(msg.chat.id, `此地址累计发送第${newCount}次`);
|
|
|
+ console.log(`TRX地址使用次数更新 - 地址: ${text}, 次数: ${newCount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ } else {
|
|
|
+ // 插入新地址记录
|
|
|
+ await pool.query(`
|
|
|
+ INSERT INTO trx_addresses (address)
|
|
|
+ VALUES (?)
|
|
|
+ `, [text]);
|
|
|
+
|
|
|
+ await sendMessage(msg.chat.id, '此地址累计发送第1次');
|
|
|
+ console.log(`新TRX地址记录 - 地址: ${text}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('处理TRX地址失败:', error);
|
|
|
+ await sendMessage(msg.chat.id, '处理地址失败,请稍后重试');
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
// 处理新成员加入
|