diff options
-rw-r--r-- | AyaBot/config.py | 68 | ||||
-rw-r--r-- | AyaBot/plugins/__pycache__/chat.cpython-37.pyc | bin | 0 -> 2726 bytes | |||
-rw-r--r-- | AyaBot/plugins/__pycache__/covid19.cpython-37.pyc | bin | 2252 -> 2291 bytes | |||
-rw-r--r-- | AyaBot/plugins/__pycache__/other.cpython-37.pyc | bin | 1953 -> 2498 bytes | |||
-rw-r--r-- | AyaBot/plugins/__pycache__/setu.cpython-37.pyc | bin | 3586 -> 3596 bytes | |||
-rw-r--r-- | AyaBot/plugins/__pycache__/translate.cpython-37.pyc | bin | 1756 -> 1795 bytes | |||
-rw-r--r-- | AyaBot/plugins/__pycache__/weather.cpython-37.pyc | bin | 6213 -> 6252 bytes | |||
-rw-r--r-- | AyaBot/plugins/chat.py | 80 | ||||
-rw-r--r-- | AyaBot/plugins/setu.py | 8 | ||||
-rw-r--r-- | run.py | 31 |
10 files changed, 178 insertions, 9 deletions
diff --git a/AyaBot/config.py b/AyaBot/config.py index a51b6e7..8ec3cfe 100644 --- a/AyaBot/config.py +++ b/AyaBot/config.py @@ -1,4 +1,5 @@ # -*- coding:utf-8 -*- +import time from nonebot.default_config import * #配置监听的 IP 和端口 @@ -6,13 +7,72 @@ HOST = '127.0.0.1' PORT = 8080 #咱的主人(QQ号) -SUPERUSERS = {1172294279} +SUPERUSERS = {} #机器人赋名,替代@ -NICKNAME = {'喵内', 'rbq', 'Aya'} +NICKNAME = {} #自定义命令开头 -COMMAND_START = {'', '/', '!', '/', '!'} +COMMAND_START = {} #推送屏蔽群名单 -bangroup = []
\ No newline at end of file +bangroup = [] + +#LOLICONAPI url:https://api.lolicon.app/#/setu +LOLICONAPI = "" + +#腾讯ai url:https://ai.qq.com/ +TX_APP_ID = "" +TX_APPKEY = "" + + + + + + + + + + + + + + + + +#判定 请勿更改! +print("正在导入吾辈最最最重要的记忆......") +if SUPERUSERS: + print("吾辈的主人已加载!") +else: + print("吾辈没找到主人...如需帮助,请查看安装手册") + +if NICKNAME: + print("吾辈的称呼已加载!") +else: + print("吾辈忘记自己叫啥惹...如需帮助,请查看安装手册") + +if COMMAND_START: + print("呼叫吾辈的特别小工具已加载!") +else: + print("吾辈无法找到呼唤咱的特别小工具...如需帮助,请查看安装手册") + +if bangroup: + print("屏蔽群发的群已加载!") +else: + print("主人似乎没给咱指定不需要接受群发的群号呢...那吾辈就可以更全面地进行推送了w") + +if LOLICONAPI: + print("涩图key已加载!") +else: + print("吾辈似乎没给咱打开涩图大门的钥匙呢...如需帮助,请查看安装手册") + +if TX_APP_ID: + print("吾辈的腾讯识别码已加载!") +else: + print("吾辈没法找到自己的腾讯识别码呢...如需帮助,请查看安装手册") + +if TX_APPKEY: + print("吾辈的腾讯key已加载!") +else: + print("主人似乎没给咱腾讯key呢...如需帮助,请查看安装手册")
\ No newline at end of file diff --git a/AyaBot/plugins/__pycache__/chat.cpython-37.pyc b/AyaBot/plugins/__pycache__/chat.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..ad1818d --- /dev/null +++ b/AyaBot/plugins/__pycache__/chat.cpython-37.pyc diff --git a/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc b/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc Binary files differindex 7524c7d..f1a5940 100644 --- a/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc +++ b/AyaBot/plugins/__pycache__/covid19.cpython-37.pyc diff --git a/AyaBot/plugins/__pycache__/other.cpython-37.pyc b/AyaBot/plugins/__pycache__/other.cpython-37.pyc Binary files differindex 1b4d258..9934055 100644 --- a/AyaBot/plugins/__pycache__/other.cpython-37.pyc +++ b/AyaBot/plugins/__pycache__/other.cpython-37.pyc diff --git a/AyaBot/plugins/__pycache__/setu.cpython-37.pyc b/AyaBot/plugins/__pycache__/setu.cpython-37.pyc Binary files differindex 66e8215..1bca92b 100644 --- a/AyaBot/plugins/__pycache__/setu.cpython-37.pyc +++ b/AyaBot/plugins/__pycache__/setu.cpython-37.pyc diff --git a/AyaBot/plugins/__pycache__/translate.cpython-37.pyc b/AyaBot/plugins/__pycache__/translate.cpython-37.pyc Binary files differindex 42462a8..17bf117 100644 --- a/AyaBot/plugins/__pycache__/translate.cpython-37.pyc +++ b/AyaBot/plugins/__pycache__/translate.cpython-37.pyc diff --git a/AyaBot/plugins/__pycache__/weather.cpython-37.pyc b/AyaBot/plugins/__pycache__/weather.cpython-37.pyc Binary files differindex 02ebb2f..b931e84 100644 --- a/AyaBot/plugins/__pycache__/weather.cpython-37.pyc +++ b/AyaBot/plugins/__pycache__/weather.cpython-37.pyc diff --git a/AyaBot/plugins/chat.py b/AyaBot/plugins/chat.py new file mode 100644 index 0000000..38a4759 --- /dev/null +++ b/AyaBot/plugins/chat.py @@ -0,0 +1,80 @@ +# -*- coding:utf-8 -*- +import time +import httpx +import string +import nonebot +import hashlib +from AyaBot.plugins import * +from random import randint +from urllib.parse import urlencode +from nonebot.helpers import context_id, render_expression +from nonebot import on_command, CommandSession, on_natural_language, NLPSession, IntentCommand + +bot = nonebot.get_bot() + +ERROR_REPLY = ( + '吾辈不是很能理解主人的意思...', + '(。´・ω・)ん?', + 'ん?', + 'あつ...脑子坏了..理解不能', + '吾辈想听主人再说一次...' +) + +class Chat(object): + URL = 'https://api.ai.qq.com/fcgi-bin/nlp/nlp_textchat' + app_id = bot.config.TX_APP_ID + app_key = bot.config.TX_APPKEY + print(app_id, app_key) + nonce_str_example = 'fa577ce340859f9fe' + ct = lambda: time.time() + + @classmethod + def get_nonce_str(self): + nonce_str = '' + len_str = string.digits + string.ascii_letters + for i in range(len(self.nonce_str_example)): + nonce_str += len_str[randint(0, len(len_str) - 1)] + return nonce_str + + @classmethod + def sign(self, req_data): + new_list = sorted(req_data.items()) + encode_list = urlencode(new_list) + req_data = encode_list + "&" + "app_key" + "=" + self.app_key + md5 = hashlib.md5() + md5.update(req_data.encode('utf-8')) + data = md5.hexdigest() + return data.upper() + + @classmethod + async def request(self, text): + req_data = { + 'app_id': self.app_id, + 'time_stamp': int(self.ct()), + 'nonce_str': self.get_nonce_str(), + 'session': 10000, + 'question': text, + } + print(req_data) + req_data['sign'] = self.sign(req_data) + req_data = sorted(req_data.items()) + requests = httpx.AsyncClient() + result = await requests.get(self.URL, params=req_data) + await requests.aclose() + result = result.json() + print(result) + if result['ret'] == 0: + return result['data']['answer'] + return render_expression(ERROR_REPLY) + + +@on_command('chat') +async def chat(session: CommandSession): + msg = session.state.get('msg') + reply = await Chat.request(msg) + await session.finish(reply) + return + +@on_natural_language +async def _(session: NLPSession): + return IntentCommand(60.0, ('chat'), {'msg': session.msg_text})
\ No newline at end of file diff --git a/AyaBot/plugins/setu.py b/AyaBot/plugins/setu.py index f0d5365..3f24129 100644 --- a/AyaBot/plugins/setu.py +++ b/AyaBot/plugins/setu.py @@ -7,6 +7,7 @@ import requests from aiohttp import ClientSession from nonebot import on_command, CommandSession +bot = nonebot.get_bot() async def post_bytes(url, headers=None,data=None): async with ClientSession() as asyncsession: @@ -62,8 +63,9 @@ async def _(session: CommandSession): await session.send(f'[CQ:image,file={pt}]') if r == '2': url = 'https://api.lolicon.app/setu/' + apikey = bot.config.LOLICONAPI values = { - "apikey": "574300555ee56eb2be5e03", + "apikey": apikey, "r18": "0", "num": "1" } @@ -78,7 +80,7 @@ async def _(session: CommandSession): # if r == '2': # URL = 'https://danbooru.donmai.us/post.json' # values = { - # "api_key": "UoTNRNeta73tqqdGVvsU9mmH" + # "api_key": "" # } # response = requests.get(URL, params=values) # html = response.text @@ -89,7 +91,7 @@ async def _(session: CommandSession): # if r == '3': # URL = 'https://yande.re/post.json' # values = { - # "api_key": "zgBbal8sZVuRYp3UNX5Frg" + # "api_key": "" # } # response = requests.get(URL, params=values) # html = response.text @@ -1,11 +1,38 @@ # -*- coding:utf-8 -*- -import nonebot +import time +COPYRIGHT = ( + r""" + _____ _ ____ ____ _ + /\ / ____| | |/ __ \| _ \ | | + / \ _ _ __ _| | ___ ___ | | | | | |_) | ___ | |_ + / /\ \| | | |/ _` | | / _ \ / _ \| | | | | _ < / _ \| __| + / ____ \ |_| | (_| | |___| (_) | (_) | | |__| | |_) | (_) | |_ + /_/ \_\__, |\__,_|\_____\___/ \___/|_|\___\_\____/ \___/ \__| + __/ | + |___/ + +Copyright © 2018-2020 Kyomotoi,All Rights Reserved +Project: https://github.com/Kyomotoi/Aya +Blog: lolihub.icu +=================================================== +""" +) +print(COPYRIGHT) +time.sleep(3) + + from AyaBot import config -from AyaBot.plugins import module +time.sleep(3) +print("开始执行主程序...RCnb!") + + +time.sleep(2) from os import path +from AyaBot.plugins import module if __name__ == '__main__': + import nonebot nonebot.init(config) nonebot.load_builtin_plugins() nonebot.load_plugins( |