|
@@ -368,10 +368,12 @@ bot.on('message', async (msg) => {
|
|
|
// 处理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 = ?',
|
|
|
- [text]
|
|
|
+ 'SELECT * FROM trx_addresses WHERE address = ? AND group_id = ?',
|
|
|
+ [text, groupId]
|
|
|
);
|
|
|
|
|
|
if (existingAddress && existingAddress.length > 0) {
|
|
@@ -380,21 +382,21 @@ bot.on('message', async (msg) => {
|
|
|
UPDATE trx_addresses
|
|
|
SET usage_count = usage_count + 1,
|
|
|
last_seen_time = CURRENT_TIMESTAMP
|
|
|
- WHERE address = ?
|
|
|
- `, [text]);
|
|
|
+ WHERE address = ? AND group_id = ?
|
|
|
+ `, [text, groupId]);
|
|
|
|
|
|
const newCount = existingAddress[0].usage_count + 1;
|
|
|
await sendMessage(msg.chat.id, `此地址累计发送第${newCount}次`);
|
|
|
- console.log(`TRX地址使用次数更新 - 地址: ${text}, 次数: ${newCount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ console.log(`TRX地址使用次数更新 - 群组: ${msg.chat.title}, 地址: ${text}, 次数: ${newCount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
} else {
|
|
|
// 插入新地址记录
|
|
|
await pool.query(`
|
|
|
- INSERT INTO trx_addresses (address)
|
|
|
- VALUES (?)
|
|
|
- `, [text]);
|
|
|
+ INSERT INTO trx_addresses (address, group_id)
|
|
|
+ VALUES (?, ?)
|
|
|
+ `, [text, groupId]);
|
|
|
|
|
|
await sendMessage(msg.chat.id, '此地址累计发送第1次');
|
|
|
- console.log(`新TRX地址记录 - 地址: ${text}, 时间: ${new Date().toLocaleString()}`);
|
|
|
+ console.log(`新TRX地址记录 - 群组: ${msg.chat.title}, 地址: ${text}, 时间: ${new Date().toLocaleString()}`);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('处理TRX地址失败:', error);
|