Merge pull request #124 from SCUOP/nonebot2

米游币自动获取
This commit is contained in:
惜月 2022-07-19 01:22:36 -05:00 committed by GitHub
commit 5a46174323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 528 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import random
import re
from asyncio import sleep
from collections import defaultdict
from cv2 import log
from littlepaimon_utils.tools import FreqLimiter
from nonebot import on_command, require, logger, get_bot
@ -18,17 +19,17 @@ from .draw_daily_note import draw_daily_note_card
from .draw_month_info import draw_monthinfo_card
from .draw_player_card import draw_player_card, draw_all_chara_card, draw_chara_card
from .draw_role_card import draw_role_card
from .get_data import get_bind_game, get_sign_info, sign, get_sign_list, get_abyss_data, get_daily_note_data, \
from .get_data import addStoken, get_bind_game, get_sign_info, sign, get_sign_list, get_abyss_data, get_daily_note_data, \
get_enka_data
from .get_data import get_monthinfo_data, get_player_card_data, get_chara_detail_data, get_chara_skill_data
from ..utils.alias_handler import get_match_alias
from ..utils.auth_util import check_cookie
from ..utils.config import config
from ..utils.db_util import get_auto_sign, delete_auto_sign, get_last_query
from ..utils.db_util import get_auto_sign, delete_auto_sign, get_last_query, get_private_stoken, update_private_stoken,get_coin_auto_sign
from ..utils.db_util import insert_public_cookie, update_private_cookie, delete_cookie_cache, delete_private_cookie, \
update_last_query, reset_public_cookie
from ..utils.db_util import update_note_remind2, update_note_remind, get_note_remind, delete_note_remind, \
update_day_remind_count, get_private_cookie, add_auto_sign, get_all_query
update_day_remind_count, get_private_cookie, add_auto_sign, get_all_query,add_coin_auto_sign,delete_coin_auto_sign
from ..utils.decorator import exception_handler
from ..utils.enka_util import PlayerInfo
from ..utils.message_util import MessageBuild as MsgBd
@ -36,6 +37,7 @@ from ..utils.message_util import get_uid_in_msg, uid_userId_to_dict, replace_all
require('nonebot_plugin_apscheduler')
from nonebot_plugin_apscheduler import scheduler
from .get_coin import MihoyoBBSCoin
__plugin_meta__ = PluginMetadata(
name="Paimon_Info",
@ -65,6 +67,11 @@ __plugin_meta__ = PluginMetadata(
"--------\n"
"[更新角色信息 uid]更新游戏内展柜8个角色的面板信息\n"
"[ysd 角色名 uid]查看指定角色的详细面板信息\n"
"--------\n"
"[myb获取]手动进行一次米游币获取\n"
"[myb自动获取开启uid/关闭]开启米游币原神自动获取\n"
"--------\n"
"[添加stoken+stoken]添加stoken"
),
extra={
'type': '原神信息查询',
@ -139,7 +146,19 @@ role_info.__paimon_help__ = {
"introduce": "查看指定角色的详细面板信息",
"priority": 4
}
get_mys_coin = on_command('myb获取',aliases={'米游币获取','获取米游币'},priority=7,block=True)
get_mys_coin_auto = on_command('myb自动获取',aliases={'米游币自动获取','自动获取米游币'},priority=7,block=True)
get_mys_coin_auto.__paimon_help__ = {
"usage": "myb自动获取<on|off uid>",
"introduce": "自动获取米游币",
"priority": 10
}
add_stoken = on_command('添加stoken',priority=7,block=True)
add_stoken.__paimon_help__ = {
"usage": "添加stoken[stoken]",
"introduce": "添加stoken以获取米游币",
"priority": 99
}
@sy.handle()
@ys.handle()
@ -663,6 +682,36 @@ async def auto_sign():
except Exception as e:
logger.error(f'米游社签到结果发送失败:{e}')
@scheduler.scheduled_job('cron', hour=config.paimon_sign_hour, minute=config.paimon_sign_minute, misfire_grace_time=10)
async def coin_auto_sign():
data = await get_coin_auto_sign()
ann = defaultdict(lambda: defaultdict(list))
if data:
logger.info('---派蒙开始执行米游币自动获取---')
for user_id,uid,remind_id in data:
sk = await get_private_stoken(uid,key='uid')
stoken = sk[0][4]
get_coin_task = MihoyoBBSCoin(stoken)
data = await get_coin_task.task_run()
if get_coin_task.is_Right is False:
ann[remind_id]['失败'].append(f'.UID{uid}')
await delete_coin_auto_sign(user_id,uid)
else:
ann[remind_id]['成功'].append(
f'.UID{uid}获取myb成功')
for group_id, content in ann.items():
group_str = '米游社自动签到结果:\n'
for type, ann_list in content.items():
if ann_list:
group_str += f'签到{type}\n'
for u in ann_list:
group_str += str(ann_list.index(u) + 1) + u + '\n'
try:
await get_bot().send_group_msg(group_id=group_id, message=group_str)
await sleep(random.randint(3, 8))
except Exception as e:
logger.error(f'米游社签到结果发送失败:{e}')
@scheduler.scheduled_job('cron', minute=f'*/{config.paimon_check_interval}', misfire_grace_time=10)
async def check_note():
@ -753,3 +802,79 @@ async def all_update():
if failed_time > 5:
break
return '玩家信息uid更新共{}个,更新完成'.format(len(uid_list))
@get_mys_coin.handle()
@exception_handler()
async def get_mys_coin_handler(event: MessageEvent, msg: Message = CommandArg()):\
#获取UID
uid, msg, user_id, use_cache = await get_uid_in_msg(event, msg)
if not uid:
await get_mys_coin.finish('没有找到你的uid哦')
sk = await get_private_stoken(uid,key='uid')
if not sk:
await get_mys_coin.finish('请旅行者先添加cookie和stoken哦')
cookie = sk[0][1]
if not cookie:
await get_mys_coin.finish('你的该uid还没绑定cookie哦先用ysb绑定吧')
stoken = sk[0][4]
get_coin_task = MihoyoBBSCoin(stoken)
data = await get_coin_task.task_run()
msg = "米游币获取完成\n" + data
await get_mys_coin.finish(msg)
@get_mys_coin_auto.handle()
@exception_handler()
async def get_mys_coin_auto_handler(event: MessageEvent, msg: Message = CommandArg()):
if event.message_type == 'group':
remind_id = str(event.group_id)
elif event.message_type == 'private':
remind_id = 'q' + str(event.user_id)
else:
await get_mys_coin_auto.finish('米游币自动获取功能暂时不支持频道使用哦')
msg = str(msg).strip()
find_uid = re.search(r'(?P<uid>(1|2|5)\d{8})', msg)
if not find_uid:
await mys_sign_auto.finish('请把正确的需要帮忙获取的uid给派蒙哦!', at_sender=True)
else:
uid = find_uid.group('uid')
find_action = re.search(r'(?P<action>开启|启用|打开|关闭|禁用|on|off)', msg)
if find_action:
if find_action.group('action') in ['开启', '启用', '打开', 'on']:
sk= await get_private_stoken(uid, key='uid')
stoken = sk[0][4]
if not stoken:
await mys_sign_auto.finish('你的该uid还没绑定stoken哦先用添加stoken绑定吧!', at_sender=True)
await add_coin_auto_sign(str(event.user_id), uid, remind_id)
await mys_sign_auto.finish('开启米游币自动签到成功,派蒙会在每日0点帮你签到', at_sender=True)
elif find_action.group('action') in ['关闭', '禁用', 'off']:
await delete_coin_auto_sign(str(event.user_id), uid)
await mys_sign_auto.finish('关闭米游币自动签到成功', at_sender=True)
else:
await mys_sign_auto.finish('指令错误,在后面加 开启/关闭 来使用哦', at_sender=True)
@add_stoken.handle()
@exception_handler()
async def add_stoken_handler(event: MessageEvent, msg: Message = CommandArg()):
stoken = str(msg).strip()
if stoken == '':
res = '获取stoken的教程\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1\n获取到后添加派蒙好友私聊发送ysb接复制到的cookie就行啦~'
await add_stoken.finish(res, at_sender=True)
else:
uid = (await get_private_cookie(event.user_id,key='user_id'))[0][2]
stoken, mys_id, stoken_info = await addStoken(stoken,uid)
if not stoken_info and not mys_id:
await add_stoken.finish('请旅行者先使用ysb添加cookie哦~')
if not stoken_info or stoken_info['retcode'] != 0:
msg = cookie_error_msg
if event.message_type != 'private':
msg += '\n当前是在群聊里绑定,建议旅行者添加派蒙好友私聊绑定!'
await add_stoken.finish(msg, at_sender=True)
else:
if uid:
await update_private_stoken(user_id=str(event.user_id), uid=uid, mys_id=mys_id, cookie='',stoken=stoken)
await update_last_query(str(event.user_id), uid, 'uid')
msg = f'stoken绑定成功啦!'
if event.message_type != 'private':
msg += '\n当前是在群聊里绑定建议旅行者把stoken撤回哦!'
await ysb.finish(MsgBd.Text(msg), at_sender=True)

274
Paimon_Info/get_coin.py Normal file
View File

@ -0,0 +1,274 @@
import random
import string
import time
from httpx import AsyncClient
from nonebot import logger
# 米游社的API列表
bbs_Cookieurl = 'https://webapi.account.mihoyo.com/Api/cookie_accountinfo_by_loginticket?login_ticket={}'
bbs_Cookieurl2 = 'https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?' \
'login_ticket={}&token_types=3&uid={}'
bbs_Taskslist = 'https://bbs-api.mihoyo.com/apihub/sapi/getUserMissionsState' # 获取任务列表
bbs_Signurl = 'https://bbs-api.mihoyo.com/apihub/sapi/signIn?gids={}' # post
bbs_Listurl = 'https://bbs-api.mihoyo.com/post/api/getForumPostList?' \
'forum_id={}&is_good=false&is_hot=false&page_size=20&sort_type=1'
bbs_Detailurl = 'https://bbs-api.mihoyo.com/post/api/getPostFull?post_id={}'
bbs_Shareurl = 'https://bbs-api.mihoyo.com/apihub/api/getShareConf?entity_id={}&entity_type=1'
bbs_Likeurl = 'https://bbs-api.mihoyo.com/apihub/sapi/upvotePost' # post json
mihoyobbs_List = [{
'id' : '1',
'forumId': '1',
'name' : '崩坏3',
'url' : 'https://bbs.mihoyo.com/bh3/'
}, {
'id' : '2',
'forumId': '26',
'name' : '原神',
'url' : 'https://bbs.mihoyo.com/ys/'
}, {
'id' : '3',
'forumId': '30',
'name' : '崩坏2',
'url' : 'https://bbs.mihoyo.com/bh2/'
}, {
'id' : '4',
'forumId': '37',
'name' : '未定事件簿',
'url' : 'https://bbs.mihoyo.com/wd/'
}, {
'id' : '5',
'forumId': '34',
'name' : '大别野',
'url' : 'https://bbs.mihoyo.com/dby/'
}, {
'id' : '6',
'forumId': '52',
'name' : '崩坏:星穹铁道',
'url' : 'https://bbs.mihoyo.com/sr/'
}]
def random_text(num: int) -> str:
return ''.join(random.sample(string.ascii_lowercase + string.digits, num))
class MihoyoBBSCoin:
def __init__(self, cookies):
self.postsList = None
self.headers = {
'DS' : old_version_get_ds_token(True),
'cookie' : cookies,
'x-rpc-client_type' : '2',
'x-rpc-app_version' : '2.7.0',
'x-rpc-sys_version' : '6.0.1',
'x-rpc-channel' : 'mihoyo',
'x-rpc-device_id' : random_hex(32),
'x-rpc-device_name' : random_text(random.randint(1, 10)),
'x-rpc-device_model': 'Mi 10',
'Referer' : 'https://app.mihoyo.com',
'Host' : 'bbs-api.mihoyo.com',
'User-Agent' : 'okhttp/4.8.0'
}
self.Task_do = {
'bbs_Sign' : False,
'bbs_Read_posts' : False,
'bbs_Read_posts_num': 3,
'bbs_Like_posts' : False,
'bbs_Like_posts_num': 5,
'bbs_Share' : False
}
self.mihoyobbs_List_Use = []
self.Today_getcoins = 0
self.Today_have_getcoins = 0 # 这个变量以后可能会用上,先留着了
self.Have_coins = 0
self.is_Right = True #判断stoken是否失效
#开始运行
async def task_run(self):
await self.load_mihoyo_bbs_list_use()
start = await self.get_tasks_list()
if self.is_Right is False:
return start
self.postsList = await self.get_list()
sign = await self.signing()
read = await self.read_posts()
like = await self.like_posts()
share = await self.share_post()
im = start + '\n' + sign + '\n' + read + '\n' + like + '\n' + share
return im
async def load_mihoyo_bbs_list_use(self):
for i in [2, 5]:
for k in mihoyobbs_List:
if i == int(k['id']):
self.mihoyobbs_List_Use.append(k)
# 获取任务列表,用来判断做了哪些任务
async def get_tasks_list(self):
logger.info('正在获取任务列表')
async with AsyncClient() as client:
req = await client.get(url=bbs_Taskslist, headers=self.headers)
data = req.json()
if 'err' in data['message'] or data['retcode'] == -100:
self.is_Right = False
logger.info('stoken或cookie失效')
return '你的Cookies或Stoken已失效。'
# log.error('获取任务列表失败你的cookie可能已过期请重新设置cookie。')
else:
self.Today_getcoins = data['data']['can_get_points']
self.Today_have_getcoins = data['data']['already_received_points']
self.Have_coins = data['data']['total_points']
# 如果当日可获取米游币数量为0直接判断全部任务都完成了
if self.Today_getcoins == 0:
self.Task_do['bbs_Sign'] = True
self.Task_do['bbs_Read_posts'] = True
self.Task_do['bbs_Like_posts'] = True
self.Task_do['bbs_Share'] = True
else:
# 如果第0个大于或等于62则直接判定任务没做
if data['data']['states'][0]['mission_id'] >= 62:
logger.info(f'新的一天,今天可以获得{self.Today_getcoins}个米游币')
pass
else:
logger.info(f'似乎还有任务没完成,今天还能获得{self.Today_getcoins}')
for i in data['data']['states']:
# 58是讨论区签到
if i['mission_id'] == 58:
if i['is_get_award']:
self.Task_do['bbs_Sign'] = True
# 59是看帖子
elif i['mission_id'] == 59:
if i['is_get_award']:
self.Task_do['bbs_Read_posts'] = True
else:
self.Task_do['bbs_Read_posts_num'] -= i['happened_times']
# 60是给帖子点赞
elif i['mission_id'] == 60:
if i['is_get_award']:
self.Task_do['bbs_Like_posts'] = True
else:
self.Task_do['bbs_Like_posts_num'] -= i['happened_times']
# 61是分享帖子
elif i['mission_id'] == 61:
if i['is_get_award']:
self.Task_do['bbs_Share'] = True
# 分享帖子,是最后一个任务,到这里了下面都是一次性任务,直接跳出循环
break
return '今日完成情况!'
# 获取要帖子列表
async def get_list(self) -> list:
temp_list = []
logger.info('正在获取帖子列表......')
async with AsyncClient() as client:
req = await client.get(url=bbs_Listurl.format(self.mihoyobbs_List_Use[0]['forumId']), headers=self.headers)
data = req.json()
for n in range(5):
temp_list.append([data['data']['list'][n]['post']['post_id'], data['data']['list'][n]['post']['subject']])
logger.info('已获取{}个帖子'.format(len(temp_list)))
return temp_list
# 进行签到操作
async def signing(self):
if self.Task_do['bbs_Sign']:
logger.info("讨论区任务已经完成过了~")
return '讨论区任务已经完成过了~'
else:
for i in self.mihoyobbs_List_Use:
async with AsyncClient() as client:
req = await client.post(url=bbs_Signurl.format(i['id']), data={}, headers=self.headers)
data = req.json()
if 'err' not in data['message']:
time.sleep(random.randint(2, 8))
else:
logger.info("cookie或stoken已失效")
return '你的Cookies已失效。'
return 'SignM:完成!'
# 看帖子
async def read_posts(self):
if self.Task_do['bbs_Read_posts']:
logger.info("看帖任务已经完成过了~'")
return '看帖任务已经完成过了~'
else:
num_ok = 0
for i in range(self.Task_do['bbs_Read_posts_num']):
async with AsyncClient() as client:
req = await client.get(url=bbs_Detailurl.format(self.postsList[i][0]), headers=self.headers)
data = req.json()
if data['message'] == 'OK':
num_ok += 1
time.sleep(random.randint(2, 8))
logger.info('ReadM:成功!Read:{}!'.format(str(num_ok)))
return 'ReadM:成功!Read:{}!'.format(str(num_ok))
# 点赞
async def like_posts(self):
if self.Task_do['bbs_Like_posts']:
logger.info('Like任务已经完成过了~')
return 'Like任务已经完成过了~'
else:
num_ok = 0
num_cancel = 0
for i in range(self.Task_do['bbs_Like_posts_num']):
async with AsyncClient() as client:
req = await client.post(url=bbs_Likeurl, headers=self.headers,
json={'post_id': self.postsList[i][0], 'is_cancel': False})
data = req.json()
if data['message'] == 'OK':
num_ok += 1
# 判断取消点赞是否打开
if True:
time.sleep(random.randint(2, 8))
async with AsyncClient() as client:
req = await client.post(url=bbs_Likeurl, headers=self.headers,
json={'post_id': self.postsList[i][0], 'is_cancel': True})
data = req.json()
if data['message'] == 'OK':
num_cancel += 1
time.sleep(random.randint(2, 8))
logger.info('LikeM:完成!like:{}dislike:{}!'.format(str(num_ok), str(num_cancel)))
return 'LikeM:完成!like:{}dislike:{}!'.format(str(num_ok), str(num_cancel))
# 分享操作
async def share_post(self):
if self.Task_do['bbs_Share']:
logger.info( '分享任务已经完成过了~')
return '分享任务已经完成过了~'
else:
for _ in range(3):
async with AsyncClient() as client:
req = await client.get(url=bbs_Shareurl.format(self.postsList[0][0]), headers=self.headers)
data = req.json()
if data['message'] == 'OK':
return 'ShareM:完成!'
else:
time.sleep(random.randint(2, 8))
time.sleep(random.randint(2, 8))
#add function
import hashlib
def md5(text):
md5_func = hashlib.md5()
md5_func.update(text.encode())
return md5_func.hexdigest()
def old_version_get_ds_token(mysbbs=False):
if mysbbs:
n = 'fd3ykrh7o1j54g581upo1tvpam0dsgtf'
else:
n = 'h8w582wxwgqvahcdkpvdhbh2w9casgfl'
i = str(int(time.time()))
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
c = md5('salt=' + n + '&t=' + i + '&r=' + r)
return i + ',' + r + ',' + c
def random_hex(length):
result = hex(random.randint(0, 16 ** length)).replace('0x', '').upper()
if len(result) < length:
result = '0' * (length - len(result)) + result
return result

View File

@ -1,13 +1,19 @@
import datetime
from distutils.log import info
import re
from asyncio import sleep
from littlepaimon_utils import aiorequests
from ..utils.auth_util import get_headers, get_sign_headers, get_use_cookie, get_own_cookie, check_retcode
from ..utils.db_util import update_cookie_cache
from ..utils.db_util import get_private_cookie, update_cookie_cache, update_private_cookie
from ..utils.decorator import cache
from httpx import AsyncClient
from nonebot import logger
o_url = 'https://api-takumi.mihoyo.com'
async def get_abyss_data(user_id, uid, schedule_type="1", use_cache=True):
server_id = "cn_qd01" if uid[0] == '5' else "cn_gf01"
@ -154,6 +160,27 @@ async def get_bind_game(cookie):
data = resp.json()
return data, uid
#添加stoken
async def addStoken(stoken,uid):
login_ticket = re.search(r'login_ticket=([0-9a-zA-Z]+)', stoken).group(0).split('=')[1]
logger.info(login_ticket)
# mys_id = re.search(r'login_uid=([0-9]+)', mes).group(0).split('=')[1]
ck = await get_private_cookie(uid,key='uid')
logger.info(ck)
if not ck:
return NULL,NULL
ck = ck[0][1]
mys_id = re.search(r'account_id=(\d*)', ck).group(0).split('=')[1]
logger.info("run1")
logger.info(mys_id)
raw_data = await get_stoken_by_login_ticket(login_ticket, mys_id)
logger.info(raw_data)
logger.info("run2")
stoken = raw_data['data']['list'][0]['token']
logger.info("run3")
s_cookies = 'stuid={};stoken={}'.format(mys_id, stoken)
logger.info(s_cookies)
return s_cookies,mys_id,raw_data
# 获取今日签到信息
async def get_sign_info(uid):
@ -237,4 +264,14 @@ async def get_enka_data(uid):
except Exception:
await sleep(1.5)
async def get_stoken_by_login_ticket(loginticket, mys_id):
async with AsyncClient() as client:
req = await client.get(
url= o_url + '/auth/api/getMultiTokenByLoginTicket',
params={
'login_ticket': loginticket,
'token_types' : '3',
'uid' : mys_id
}
)
return req.json()

View File

@ -79,6 +79,23 @@ async def get_private_cookie(value, key='user_id'):
conn.close()
return cookie
# 通过key(如user_id, uid)获取私人Stoken
async def get_private_stoken(value, key='user_id'):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS private_cookies
(
user_id TEXT NOT NULL,
uid TEXT NOT NULL,
mys_id TEXT,
cookie TEXT,
stoken TEXT,
PRIMARY KEY (user_id, uid)
);''')
cursor.execute(f'SELECT user_id, cookie, uid, mys_id,stoken FROM private_cookies WHERE {key}="{value}";')
stoken = cursor.fetchall()
conn.close()
return stoken
# 更新cookie
async def update_private_cookie(user_id, uid='', mys_id='', cookie='', stoken=''):
@ -97,6 +114,26 @@ async def update_private_cookie(user_id, uid='', mys_id='', cookie='', stoken=''
conn.commit()
conn.close()
#更新stoken
async def update_private_stoken(user_id, uid='', mys_id='', cookie='', stoken=''):
#保证cookie不被更新
ck = await get_private_cookie(uid,key='uid')
cookie = ck[0][1]
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS private_cookies
(
user_id TEXT NOT NULL,
uid TEXT NOT NULL,
mys_id TEXT,
cookie TEXT,
stoken TEXT,
PRIMARY KEY (user_id, uid)
);''')
cursor.execute('REPLACE INTO private_cookies VALUES (?, ?, ?, ?, ?);', (user_id, uid, mys_id, cookie, stoken))
conn.commit()
conn.close()
# 删除私人cookie
async def delete_private_cookie(user_id):
@ -133,7 +170,8 @@ async def get_cookie_cache(value, key='uid'):
cursor.execute('''CREATE TABLE IF NOT EXISTS cookie_cache(
uid TEXT PRIMARY KEY NOT NULL,
mys_id TEXT,
cookie TEXT);''')
cookie TEXT
stoken TEXT);''')
cursor.execute(f'SELECT cookie FROM cookie_cache WHERE {key}="{value}"')
res = cursor.fetchone()
if res:
@ -381,6 +419,51 @@ async def delete_auto_sign(user_id, uid):
conn.commit()
conn.close()
async def get_coin_auto_sign():
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS coin_bbs_sign
(
user_id TEXT NOT NULL,
uid TEXT NOT NULL,
group_id TEXT,
PRIMARY KEY (user_id, uid)
);''')
cursor.execute('SELECT user_id,uid,group_id FROM coin_bbs_sign;')
res = cursor.fetchall()
conn.close()
return res
async def add_coin_auto_sign(user_id, uid, group_id):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS coin_bbs_sign
(
user_id TEXT NOT NULL,
uid TEXT NOT NULL,
group_id TEXT,
PRIMARY KEY (user_id, uid)
);''')
cursor.execute('REPLACE INTO coin_bbs_sign VALUES (?, ?, ?);', (user_id, uid, group_id))
conn.commit()
conn.close()
async def delete_coin_auto_sign(user_id, uid):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS coin_bbs_sign
(
user_id TEXT NOT NULL,
uid TEXT NOT NULL,
group_id TEXT,
PRIMARY KEY (user_id, uid)
);''')
cursor.execute('DELETE FROM coin_bbs_sign WHERE user_id=? AND uid=?;', (user_id, uid))
conn.commit()
conn.close()
async def get_all_myb_exchange():
conn = sqlite3.connect(db_path)

View File

@ -159,8 +159,10 @@ async def get_at_target(msg):
# message预处理获取uid、干净的msg、user_id、是否缓存
async def get_uid_in_msg(event: MessageEvent, msg: Message):
msg = str(msg).strip()
logger.info(msg)
if not msg:
uid = await get_last_query(str(event.user_id))
logger.info(uid)
return uid, '', str(event.user_id), True
user_id = await get_at_target(event.message) or str(event.user_id)
msg = re.sub(r'\[CQ.*?\]', '', msg)