How to use the nonebot.on_command function in nonebot

To help you get started, we’ve selected a few nonebot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / gacya.py View on Github external
@on_command('set_up',aliases=('up设置',),only_to_me=False)
async def set_up(session:CommandSession):
    global up
    if master == session.ctx['user_id']:
        msg=session.current_arg.split()
        up= [f'{i}.png' for i in msg]
        await session.send(message='设置完成,现在卡池up角色:{}'.format(''.join([f'[CQ:image,file=file:///{root}\\{i}]'  for i in up])))
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('switch', aliases=('开启','关闭'), only_to_me=False) 
async def switch(session: CommandSession):
    if session.ctx['user_id'] in session.bot.config.MASTER:
        comman = session.ctx['raw_message'].split(' ',1)
        swtich = comman[0]#获取关键词
        plugins = comman[1]
        global new_switch,hbook_switch,hpic_switch,jjcsearch_switch
        if swtich=='开启':
            if plugins == '新闻':
                new_switch = True
            elif plugins == 'jjc':
                jjcsearch_switch= True
            elif plugins == '本子':
                hbook_switch = True
            else :
                await session.send('指令有误!')
        else :
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('Tevents', aliases=('台服活动',), only_to_me=True)
async def Tevents(session: CommandSession):
    header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
    url = 'https://pcredivewiki.tw/static/data/event.json'

    data = await get_bytes(url,headers = header)
    data = json.loads(data.decode())

    n=dt.datetime.now()
    msg0 = '已查询到以下活动:'
    for i in data:
        t=dt.datetime.strptime(i['end_time'],'%Y/%m/%d %H:%M')
        if t>n:
            msg=('\n-----------------------------------------------\n活动名称:{}\n活动时间:{}--{}'.format(jianfan.toSimpleString(i['campaign_name']),i['start_time'][5:],i['end_time'][5:]))
            msg0+=msg
    await session.send(message= msg0)
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('Tnews', aliases=('台服新闻',), only_to_me=True)
async def Tnews(session: CommandSession):
    url = 'http://www.princessconnect.so-net.tw/news'
    header ={ 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
    
    data = await get_bytes(url,headers = header)
    data = data.decode()
    #标题
    pattern_title = '<a href="/news/newsDetail/.*?">(.*?)</a>'#标题
    title = re.findall(pattern_title,data)
    #链接
    pattern_link = '
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('Rnews', aliases=('日服新闻','日服活动'), only_to_me=True)
async def Rnews(session: CommandSession):
    header = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
    url = 'https://priconne-redive.jp/news/'
    
    data = await get_bytes(url,headers = header)
    data = data.decode()

    pattern_title = '<h4>(.*?)</h4>'#标题
    title = re.findall(pattern_title,data)

    pattern_link = '<a href="(.*?)">'#链接
    link0 = re.findall(pattern_link,data)
    link = [link0[i] for i in range(len(link0)) if 'new' in link0[i]]
    del(link[0],link[-1])

    pattern_time = '<time class="time">(.*?)</time>'#发布时间
</a>
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / notices.py View on Github external
@on_command('set_request', aliases=('开启邀请',), only_to_me=True)
async def set_request(session: CommandSession):
    global request_flag
    if session.ctx['user_id']==master:
        request_flag=True
        await session.bot.send_private_msg(user_id=master,message='已开启')
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('zh_to_ja', aliases=('翻译日语',), only_to_me=False)                 #changed
async def ja_to_zh(session: CommandSession):
    if ' ' in session.ctx['raw_message']: 
        msg=session.ctx['raw_message'][5:]
        re_msg = translate(msg[:4999], to='ja', source='zh-CN')
        if re_msg[0]!='':
            await session.send(re_msg[0])
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('jjcsearch', aliases=('jjc查询','JJC查询','怎么拆','怎么解'), only_to_me=False)                 #changed
async def jjcs(session: CommandSession):
    msg=session.current_arg.strip()
    if jjcsearch_switch: 
        msg=session.current_arg.strip()
        if not msg:
            f_msg = session.get('message', prompt='骑士君想查什么阵容呢?\nps:用空格分隔')
        result = await jjcsearch.total(msg,session.ctx['user_id'],session.bot.config.JJC_KEY)
        await session.send(result)
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / spider.py View on Github external
@on_command('ja_to_en', aliases=('英语翻译',), only_to_me=False)                 #changed
async def ja_to_zh(session: CommandSession):
    if ' ' in session.ctx['raw_message']: 
        msg=session.ctx['raw_message'][5:]
        re_msg = translate(msg[:4999], to='zh-CN', source='en')
        if re_msg[0]!='':
            await session.send(re_msg[0])
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / gacya.py View on Github external
@on_command('set_gacya',aliases=('卡池设置',),only_to_me=False)
async def set_gacya(session:CommandSession):
    global fes,isdouble
    if master == session.ctx['user_id']:
        msg=session.current_arg.strip()
        if not msg:
            msg = session.get('message', prompt='准备完成,请发送设置')
        fes=msg[0]
        try:
            isdouble=msg[1]
        except:
            isdouble='0'
        await session.send(message=f'设置完成,现在卡池设置\nfes:{fes}\n双倍:{isdouble}')

nonebot

An asynchronous QQ bot framework based on CoolQ.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis