diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index ac26fb9..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Paimon_Calender/__init__.py b/Paimon_Calender/__init__.py index 45bea90..f1b3edc 100644 --- a/Paimon_Calender/__init__.py +++ b/Paimon_Calender/__init__.py @@ -7,7 +7,7 @@ from nonebot.params import CommandArg from ..utils.config import config from ..utils.file_handler import load_json, save_json -from ..utils.generate import * +from .generate import * import re HELP_STR = ''' @@ -62,7 +62,7 @@ async def _(bot: Bot, event: Union[GroupMessageEvent, MessageEvent], msg: Messag fun = str(msg).strip() action = re.search(r'(?Pon|off|time|status|test)', fun) - if group_id not in config.paimon_calender_group: + if group_id not in config.paimon_calender_group or int(group_id) not in config.paimon_calender_group: await calendar.finish(f"尚未在群 {group_id} 开启本功能!", at_sender=True) if not fun: diff --git a/utils/draw.py b/Paimon_Calender/draw.py similarity index 100% rename from utils/draw.py rename to Paimon_Calender/draw.py diff --git a/utils/event.py b/Paimon_Calender/event.py similarity index 99% rename from utils/event.py rename to Paimon_Calender/event.py index 61e8293..78bc841 100644 --- a/utils/event.py +++ b/Paimon_Calender/event.py @@ -1,9 +1,6 @@ -import os -import json from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta -from .aiorequests import get -import aiohttp +from utils.aiorequests import get import asyncio import math import functools diff --git a/utils/generate.py b/Paimon_Calender/generate.py similarity index 99% rename from utils/generate.py rename to Paimon_Calender/generate.py index 6699fe9..fc8a91a 100644 --- a/utils/generate.py +++ b/Paimon_Calender/generate.py @@ -1,4 +1,3 @@ - import base64 from io import BytesIO from .event import * diff --git a/Paimon_Chat/__init__.py b/Paimon_Chat/__init__.py index 6bf5721..2d55894 100644 --- a/Paimon_Chat/__init__.py +++ b/Paimon_Chat/__init__.py @@ -11,6 +11,13 @@ from utils.config import config from utils.auth_util import FreqLimiter2 from utils.message_util import MessageBuild from utils.file_handler import load_json_from_url +if config.paimon_mongodb_url: + try: + from .Learning_repeate import main + except ImportError: + logger.info('派蒙机器学习聊天启用失败,可能是mongodb连接失败或缺少相关库') +else: + logger.info('派蒙机器学习聊天启用失败,mongodb尚未配置') driver = get_driver() diff --git a/README.md b/README.md index 401063b..ba0673e 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,12 @@ - 修复可能因ssl证书导致的静态资源下载问题 + 5.23 - 新增`xx原魔图鉴` ++ 5.25 + - `ys、ysc、ysa、sy`等和`wiki`模块指令可以对话式查询 ++ 5.27 + - 新增`原神日历`[@nicklly](https://github.com/nicklly),需在`.env.*`配置`paimon_calender_group=[开启群号]` ++ 5.28 + - `Paimon_Chat`聊天新增`学习群友发言`(魔改自[Pallas-Bot](https://github.com/InvoluteHell/Pallas-Bot/tree/master/src/plugins/repeater)),需安装`jieba_fast、pymongo、pypinyin依赖库`、`mongodb数据库`且在`.env.*`配置文件中添加mongodb连接参数`paimon_mongodb_url`,例如`paimon_mongodb_url=mongodb://localhost:27017/` ## 丨功能列表 @@ -128,10 +134,11 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); - [NoneBot2](https://github.com/nonebot/nonebot2) - 跨平台异步机器人框架 - [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) - Onebot标准的框架实现 -- [西北一枝花](https://github.com/Nwflower) - 部分图片的美工大大和武器攻略图提供 -- [egenshin](https://github.com/pcrbot/erinilis-modules/tree/master/egenshin) - 参考了它的代码和资源 +- [西北一枝花](https://github.com/Nwflower) - 美工大大和武器攻略图提供 +- [egenshin](https://github.com/pcrbot/erinilis-modules/tree/master/egenshin) - 抽卡和猜语音代码、资源参考 - [bluemushoom](https://bbs.nga.cn/nuke.php?func=ucp&uid=62861898) - 全角色收益曲线和参考面板攻略图来源 -- [genshin-gacha-export](https://github.com/sunfkny/genshin-gacha-export) - 抽卡记录导出参考 +- [genshin-gacha-export](https://github.com/sunfkny/genshin-gacha-export) - 抽卡记录导出代码参考 +- [Pallas-Bot](https://github.com/InvoluteHell/Pallas-Bot/tree/master/src/plugins/repeater) - 群聊记录发言学习代码参考 - [西风驿站](https://bbs.mihoyo.com/ys/collection/307224) - 角色攻略一图流来源 - [游创工坊](https://space.bilibili.com/176858937) - 深渊排行榜数据来源 @@ -139,15 +146,15 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); - 如果本项目对你有帮助,给个star~~求求啦 - 部分资源使用了云存储,如果想赞助流量费用,欢迎来[爱发电](https://afdian.net/@cherishmoon),十分感谢! -### 赞助支持 - -十分感谢! - -| 赞助者 | 金额 | 日期 | -| ------- | ---- | ---- | -| 深海 | 10 | 5.20 | -| 夜空koi | 30 | 5.22 | -| 情话 | 20 | 5.23 | +| 赞助者 | 金额 | +| --------------- | ---- | +| 深海 | 10 | +| 夜空koi | 30 | +| 情话 | 20 | +| 爱发电用户_Mfms | 15 | +| 米特建木 | 10 | +| 永远的皇珈骑士 | 30 | +| 小兔和鹿 | 30 | ## 丨其他 diff --git a/utils/config.py b/utils/config.py index 67d985f..a5930ec 100644 --- a/utils/config.py +++ b/utils/config.py @@ -33,11 +33,38 @@ class PluginConfig(BaseModel): paimon_add_group: bool = False # 派蒙聊天开启群组 paimon_chat_group: List[int] = [] + # 派蒙猜语音持续时间 paimon_guess_voice: int = 30 # 原神日历开启群组 paimon_calender_group: List[int] = [] + # 以下为机器学习聊天模块配置 + # mongodb数据库连接url + paimon_mongodb_url: str = None + # 派蒙聊天屏蔽用户 + paimon_chat_ban: List[int] = [] + # 派蒙聊天学习阈值,越小学习越快 + paimon_answer_threshold: int = 3 + # 派蒙聊天上限阈值 + paimon_answer_limit_threshold: int = 25 + # N个群有相同的回复,就跨群作为全局回复 + paimon_cross_group_threshold: int = 2 + # 复读的阈值 + paimon_repeat_threshold: int = 3 + # 主动发言阈值,越小话越多 + paimon_speak_threshold: int = 3 + # 喝醉的概率 + paimon_drunk_probability: float = 0.07 + # 用文字转语音来回复的概率 + paimon_voice_probability: float = 0.03 + # 连续主动说话的概率 + paimon_speak_continuously_probability: float = 0.5 + # 主动说话加上随机戳一戳群友的概率 + paimon_speak_poke_probability: float = 0.5 + # 连续主动说话最多几句话 + paimon_speak_continuously_max_len: int = 3 + driver = get_driver() global_config = driver.config diff --git a/utils/db_util.py b/utils/db_util.py index 7612874..e2b9598 100644 --- a/utils/db_util.py +++ b/utils/db_util.py @@ -1,8 +1,5 @@ import sqlite3 -import json import os -import re -from nonebot import logger from datetime import datetime db_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'user_data', 'user_data.db') @@ -32,31 +29,31 @@ def init_db(): mys_id TEXT, last_time datetime );''') - try: - with open(os.path.join(os.path.dirname(__file__), 'user_data', 'user_cookies.json'), 'r', - encoding='utf-8') as f: - data = json.load(f) - for d in data['私人'].items(): - for c in d[1]['cookies']: - match = re.search(r'account_id=(\d{6,12})', c['cookie']) - mys_id = match.group(1) if match else '' - cursor.execute('INSERT INTO private_cookies (user_id, uid, mys_id, cookie) VALUES (?, ?, ?, ?);', - (d[0], c['uid'], mys_id, c['cookie'])) - cursor.execute('INSERT INTO last_query (user_id, uid, last_time) VALUES (?, ?, ?);', - (d[0], d[1]['last_query'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) - cursor.execute('''CREATE TABLE IF NOT EXISTS public_cookies ( - no int IDENTITY(1,1) PRIMARY KEY, - cookie TEXT, - status TEXT);''') - for d in data['通用']: - if d['cookie']: - try: - cursor.execute('INSERT INTO public_cookies VALUES (?, ?, "OK");', (d['no'], d['cookie'])) - except: - pass - logger.info('---派蒙初始化数据库成功,已导入原json数据---') - except: - logger.error('---派蒙初始化数据库失败,请检查user_cookies.json文件是否存在---') + # try: + # with open(os.path.join(os.path.dirname(__file__), 'user_data', 'user_cookies.json'), 'r', + # encoding='utf-8') as f: + # data = json.load(f) + # for d in data['私人'].items(): + # for c in d[1]['cookies']: + # match = re.search(r'account_id=(\d{6,12})', c['cookie']) + # mys_id = match.group(1) if match else '' + # cursor.execute('INSERT INTO private_cookies (user_id, uid, mys_id, cookie) VALUES (?, ?, ?, ?);', + # (d[0], c['uid'], mys_id, c['cookie'])) + # cursor.execute('INSERT INTO last_query (user_id, uid, last_time) VALUES (?, ?, ?);', + # (d[0], d[1]['last_query'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + # cursor.execute('''CREATE TABLE IF NOT EXISTS public_cookies ( + # no int IDENTITY(1,1) PRIMARY KEY, + # cookie TEXT, + # status TEXT);''') + # for d in data['通用']: + # if d['cookie']: + # try: + # cursor.execute('INSERT INTO public_cookies VALUES (?, ?, "OK");', (d['no'], d['cookie'])) + # except: + # pass + # logger.info('---派蒙初始化数据库成功,已导入原json数据---') + # except: + # logger.error('---派蒙初始化数据库失败,请检查user_cookies.json文件是否存在---') conn.commit() conn.close()