mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
每日0点清除公共ck限制,修复小问题,更新README
This commit is contained in:
parent
0a63d80beb
commit
aaa220f918
72
README.md
72
README.md
@ -64,7 +64,42 @@
|
||||
|
||||
## 功能列表🌅
|
||||
|
||||
详见[WIKI](https://github.com/CMHopeSunshine/LittlePaimon/wiki/%E5%8A%9F%E8%83%BD%E5%88%97%E8%A1%A8),向派蒙发送`#帮助派蒙`可以查看指令列表
|
||||
详见[功能列表I](https://github.com/CMHopeSunshine/LittlePaimon/wiki/%E5%8A%9F%E8%83%BD%E5%88%97%E8%A1%A8),向派蒙发送`#帮助派蒙`可以查看指令列表。
|
||||
|
||||
## 部署方法🖥️
|
||||
|
||||
> 本项目基于HoshinoBot,可以使用HoshinoBot同样的部署方法。
|
||||
|
||||
### 手动部署
|
||||
|
||||
- [Linux](https://github.com/CMHopeSunshine/LittlePaimon/wiki/%E9%83%A8%E7%BD%B2%E6%96%B9%E6%B3%95#linux)
|
||||
- [安卓系统](https://github.com/CMHopeSunshine/LittlePaimon/wiki/%E9%83%A8%E7%BD%B2%E6%96%B9%E6%B3%95#%E5%9C%A8%E5%AE%89%E5%8D%93%E6%89%8B%E6%9C%BA%E4%B8%8A%E9%83%A8%E7%BD%B2)
|
||||
- [Windows](https://github.com/CMHopeSunshine/LittlePaimon/wiki/%E9%83%A8%E7%BD%B2%E6%96%B9%E6%B3%95#windows)
|
||||
|
||||
### Windows一键安装脚本
|
||||
|
||||
⚠️一键脚本会因计算机环境不同而可能产生各种各样的问题,出现问题请尝试手动部署
|
||||
|
||||
在你想安装的位置打开`powershell`,输入执行:
|
||||
|
||||
```powershell
|
||||
iwr "https://cdn.jsdelivr.net/gh/CMHopeSunshine/LittlePaimon@master/LittlePaimon-install.ps1" -O .\pm.ps1 ; ./pm.ps1 ; Set-Location .. ; rm pm.ps1
|
||||
```
|
||||
|
||||
安装成功后,用`powershell`运行文件夹内的`启动.ps1`来启动机器人
|
||||
|
||||
### 添加公共cookie
|
||||
|
||||
需要至少添加一条公共cookie,小派蒙才能使用查询功能。
|
||||
|
||||
登录米游社网页版,在地址栏粘贴:
|
||||
|
||||
```
|
||||
javascript:(function(){prompt(document.domain,document.cookie)})();
|
||||
```
|
||||
|
||||
复制得到的cookie,向小派蒙发送`添加公共ck`和粘贴的内容即可开始使用
|
||||
|
||||
|
||||
## 重要通知⚠️
|
||||
|
||||
@ -91,38 +126,7 @@
|
||||
- [ ] 角色练度统计
|
||||
- [ ] 派蒙戳一戳集卡
|
||||
|
||||
画大饼...
|
||||
|
||||
## 部署方法🖥️
|
||||
|
||||
> 本项目和HoshinoBot的部署方式一样,因此Linux可以参考:
|
||||
>
|
||||
> https://cn.pcrbot.com/deploy-hoshinobot-on-centos/
|
||||
|
||||
### 一键安装脚本
|
||||
|
||||
⚠️一键脚本会因计算机环境不同而可能产生各种各样的问题,出现问题请尝试参考HoshinoBot手动部署
|
||||
|
||||
#### Windows
|
||||
|
||||
在你想安装的位置打开`powershell`,输入执行:
|
||||
|
||||
```powershell
|
||||
iwr "https://cdn.jsdelivr.net/gh/CMHopeSunshine/LittlePaimon@master/LittlePaimon-install.ps1" -O .\pm.ps1 ; ./pm.ps1 ; Set-Location .. ; rm pm.ps1
|
||||
```
|
||||
|
||||
安装成功后,`powershell`运行文件夹内的`启动.ps1`来启动机器人
|
||||
完成go-cqhttp的登录后,登录米游社网页版,在地址栏粘贴:
|
||||
|
||||
```
|
||||
javascript:(function(){prompt(document.domain,document.cookie)})();
|
||||
```
|
||||
|
||||
复制得到的cookie,向机器人私聊发送`添加公共ck`和粘贴的内容即可开始使用
|
||||
|
||||
#### Linux
|
||||
|
||||
待补充...懒
|
||||
持续画大饼ing......
|
||||
|
||||
## 额外说明🗝️
|
||||
|
||||
@ -132,7 +136,7 @@ javascript:(function(){prompt(document.domain,document.cookie)})();
|
||||
|
||||
代码水平很烂,站在巨人的肩膀上努力学习ing......
|
||||
|
||||
- [HoshinoBot](https://github.com/Ice-Cirno/HoshinoBot) - 基于nonebot1的QQ-bot框架
|
||||
- [HoshinoBot](https://github.com/Ice-Cirno/HoshinoBot) - 基于nonebot的QQ-bot框架
|
||||
- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) - Onebot标准的框架实现
|
||||
- [egenshin](https://github.com/pcrbot/erinilis-modules/tree/master/egenshin) - 参考了它的抽卡代码和资源
|
||||
- [西风驿站](https://bbs.mihoyo.com/ys/collection/307224) - 角色攻略一图流来源
|
||||
|
@ -26,15 +26,15 @@ async def main(bot,ev):
|
||||
if f.isdigit() and (9 <= int(f) <=12) and len(true_floor) < 2:
|
||||
true_floor.append(int(f))
|
||||
true_floor.sort()
|
||||
# try:
|
||||
data = await get_abyss_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
abyss_card = await draw_abyss_card(data, uid, true_floor)
|
||||
await bot.send(ev, abyss_card, at_sender=True)
|
||||
# except Exception as e:
|
||||
# await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
try:
|
||||
data = await get_abyss_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
abyss_card = await draw_abyss_card(data, uid, true_floor)
|
||||
await bot.send(ev, abyss_card, at_sender=True)
|
||||
except Exception as e:
|
||||
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
|
||||
|
||||
|
||||
|
@ -15,12 +15,12 @@ sv = Service('派蒙实时便签', bundle='派蒙', help_=help_msg)
|
||||
@sv.on_prefix(('ssbq','实时便笺','实时便签'))
|
||||
async def main(bot,ev):
|
||||
uid, msg, user_id, use_cache = await get_uid_in_msg(ev)
|
||||
# try:
|
||||
data = await get_daily_note_data(uid)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
daily_note_card = await draw_daily_note_card(data, uid)
|
||||
await bot.send(ev, daily_note_card, at_sender=True)
|
||||
# except Exception as e:
|
||||
# await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
try:
|
||||
data = await get_daily_note_data(uid)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
daily_note_card = await draw_daily_note_card(data, uid)
|
||||
await bot.send(ev, daily_note_card, at_sender=True)
|
||||
except Exception as e:
|
||||
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
|
@ -104,7 +104,7 @@ async def insert_public_cookie(cookie):
|
||||
cookie TEXT,
|
||||
status TEXT,
|
||||
);''')
|
||||
cursor.execute('INSERT IGNORE INTO public_cookies (cookie, status) VALUES (?,"ok");', (cookie,))
|
||||
cursor.execute('INSERT IGNORE INTO public_cookies (cookie, status) VALUES (?,"OK");', (cookie,))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@ -120,6 +120,18 @@ async def limit_public_cookie(cookie):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# 清除公共cookie上限
|
||||
async def reset_public_cookie():
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS public_cookies(
|
||||
no int PRIMARY KEY
|
||||
cookie TEXT,
|
||||
status TEXT);''')
|
||||
cursor.execute('UPDATE public_cookies SET status="OK" WHERE status="limited30";')
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# 通过key(如user_id, uid)获取私人cookie
|
||||
async def get_private_cookie(value, key='user_id'):
|
||||
conn = sqlite3.connect(db_path)
|
||||
|
@ -26,12 +26,12 @@ async def main(bot,ev):
|
||||
find_month = '(?P<month>' + '|'.join(month_list) + ')'
|
||||
match = re.search(find_month, msg)
|
||||
month = match.group('month') if match else month_now
|
||||
# try:
|
||||
data = await get_monthinfo_data(uid, month, use_cache=use_cache)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
monthinfo_card = await draw_monthinfo_card(data)
|
||||
await bot.send(ev, monthinfo_card, at_sender=True)
|
||||
# except Exception as e:
|
||||
# await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
try:
|
||||
data = await get_monthinfo_data(uid, month, use_cache=use_cache)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
monthinfo_card = await draw_monthinfo_card(data)
|
||||
await bot.send(ev, monthinfo_card, at_sender=True)
|
||||
except Exception as e:
|
||||
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
|
@ -21,22 +21,22 @@ async def player_card(bot,ev):
|
||||
if not uid:
|
||||
await bot.send(ev,'请把正确的uid给派蒙哦,例如sy100123456!',at_sender=True)
|
||||
return
|
||||
# try:
|
||||
data = await get_player_card_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
if ev.message_type == 'group':
|
||||
user_info = await bot.get_group_member_info(group_id=ev.group_id,user_id=int(user_id))
|
||||
nickname = user_info['card'] or user_info['nickname']
|
||||
try:
|
||||
data = await get_player_card_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(data, str):
|
||||
await bot.send(ev, data, at_sender=True)
|
||||
else:
|
||||
nickname = ev.sender['nickname']
|
||||
chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache)
|
||||
chara_data = None if isinstance(chara_data, str) else chara_data
|
||||
player_card = await draw_player_card(data, chara_data, uid, nickname)
|
||||
await bot.send(ev, player_card, at_sender=True)
|
||||
# except Exception as e:
|
||||
# await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
if ev.message_type == 'group':
|
||||
user_info = await bot.get_group_member_info(group_id=ev.group_id,user_id=int(user_id))
|
||||
nickname = user_info['card'] or user_info['nickname']
|
||||
else:
|
||||
nickname = ev.sender['nickname']
|
||||
chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache)
|
||||
chara_data = None if isinstance(chara_data, str) else chara_data
|
||||
player_card = await draw_player_card(data, chara_data, uid, nickname)
|
||||
await bot.send(ev, player_card, at_sender=True)
|
||||
except Exception as e:
|
||||
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
|
||||
@sv.on_prefix('ysa')
|
||||
async def all_characters(bot,ev):
|
||||
@ -44,15 +44,15 @@ async def all_characters(bot,ev):
|
||||
if not uid:
|
||||
await bot.send(ev,'请把正确的uid给派蒙哦,例如sy100123456!',at_sender=True)
|
||||
return
|
||||
# try:
|
||||
chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(chara_data, str):
|
||||
await bot.send(ev, chara_data, at_sender=True)
|
||||
else:
|
||||
player_card = await draw_all_chara_card(chara_data, uid)
|
||||
await bot.send(ev, player_card, at_sender=True)
|
||||
# except Exception as e:
|
||||
# await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
try:
|
||||
chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(chara_data, str):
|
||||
await bot.send(ev, chara_data, at_sender=True)
|
||||
else:
|
||||
player_card = await draw_all_chara_card(chara_data, uid)
|
||||
await bot.send(ev, player_card, at_sender=True)
|
||||
except Exception as e:
|
||||
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
|
||||
@sv.on_prefix('ysc')
|
||||
async def my_characters(bot,ev):
|
||||
@ -68,14 +68,14 @@ async def my_characters(bot,ev):
|
||||
if not chara_name:
|
||||
await bot.send(ev,f'没有角色名叫{filt_message(chara)}哦!',at_sender=True)
|
||||
return
|
||||
# try:
|
||||
chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(chara_data, str):
|
||||
await bot.send(ev, chara_data, at_sender=True)
|
||||
else:
|
||||
skill_data = await get_chara_skill_data(uid, chara_name[0], use_cache=use_cache)
|
||||
chara_card = await draw_chara_card(chara_data, skill_data, chara_name, uid)
|
||||
await bot.send(ev, chara_card, at_sender=True)
|
||||
# except Exception as e:
|
||||
# await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
try:
|
||||
chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache)
|
||||
if isinstance(chara_data, str):
|
||||
await bot.send(ev, chara_data, at_sender=True)
|
||||
else:
|
||||
skill_data = await get_chara_skill_data(uid, chara_name[0], use_cache=use_cache)
|
||||
chara_card = await draw_chara_card(chara_data, skill_data, chara_name, uid)
|
||||
await bot.send(ev, chara_card, at_sender=True)
|
||||
except Exception as e:
|
||||
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
|
||||
|
||||
|
@ -2,7 +2,7 @@ from hoshino import MessageSegment, Service, trigger, priv, CanceledException,lo
|
||||
from hoshino.typing import CQEvent, Message
|
||||
from nonebot import message_preprocessor
|
||||
from ..get_data import get_bind_game
|
||||
from ..db_util import insert_public_cookie, update_private_cookie, delete_cookie_cache, delete_cookie, delete_private_cookie
|
||||
from ..db_util import insert_public_cookie, update_private_cookie, delete_cookie_cache, delete_cookie, delete_private_cookie,update_last_query, reset_public_cookie
|
||||
from ..util import check_cookie
|
||||
|
||||
help_msg='''
|
||||
@ -35,6 +35,7 @@ async def bind(bot,ev):
|
||||
break
|
||||
if uid:
|
||||
await update_private_cookie(user_id=str(ev.user_id), uid=uid, mys_id=mys_id, cookie=cookie)
|
||||
await update_last_query(str(ev.user_id), uid, 'uid')
|
||||
await delete_cookie_cache(uid, key='uid', all=False)
|
||||
msg = f'{nickname}绑定成功啦!使用ys/ysa等指令和派蒙互动吧!'
|
||||
if ev.detail_type != 'private':
|
||||
@ -62,4 +63,6 @@ async def bing_public(bot, ev):
|
||||
@sv.scheduled_job('cron', hour='0')
|
||||
async def delete_cache():
|
||||
logger.info('---清空今日cookie缓存---')
|
||||
await delete_cookie_cache(all=True)
|
||||
await delete_cookie_cache(all=True)
|
||||
logger.info('---清空今日cookie限制记录---')
|
||||
await reset_public_cookie()
|
||||
|
@ -55,13 +55,10 @@ async def get_own_cookie(uid='', mys_id='', action=''):
|
||||
# 检查数据返回状态,10001为ck过期了,10101为达到每日30次上线了
|
||||
async def check_retcode(data, cookie, uid):
|
||||
if data['retcode'] == 10001:
|
||||
# TODO:此处为删除cookie的操作
|
||||
await delete_cookie(cookie['cookie'], cookie['type'])
|
||||
# TODO: 此处为发送cookie删除信息提醒的操作
|
||||
await send_cookie_delete_msg(cookie)
|
||||
return False
|
||||
elif data['retcode'] == 10101:
|
||||
# TODO: 此处为设置cookie到30次上限的操作
|
||||
if cookie['type'] == 'public':
|
||||
logger.info(f'{cookie["no"]}号公共cookie达到了每日30次查询上限')
|
||||
elif cookie['type'] == 'private':
|
||||
@ -69,7 +66,6 @@ async def check_retcode(data, cookie, uid):
|
||||
await limit_public_cookie(cookie['cookie'])
|
||||
return False
|
||||
else:
|
||||
# TODO: 此处为更新最后查询的操作
|
||||
await update_cookie_cache(cookie['cookie'], uid, 'uid')
|
||||
return True
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user