|
@@ -148,7 +148,7 @@ bot.on('message', async (msg) => {
|
|
|
}
|
|
|
}
|
|
|
// 处理入款修正命令
|
|
|
- else if (text.startsWith('-') && !text.includes('u')) {
|
|
|
+ else if (text.startsWith('-') && !text.includes('下发')) {
|
|
|
const amount = parseFloat(text.substring(1));
|
|
|
if (!isNaN(amount)) {
|
|
|
const transactionData = {
|
|
@@ -182,7 +182,7 @@ bot.on('message', async (msg) => {
|
|
|
}
|
|
|
}
|
|
|
// 处理回款命令
|
|
|
- else if (text.toLowerCase().includes('u')) {
|
|
|
+ else if (text.startsWith('下发')) {
|
|
|
const amount = parseFloat(text.replace(/[^0-9.-]/g, ''));
|
|
|
if (!isNaN(amount)) {
|
|
|
const transactionData = {
|
|
@@ -216,7 +216,7 @@ bot.on('message', async (msg) => {
|
|
|
}
|
|
|
}
|
|
|
// 处理回款修正命令
|
|
|
- else if (text.toLowerCase().includes('u') && text.includes('-')) {
|
|
|
+ else if (text.startsWith('下发-')) {
|
|
|
const amount = parseFloat(text.replace(/[^0-9.-]/g, ''));
|
|
|
if (!isNaN(amount)) {
|
|
|
const transactionData = {
|
|
@@ -482,90 +482,6 @@ bot.onText(/\/addgroup (.+)/, async (msg, match) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-// 处理入款命令
|
|
|
-bot.onText(/\/deposit (.+)/, async (msg, match) => {
|
|
|
- if (!isGroupAllowed(msg.chat.id)) {
|
|
|
- sendMessage(msg.chat.id, '该群组未授权使用此功能');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const amount = parseFloat(match[1]);
|
|
|
- if (isNaN(amount)) {
|
|
|
- sendMessage(msg.chat.id, '请输入有效的金额');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const transactionData = {
|
|
|
- groupId: msg.chat.id.toString(),
|
|
|
- groupName: msg.chat.title || '未命名群组',
|
|
|
- amount: amount
|
|
|
- };
|
|
|
-
|
|
|
- try {
|
|
|
- const result = await Transaction.deposit(transactionData);
|
|
|
- if (result.success) {
|
|
|
- const billMessage = await generateBillMessage(msg.chat.id);
|
|
|
- if (billMessage) {
|
|
|
- await sendMessage(msg.chat.id, billMessage, {
|
|
|
- reply_markup: generateInlineKeyboard(msg.chat.id)
|
|
|
- });
|
|
|
- console.log(`入款成功 - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- } else {
|
|
|
- await sendMessage(msg.chat.id, '入款成功,但获取账单信息失败');
|
|
|
- console.log(`入款成功(无账单) - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- }
|
|
|
- } else {
|
|
|
- await sendMessage(msg.chat.id, result.message || '入款失败');
|
|
|
- console.log(`入款失败 - 群组: ${msg.chat.title}, 金额: ${amount}, 原因: ${result.message}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error(formatLog('记录入款失败', error));
|
|
|
- await sendMessage(msg.chat.id, '记录入款失败,请稍后重试');
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
-// 处理下发命令
|
|
|
-bot.onText(/\/withdraw (.+)/, async (msg, match) => {
|
|
|
- if (!isGroupAllowed(msg.chat.id)) {
|
|
|
- sendMessage(msg.chat.id, '该群组未授权使用此功能');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const amount = parseFloat(match[1]);
|
|
|
- if (isNaN(amount)) {
|
|
|
- sendMessage(msg.chat.id, '请输入有效的金额');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const transactionData = {
|
|
|
- groupId: msg.chat.id.toString(),
|
|
|
- groupName: msg.chat.title || '未命名群组',
|
|
|
- amount: amount
|
|
|
- };
|
|
|
-
|
|
|
- try {
|
|
|
- const result = await Transaction.withdrawal(transactionData);
|
|
|
- if (result.success) {
|
|
|
- const billMessage = await generateBillMessage(msg.chat.id);
|
|
|
- if (billMessage) {
|
|
|
- await sendMessage(msg.chat.id, billMessage, {
|
|
|
- reply_markup: generateInlineKeyboard(msg.chat.id)
|
|
|
- });
|
|
|
- console.log(`出款成功 - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- } else {
|
|
|
- await sendMessage(msg.chat.id, '出款成功,但获取账单信息失败');
|
|
|
- console.log(`出款成功(无账单) - 群组: ${msg.chat.title}, 金额: ${amount}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- }
|
|
|
- } else {
|
|
|
- await sendMessage(msg.chat.id, result.message || '出款失败');
|
|
|
- console.log(`出款失败 - 群组: ${msg.chat.title}, 金额: ${amount}, 原因: ${result.message}, 时间: ${new Date().toLocaleString()}`);
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error(formatLog('记录出款失败', error));
|
|
|
- await sendMessage(msg.chat.id, '记录出款失败,请稍后重试');
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
// 处理查看账单命令
|
|
|
bot.onText(/\/bill/, async (msg) => {
|
|
|
const billMessage = await generateBillMessage(msg.chat.id);
|