summaryrefslogtreecommitdiff
path: root/ATRI
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI')
-rw-r--r--ATRI/modules/b64/__init__.py3
-rw-r--r--ATRI/modules/google_translate/__init__.py3
-rw-r--r--ATRI/plugins/bilibili.py108
-rw-r--r--ATRI/plugins/chat.py20
-rw-r--r--ATRI/plugins/hitokoto.py2
-rw-r--r--ATRI/plugins/other.py73
-rw-r--r--ATRI/plugins/pixiv.py6
-rw-r--r--ATRI/plugins/setu.py1
-rw-r--r--ATRI/plugins/switch.py4
9 files changed, 37 insertions, 183 deletions
diff --git a/ATRI/modules/b64/__init__.py b/ATRI/modules/b64/__init__.py
index 2c800a0..cb5387a 100644
--- a/ATRI/modules/b64/__init__.py
+++ b/ATRI/modules/b64/__init__.py
@@ -1,9 +1,6 @@
import os
-import time
import base64
-import requests
from pathlib import Path
-from PIL import Image, ImageGrab
path_emoji = Path('.') / 'ATRI' / 'data' / 'emoji'
diff --git a/ATRI/modules/google_translate/__init__.py b/ATRI/modules/google_translate/__init__.py
index ef0428a..c42b774 100644
--- a/ATRI/modules/google_translate/__init__.py
+++ b/ATRI/modules/google_translate/__init__.py
@@ -1,9 +1,6 @@
-# -*- coding:utf-8 -*-
import re
import requests
import demjson
-from pprint import pformat, pprint
-from urllib.parse import urlencode
def int_overflow(val):
diff --git a/ATRI/plugins/bilibili.py b/ATRI/plugins/bilibili.py
deleted file mode 100644
index e415048..0000000
--- a/ATRI/plugins/bilibili.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# -*- coding:utf-8 -*-
-import json
-import nonebot
-from orjson import loads
-from html import unescape
-import aiocqhttp
-
-from nonebot import on_command, CommandSession
-
-from ATRI.modules import response # type: ignore
-
-
-REPORT_FORMAT = """({aid})信息如下:
-Title: {title}
-aid: {aid}
-bid: {bid}
-观看: {view} 点赞: {like}
-投币: {coin} 转发: {share}
-观看链接:
-{aid_link}
-{bid_link}"""
-
-
-table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
-tr={}
-for i in range(58):
- tr[table[i]]=i
-s=[11,10,3,8,4,6]
-xor=177451812
-add=8728348608
-
-def dec(x):
- r=0
- for i in range(6):
- r+=tr[x[s[i]]]*58**i
- return (r-add)^xor
-
-def enc(x):
- x=(x^xor)+add
- r=list('BV1 4 1 7 ')
- for i in range(6):
- r[s[i]]=table[x//58**i%58]
- return ''.join(r)
-
-
-def check(string, sub_str):
- if (string.find(sub_str) == -1):
- ch = 0
- return ch
- else:
- ch = 1
- return ch
-
-
[email protected]_natural_language(only_to_me = False, only_short_message = False)
-async def fk_tx_app_bilibili(session: nonebot.NLPSession):
- rich_message = [x for x in session.event['message'] if x.get('type') == 'rich']
-
- if not rich_message:
- return
-
- rich_message = rich_message[0]['data']
- print(rich_message)
-
- xch = '小程序'
- bili = '哔哩哔哩'
- if check(rich_message['text'], xch) == 0:
- return
- if check(rich_message['text'], bili) == 0:
- return
-
- print(rich_message['text'])
-
- rich_message = rich_message['content']
- data = loads(unescape(rich_message))
-
- if 'detail_1' not in str(rich_message):
- return
-
- URL = data['detail_1']['qqdocurl']
- rep = URL.replace('?', '/')
- rep = rep.split('/')
- biv = rep[4]
-
- aid = str(dec(biv))
-
- url = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'
- ad = 'av' + aid
-
- dc = json.loads(response.request_api(url))
-
- pic = dc["data"]["pic"]
-
- await session.send(REPORT_FORMAT.format(
- title = dc["data"]["title"],
-
- view = dc["data"]["stat"]["view"],
- coin = dc["data"]["stat"]["coin"],
- share = dc["data"]["stat"]["share"],
- like = dc["data"]["stat"]["like"],
-
- bid = biv,
- bid_link = dc["data"]["short_link"],
-
- aid = ad,
- aid_link = f'https://b23.tv/{ad}'
- )
- ) \ No newline at end of file
diff --git a/ATRI/plugins/chat.py b/ATRI/plugins/chat.py
index 1adee0f..0161768 100644
--- a/ATRI/plugins/chat.py
+++ b/ATRI/plugins/chat.py
@@ -17,7 +17,7 @@ bot = nonebot.get_bot()
hour = 7
)
async def _():
- '''早安'''
+ """早安"""
try:
group_list = await bot.get_group_list() #type: ignore
groups = [group['group_id'] for group in group_list]
@@ -55,7 +55,7 @@ async def _():
hour = 22
)
async def _():
- '''晚安'''
+ """晚安"""
try:
group_list = await bot.get_group_list() #type: ignore
groups = [group['group_id'] for group in group_list]
@@ -97,7 +97,7 @@ def now_time():
@on_command('morning', patterns = [r"早[安哇]|早上好|ohayo|哦哈哟|お早う"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if 5.5 <= now_time() < 9:
await session.send(
choice(
@@ -166,7 +166,7 @@ async def _(session: CommandSession):
@on_command('night', patterns = [r"晚安|oyasuminasai|おやすみなさい"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if 5.5 <= now_time() < 11:
await session.send(
choice(
@@ -267,7 +267,7 @@ async def az(session: CommandSession):
@on_command('wenhao', patterns = [r"'?'|?"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
res = randint(1,3)
if res == 1:
res = randint(1,5)
@@ -291,7 +291,7 @@ async def az(session: CommandSession):
await session.send(f'[CQ:image,file=file:///{img}]')
@on_command('yn', patterns = [r"是[吗]|是否"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if randint(1,3) == 1:
img = choice(
[
@@ -305,7 +305,7 @@ async def az(session: CommandSession):
@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|2b"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if randint(1,2) == 1:
if randint(1,2) == 1:
img = choice(
@@ -329,7 +329,7 @@ async def az(session: CommandSession):
await session.send('火箭拳——————————————————————————!!!')
@on_command('ciallo', patterns = [r"[Cc][iI][aA][lL][lL][oO]"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if randint(1,2) == 1:
res = randint(1,2)
if res == 1:
@@ -346,7 +346,7 @@ async def az(session: CommandSession):
await session.send('Ciallo~(∠・ω< )⌒★')
@on_command('ne', patterns = [r"呐|ねえ|口内"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if randint(1,3) == 1:
await session.send(
choice(
@@ -357,7 +357,7 @@ async def az(session: CommandSession):
)
@on_command('kani', patterns = [r"螃蟹|🦀|カニ|[kK]ani"], only_to_me = False)
-async def az(session: CommandSession):
+async def _(session: CommandSession):
if random.randint(1,2) == 1:
img = choice(
[
diff --git a/ATRI/plugins/hitokoto.py b/ATRI/plugins/hitokoto.py
index 36a5f33..fdc58c0 100644
--- a/ATRI/plugins/hitokoto.py
+++ b/ATRI/plugins/hitokoto.py
@@ -5,7 +5,7 @@ from nonebot import NLPSession, NLPResult
from ATRI.modules import response # type: ignore
-url = f'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source='
+url = 'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source='
HITOKOTO_REPLY = """{hitokoto}
diff --git a/ATRI/plugins/other.py b/ATRI/plugins/other.py
index 457381d..d1a105c 100644
--- a/ATRI/plugins/other.py
+++ b/ATRI/plugins/other.py
@@ -57,14 +57,7 @@ MENU_AND = '''
'''.strip()
-# 论如何将 Python 写出 Java 的味道
-# 接下来给各位展示一下
-# 咱的屎山
-
-@on_command(
- '抽签',
- only_to_me = False
-)
+@on_command('抽签', only_to_me = False)
async def _(session: CommandSession):
await session.send(
str(
@@ -85,14 +78,7 @@ async def _(session: CommandSession):
)
)
-@on_command(
- '掷骰子',
- aliases = [
- '扔骰子',
- '骰子'
- ],
- only_to_me = False
-)
+@on_command('掷骰子', aliases = ['扔骰子', '骰子'], only_to_me = False)
async def _(session: CommandSession):
await session.send(
str(
@@ -102,66 +88,49 @@ async def _(session: CommandSession):
)
)
-@on_command(
- '关于',
- aliases = [
- '关于机器人'
- ],
- only_to_me = False
-)
+@on_command('关于', aliases = ['关于机器人'], only_to_me = False)
async def _(session: CommandSession):
await session.send(
- f"""想了解ATRI嘛
+ """想了解ATRI嘛
写出咱的是Kyomotoi
他的主页:https://blog.lolihub.icu/
项目地址:https://github.com/Kyomotoi/ATRI
欢迎star~w!"""
)
-@on_command(
- 'help',
- aliases = [
- '帮助',
- '如何使用ATRI',
- '机器人帮助'
- ],
- only_to_me = False
-)
+@on_command('help', aliases = ['帮助', '如何使用ATRI', '机器人帮助'], only_to_me = False)
async def _(session: CommandSession):
await session.send(
f"""{render_expression(HELP_REPLY)}
发送:菜单
或看这吧!
https://blog.lolihub.icu/#/ATRI/user"""
- )
+ )
-@on_command(
- 'menu',
- aliases = [
- '菜单'
- ],
- only_to_me = False
-)
+@on_command('menu', aliases = ['菜单'], only_to_me = False)
async def _(session: CommandSession):
await session.send(MENU_REPO)
time.sleep(0.5)
await session.send(MENU_AND)
-@on_command(
- 'report',
- aliases = [
- '来杯红茶'
- ],
- only_to_me = True
-)
+@on_command('report', aliases = ['来杯红茶'], only_to_me = True)
async def _(session: CommandSession):
+ h_type = session.event.detail_type
msg = session.current_arg.strip()
user = session.event.user_id
group = session.event.group_id
+
if not msg:
msg = session.get('message', prompt='请键入需要反馈的信息')
+
+ if h_type == 'group':
+ await bot.send_private_msg(
+ user_id = master,
+ message = f"来自群[{group}],用户[{user}]的反馈:\n{msg}"
+ ) # type: ignore
- await bot.send_private_msg(
- user_id = master,
- message = f"来自群[{group}],用户[{user}]的反馈:\n{msg}"
- ) # type: ignore \ No newline at end of file
+ elif h_type == 'private':
+ await bot.send_private_msg(
+ user_id = master,
+ message = f"来自用户[{user}]的反馈:\n{msg}"
+ ) # type: ignore \ No newline at end of file
diff --git a/ATRI/plugins/pixiv.py b/ATRI/plugins/pixiv.py
index aeadc67..4be60dc 100644
--- a/ATRI/plugins/pixiv.py
+++ b/ATRI/plugins/pixiv.py
@@ -10,9 +10,9 @@ from ATRI.modules import response # type: ignore
bot = nonebot.get_bot()
master = bot.config.SUPERUSERS
-URL_1 = f'https://api.imjad.cn/pixiv/v1/?type=illust&id=' #单图搜索
-URL_2 = f'https://api.imjad.cn/pixiv/v1/?type=member_illust&id=' #画师作品搜索
-URL_3 = f'https://api.imjad.cn/pixiv/v1/?type=rank' #每日排行榜
+URL_1 = 'https://api.imjad.cn/pixiv/v1/?type=illust&id=' #单图搜索
+URL_2 = 'https://api.imjad.cn/pixiv/v1/?type=member_illust&id=' #画师作品搜索
+URL_3 = 'https://api.imjad.cn/pixiv/v1/?type=rank' #每日排行榜
IMG_SEACH_REPLY = """[CQ:at,qq={user}]
diff --git a/ATRI/plugins/setu.py b/ATRI/plugins/setu.py
index 8c2f29e..1e026be 100644
--- a/ATRI/plugins/setu.py
+++ b/ATRI/plugins/setu.py
@@ -6,7 +6,6 @@ from random import choice, randint
from pathlib import Path
import nonebot
from nonebot import on_command, CommandSession
-from nonebot import MessageSegment
import config # type: ignore
from ATRI.modules import response # type: ignore
diff --git a/ATRI/plugins/switch.py b/ATRI/plugins/switch.py
index dc998a7..3e05467 100644
--- a/ATRI/plugins/switch.py
+++ b/ATRI/plugins/switch.py
@@ -10,7 +10,7 @@ master = bot.config.SUPERUSERS
@on_command('switch', aliases = ['开启', '关闭'], only_to_me = False)
async def _(session: CommandSession):
- with open(f"ATRI/plugins/switch/switch.json", 'r') as f:
+ with open("ATRI/plugins/switch/switch.json", 'r') as f:
data = json.load(f)
if session.event.user_id in master:
@@ -69,7 +69,7 @@ async def _(session: CommandSession):
pass
a = json.dumps(data)
- f2 = open(f"ATRI/plugins/switch/switch.json", 'w')
+ f2 = open("ATRI/plugins/switch/switch.json", 'w')
f2.write(a)
f2.close