示例#1
0
from nonebot.permission import MESSAGE
from nonebot.adapters.cqhttp import Bot, Event, MessageSegment
from nonebot_plugin_rauthman import isInService
from urllib.parse import quote
# from pixivpy3 import AppPixivAPI
from pixivpy3 import ByPassSniApi
from .config import *
import random
import datetime

sv = MatcherGroup(type='message', rule=isInService('pixiv', 1))
# aapi = AppPixivAPI()
aapi = ByPassSniApi()
aapi.require_appapi_hosts(hostname="public-api.secure.pixiv.net")
aapi.set_accept_language('jp')
sv_search = sv.on_startswith(msg='/pixiv', permission=MESSAGE, block=True)


@sv_search.handle()
async def pixiv_handle(bot: Bot, event: Event, state: dict):
    msg = str(event.message).strip()
    msg = msg.replace('/pixiv', '')
    if not msg:
        logger.info('pixiv_handle | no keyword')
        await sv_search.finish()
    state['keyword'] = msg


@sv_search.got('keyword')
async def pixiv_got(bot: Bot, event: Event, state: dict):
    keyword = state['keyword']
示例#2
0
        if rex_word.search(w):
            w = word2cheru(w)
        c.append(w)
    return ''.join(c)


def cheru2str(c: str) -> str:
    return rex_cheru_word.sub(lambda w: cheru2word(w.group()), c)


cherugo = MatcherGroup(type='message',
                       rule=sv_sw(plugin_name,
                                  usage=plugin_usage,
                                  hierarchy='其它'))

tocherugo = cherugo.on_startswith('切噜一下')


@tocherugo.handle()
async def cherulize(bot: Bot, event: MessageEvent):
    s = event.get_plaintext()
    if len(s) > 500:
        await tocherugo.finish(reply_header(event, '切、切噜太长切不动勒切噜噜...'))
    await tocherugo.finish(reply_header(event, '切噜~♪' + str2cheru(s)))


fromcherugo = cherugo.on_startswith('切噜~♪')


@fromcherugo.handle()
async def decherulize(bot: Bot, event: MessageEvent):
示例#3
0

def str2cheru(s: str) -> str:
    c = []
    for w in rex_split.split(s):
        if rex_word.search(w):
            w = word2cheru(w)
        c.append(w)
    return ''.join(c)


def cheru2str(c: str) -> str:
    return rex_cheru_word.sub(lambda w: cheru2word(w.group()), c)


sv_txt_to_cheru = sv.on_startswith(msg='切噜一下', permission=MESSAGE, block=True)


@sv_txt_to_cheru.handle()
async def cherulize(bot: Bot, event: Event, state: dict):
    msg = str(event.message).strip()
    msg = msg.replace(msg[:4], '').strip()
    if not msg:
        await sv_txt_to_cheru.finish()
    if len(msg) > 500:
        await sv_txt_to_cheru.finish('切、切噜太长切不动勒切噜噜...')
    state['cheru'] = msg


@sv_txt_to_cheru.got('cheru')
async def cherulize_cheru(bot: Bot, event: Event, state: dict):