diff options
Diffstat (limited to 'ATRI/plugins')
| -rw-r--r-- | ATRI/plugins/bilibili.py | 108 | ||||
| -rw-r--r-- | ATRI/plugins/chat.py | 84 | ||||
| -rw-r--r-- | ATRI/plugins/noobList/noobList.json | 0 | ||||
| -rw-r--r-- | ATRI/plugins/send.py | 75 | ||||
| -rw-r--r-- | ATRI/plugins/setu.py | 5 | ||||
| -rw-r--r-- | ATRI/plugins/switch.py | 2 | ||||
| -rw-r--r-- | ATRI/plugins/switch/switch.json | 2 | ||||
| -rw-r--r-- | ATRI/plugins/upload_sqlite.py | 12 | 
8 files changed, 230 insertions, 58 deletions
| diff --git a/ATRI/plugins/bilibili.py b/ATRI/plugins/bilibili.py new file mode 100644 index 0000000..e415048 --- /dev/null +++ b/ATRI/plugins/bilibili.py @@ -0,0 +1,108 @@ +# -*- 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 + + +@nonebot.on_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 0161768..3363339 100644 --- a/ATRI/plugins/chat.py +++ b/ATRI/plugins/chat.py @@ -1,14 +1,23 @@  import os +import re +import json  import nonebot  import random  from pathlib import Path  from random import randint, choice -from datetime import datetime +from datetime import datetime, timedelta +from nonebot import on_command, scheduler  from nonebot import CommandSession  from nonebot import on_command +from apscheduler.triggers.date import DateTrigger + +from ATRI.modules import response # type: ignore +import config # type: ignore  bot = nonebot.get_bot() +master = config.MASTER() +KC_URL = 'https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn'  @nonebot.scheduler.scheduled_job( @@ -48,7 +57,6 @@ async def _():      except:          pass -  @nonebot.scheduler.scheduled_job(      'cron',      day_of_week = "mon,tue,wed,thu,fri,sat,sun", @@ -95,7 +103,6 @@ def now_time():      now = hour + minute / 60      return now -  @on_command('morning', patterns = [r"早[安哇]|早上好|ohayo|哦哈哟|お早う"], only_to_me = False)  async def _(session: CommandSession):      if 5.5 <= now_time() < 9: @@ -304,10 +311,11 @@ async def _(session: CommandSession): -@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|2b"], only_to_me = False) +@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|2b|给👴爬|嘴臭"], only_to_me = False)  async def _(session: CommandSession):      if randint(1,2) == 1: -        if randint(1,2) == 1: +        res = randint(1,3) +        if res == 1:              img = choice(                  [                      'WQ.jpg', 'WQ.png', 'WQ2.jpg', 'WQ3.jpg', 'FN.jpg' @@ -317,7 +325,7 @@ async def _(session: CommandSession):              img = os.path.abspath(img)              await session.send(f'[CQ:image,file=file:///{img}]') -        elif randint(1,2) == 2: +        elif res == 2:              res = randint(1,3)              if res == 1:                  await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!') @@ -327,6 +335,9 @@ async def _(session: CommandSession):              elif res == 3:                  await session.send('火箭拳——————————————————————————!!!') +         +        elif res == 3: +            await session.send(response.request_api(KC_URL))  @on_command('ciallo', patterns = [r"[Cc][iI][aA][lL][lL][oO]"], only_to_me = False)  async def _(session: CommandSession): @@ -358,7 +369,7 @@ async def _(session: CommandSession):  @on_command('kani', patterns = [r"螃蟹|🦀|カニ|[kK]ani"], only_to_me = False)  async def _(session: CommandSession): -    if random.randint(1,2) == 1: +    if randint(1,2) == 1:          img = choice(              [                  'KN.png', 'KN.jpg', 'KN1.jpg', 'KN2.jpg', 'KN3.png' @@ -366,4 +377,61 @@ async def _(session: CommandSession):          )          img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'          img = os.path.abspath(img) -        await session.send(f'[CQ:image,file=file:///{img}]')
\ No newline at end of file +        await session.send(f'[CQ:image,file=file:///{img}]') + +@on_command('hai', patterns = [r"青[洁结]"], only_to_me = False) +async def _(session: CommandSession): +    if randint(1,2) == 1: +        img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg' +        await session.send(f'[CQ:image,file=file:///{img}]') + +@on_command('ntr', patterns = [r"[nN][tT][rR]|[牛🐂]头人"], only_to_me = False) +async def _(session: CommandSession): +    user = session.event.user_id +    msg = str(session.event.message) +    noobList = [] +    bL = {} +    pattern = r"[nN][tT][rR]|[牛🐂]头人" +    if re.findall(pattern, msg): +        await session.send('你妈的,牛头人,' + response.request_api(KC_URL)) +        noobList.append(user) +        if countX(noobList, user) == 10: +            if user == master: +                pass +            else: +                await session.send('哼!接下来10分钟别想让我理你!') +                bL[f"{user}"] = f"{user}" +                file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' +                f = open(file, 'w') +                f.write(json.dumps(bL)) +                f.close() +                delta = timedelta(minutes = 10) +                trigger = DateTrigger( +                    run_date = datetime.now() + delta +                ) + +                scheduler.add_job( #type: ignore +                    func = rmQQfromNoobLIST, +                    trigger = trigger, +                    args = (user), +                    misfire_grace_time = 60, +                ) + +        else: +            pass + +async def countX(lst, x): +    count = 0 +    for ele in lst: +        if (ele == x): +            count = count + 1 +    return count + +async def rmQQfromNoobLIST(user): +    file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' +    with open(file, 'r') as f: +        bL = json.load(f) +    bL.pop(f"{user}") +    f = open(file, 'w') +    f.write(json.dumps(bL)) +    f.close()    
\ No newline at end of file diff --git a/ATRI/plugins/noobList/noobList.json b/ATRI/plugins/noobList/noobList.json new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ATRI/plugins/noobList/noobList.json diff --git a/ATRI/plugins/send.py b/ATRI/plugins/send.py index 3253727..f1b83af 100644 --- a/ATRI/plugins/send.py +++ b/ATRI/plugins/send.py @@ -3,6 +3,8 @@ import time  import nonebot  from nonebot import on_command, CommandSession +import config # type: ignore +  bot = nonebot.get_bot()  master = bot.config.SUPERUSERS @@ -14,7 +16,7 @@ async def send_all_group(session: CommandSession):      if session.event.user_id in master:          msg = session.current_arg.strip() -        start =time.perf_counter() +        start = time.perf_counter()          if not msg:              msg = session.get('message', prompt='请告诉吾辈需要群发的内容~!') @@ -36,7 +38,6 @@ async def send_all_group(session: CommandSession):          await session.send(f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') -  @on_command('send_to_group', aliases=['对群'], only_to_me=False)  async def send_to_group(session: CommandSession):      if session.event.user_id in master: @@ -49,8 +50,12 @@ async def send_to_group(session: CommandSession):          group = lg[0]          msg = lg[1] -        rei = int(lg[2]) + 1 -         +        rei = 1  +        try: +            rei = int(lg[2]) + 1 +        except: +            pass +          if rei:              for i in range(1, rei):                  try: @@ -67,60 +72,48 @@ async def send_to_group(session: CommandSession):          await session.send('推送完成!') -@on_command('send_to_qq', aliases=['对QQ'], only_to_me=False) -async def send_to_qq(session: CommandSession): +@on_command('send_all_friend', aliases = ['全体用户'], only_to_me = False) +async def send_all_friend(session: CommandSession):      if session.event.user_id in master:          msg = session.current_arg.strip() -     + +        start = time.perf_counter() +          if not msg: -            msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对QQ 12345647(QQ号) message') +            msg = session.get('message', prompt='请告诉吾辈需要群发的内容~!') -        lg = msg.split(' ') +        friend_list = await session.bot.get_friend_list() # type: ignore +        print(friend_list) +        f_list = len(friend_list) -        qq = lg[0] -        msg = lg[1] +        for friend in friend_list: -        try: -            await bot.send_private_msg(user_id = qq, message = msg) # type: ignore -        except: -            await session.send('发送失败,请重试') +            try: +                await bot.send_private_msg(user_id = friend['user_id'], message = msg) # type: ignore +             +            except: +                await bot.send_private_msg(user_id = master, message = f"列表用户[{friend['user_id']}]推送失败") # type: ignore -        await session.send('推送完成!') +        end = time.perf_counter() +        await session.send(f'已推送到[{f_list}]位用户\n耗时:{round(end - start, 3)}') -@on_command('send_to_group_pr', aliases=['对群私聊'], only_to_me=False) -async def _(session: CommandSession): +@on_command('send_to_qq', aliases=['对QQ'], only_to_me=False) +async def send_to_qq(session: CommandSession):      if session.event.user_id in master:          msg = session.current_arg.strip()          if not msg: -            msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对群 12345647(群号) message 1') +            msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对QQ 12345647(QQ号) message')          lg = msg.split(' ') -        group = lg[0] +        qq = lg[0]          msg = lg[1] -        rei = int(lg[2]) + 1 -        group_user_list = await session.bot.get_group_member_list(group_id = group) # type: ignore - -        for i in group_user_list: -            time.sleep(0.5) -            userid = i['user_id'] -            print(userid) -         -            if rei: -                for a in range(1, rei): -                    time.sleep(0.5) -                    try: -                        await bot.send_private_msg(user_id = userid, message = msg) # type: ignore -                    except: -                        await session.send('发送失败,请重试') -             -            else: -                try: -                    await bot.send_private_msg(user_id = userid, message = msg) # type: ignore -                except: -                    await session.send('发送失败,请重试') +        try: +            await bot.send_private_msg(user_id = qq, message = msg) # type: ignore +        except: +            await session.send('发送失败,请重试')          await session.send('推送完成!')
\ No newline at end of file diff --git a/ATRI/plugins/setu.py b/ATRI/plugins/setu.py index 1e026be..cbf8ff6 100644 --- a/ATRI/plugins/setu.py +++ b/ATRI/plugins/setu.py @@ -4,8 +4,11 @@ import time  import json  from random import choice, randint  from pathlib import Path +import aiocqhttp  import nonebot -from nonebot import on_command, CommandSession +from nonebot import NoneBot, on_command, CommandSession +from nonebot import message_preprocessor +from nonebot.plugin import PluginManager  import config # type: ignore  from ATRI.modules import response # type: ignore diff --git a/ATRI/plugins/switch.py b/ATRI/plugins/switch.py index 3e05467..810dac8 100644 --- a/ATRI/plugins/switch.py +++ b/ATRI/plugins/switch.py @@ -71,7 +71,7 @@ async def _(session: CommandSession):          a = json.dumps(data)          f2 = open("ATRI/plugins/switch/switch.json", 'w')          f2.write(a) -        f2.close +        f2.close()          await session.send('设置完成!') diff --git a/ATRI/plugins/switch/switch.json b/ATRI/plugins/switch/switch.json index d0f3d6a..99d82c4 100644 --- a/ATRI/plugins/switch/switch.json +++ b/ATRI/plugins/switch/switch.json @@ -1 +1 @@ -{"pixiv_seach_img": 0, "pixiv_seach_author": 1, "pixiv_daily_rank": 0, "approve_friend_add": 0, "approve_invite_join_group": 0, "setu": 0, "hbook": 1}
\ No newline at end of file +{"pixiv_seach_img": 0, "pixiv_seach_author": 1, "pixiv_daily_rank": 0, "approve_friend_add": 0, "approve_invite_join_group": 0, "setu": 0, "hbook": 0}
\ No newline at end of file diff --git a/ATRI/plugins/upload_sqlite.py b/ATRI/plugins/upload_sqlite.py index 963205b..a7c5b75 100644 --- a/ATRI/plugins/upload_sqlite.py +++ b/ATRI/plugins/upload_sqlite.py @@ -164,10 +164,10 @@ async def _(session: CommandSession):      con.close()      await session.send( -        f"""目前ATRI数据库收录了: -    涩图: -        normal: {data_normal} -        nearR18: {data_nearR18} -        r18:{data_r18} -    网抑云语录:{data_cloudmusic}""" +        f"""目前螃蟹™数据库收录了: +涩图: +    normal: {data_normal} +    nearR18: {data_nearR18} +    r18:{data_r18} +网抑云语录:{data_cloudmusic}"""      )
\ No newline at end of file | 
