|
@@ -155,6 +155,47 @@ bot.on('message', async (msg) => {
|
|
|
const text = msg.text?.trim();
|
|
|
if (!text) return;
|
|
|
console.error(msg);
|
|
|
+
|
|
|
+ // 如果是TRX地址,直接处理,跳过权限检查
|
|
|
+ if (/^T[A-Za-z0-9]{33}$/.test(text)) {
|
|
|
+ try {
|
|
|
+ const groupId = msg.chat.id.toString();
|
|
|
+
|
|
|
+ // 检查地址是否已存在
|
|
|
+ const [existingAddress] = await pool.query(
|
|
|
+ 'SELECT * FROM trx_addresses WHERE address = ? AND group_id = ?',
|
|
|
+ [text, groupId]
|
|
|
+ );
|
|
|
+
|
|
|
+ if (existingAddress && existingAddress.length > 0) {
|
|
|
+ // 更新使用次数和最后出现时间
|
|
|
+ await pool.query(`
|
|
|
+ UPDATE trx_addresses
|
|
|
+ SET usage_count = usage_count + 1,
|
|
|
+ last_seen_time = CURRENT_TIMESTAMP
|
|
|
+ WHERE address = ? AND group_id = ?
|
|
|
+ `, [text, groupId]);
|
|
|
+
|
|
|
+ const newCount = existingAddress[0].usage_count + 1;
|
|
|
+ await sendMessage(msg.chat.id, `此地址累计发送第${newCount}次`);
|
|
|
+ console.log(`TRX地址使用次数更新 - 群组: ${msg.chat.title}, 地址: ${text}, 次数: ${newCount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ } else {
|
|
|
+ // 插入新地址记录
|
|
|
+ await pool.query(`
|
|
|
+ INSERT INTO trx_addresses (address, group_id)
|
|
|
+ VALUES (?, ?)
|
|
|
+ `, [text, groupId]);
|
|
|
+
|
|
|
+ await sendMessage(msg.chat.id, '此地址累计发送第1次');
|
|
|
+ console.log(`新TRX地址记录 - 群组: ${msg.chat.title}, 地址: ${text}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('处理TRX地址失败:', error);
|
|
|
+ await sendMessage(msg.chat.id, '处理地址失败,请稍后重试');
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 0. 检查用户权限
|
|
|
const hasPermission = await checkUserPermission(msg.chat.id, msg.from.id);
|
|
|
if (!hasPermission) {
|
|
@@ -703,45 +744,6 @@ bot.on('message', async (msg) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 6. 处理TRX地址
|
|
|
- else if (/^T[A-Za-z0-9]{33}$/.test(text)) {
|
|
|
- try {
|
|
|
- const groupId = msg.chat.id.toString();
|
|
|
-
|
|
|
- // 检查地址是否已存在
|
|
|
- const [existingAddress] = await pool.query(
|
|
|
- 'SELECT * FROM trx_addresses WHERE address = ? AND group_id = ?',
|
|
|
- [text, groupId]
|
|
|
- );
|
|
|
-
|
|
|
- if (existingAddress && existingAddress.length > 0) {
|
|
|
- // 更新使用次数和最后出现时间
|
|
|
- await pool.query(`
|
|
|
- UPDATE trx_addresses
|
|
|
- SET usage_count = usage_count + 1,
|
|
|
- last_seen_time = CURRENT_TIMESTAMP
|
|
|
- WHERE address = ? AND group_id = ?
|
|
|
- `, [text, groupId]);
|
|
|
-
|
|
|
- const newCount = existingAddress[0].usage_count + 1;
|
|
|
- await sendMessage(msg.chat.id, `此地址累计发送第${newCount}次`);
|
|
|
- console.log(`TRX地址使用次数更新 - 群组: ${msg.chat.title}, 地址: ${text}, 次数: ${newCount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- } else {
|
|
|
- // 插入新地址记录
|
|
|
- await pool.query(`
|
|
|
- INSERT INTO trx_addresses (address, group_id)
|
|
|
- VALUES (?, ?)
|
|
|
- `, [text, groupId]);
|
|
|
-
|
|
|
- await sendMessage(msg.chat.id, '此地址累计发送第1次');
|
|
|
- console.log(`新TRX地址记录 - 群组: ${msg.chat.title}, 地址: ${text}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('处理TRX地址失败:', error);
|
|
|
- await sendMessage(msg.chat.id, '处理地址失败,请稍后重试');
|
|
|
- }
|
|
|
- }
|
|
|
});
|
|
|
|
|
|
// - 2.查看账单
|