How to use the nonebot.get_bot 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 / chat.py View on Github external
# -*- coding:utf-8 -*-
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), 'plus'))
import nonebot
from nonebot import on_command, CommandSession, Message, permission as perm
from random import choice,randint
import re
import wenda
from aiocqhttp.exceptions import ActionFailed

bot = nonebot.get_bot()
master = bot.config.MASTER
first=True
bangroup=[]#推送屏蔽群名单

@on_command('send_group_list', aliases=('群信息',))
async def send_group_list(session: CommandSession):
    message_type=session.ctx['message_type'] 
    user_id=session.ctx['user_id']
    #判断发送的消息是私聊的,并且判断发送者的qq号码
    if message_type=='private' and user_id in master:
        #获取qq群的信息
        try:
            group_list = await session.bot.get_group_list()
        except ActionFailed as e:
            print(e.retcode)
        msg='一共有{}个群:'.format(len(group_list))
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / gacya.py View on Github external
# -*- coding:utf-8 -*-
from nonebot import on_command, CommandSession, permission as perm
import nonebot
import random as rd
from PIL import Image
import os
root=os.path.join(os.path.dirname(__file__),'plus','image')
os.chdir(root)
bot=nonebot.get_bot()
master = bot.config.MASTER[0]

gacya3 = ['中二.png',
        '狐狸.png',
        '妹弓.png',
        '初音.png',
        '霞.png',
        '魅魔.png',
        '充电宝.png',
        '偶像.png',
        '扇子.png',
        '哈哈剑.png',
        'xcw.png',
        'tomo.png',
        '狼.png',
        '伊利亚.png',
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / notices.py View on Github external
# -*- coding:utf-8 -*-
import nonebot
from nonebot import on_notice, NoticeSession, on_request, RequestSession, on_command, CommandSession
from aiocqhttp.exceptions import ActionFailed

bot=nonebot.get_bot()
request_flag=False
master = bot.config.MASTER[0]
# 将函数注册为群成员增加通知处理器
@on_notice('group_increase')
async def increase(session: NoticeSession):
    # 发送欢迎消息
    q = session.ctx['user_id']
    me = session.ctx['self_id']
    # 判断新成员是否是自己
    if q==me:
        await session.send('在下是可可萝,今后请多指教呐')
    else:
        await session.send(f'欢迎新大佬 [CQ:at,qq={q}]')

@on_notice('group_decrease')
async def decrease(session: NoticeSession):
github Joenothing-lst / kkl-Android-2.0 / kkl_bot / kkl / plugins / scheduler.py View on Github external
# -*- coding:utf-8 -*-
from datetime import datetime
import nonebot

bot = nonebot.get_bot()
#使用计划任务模块之前请在命令行执行pip install nonebot[scheduler]
#可自行添加不发送定时消息的群列表

@nonebot.scheduler.scheduled_job('cron', hour='14', minute='50', second='0', misfire_grace_time=60) # = UTC+8 1445
async def pcr_reminder():
    try:
        group_list = await bot.get_group_list()
        msg = '背刺Time背刺Time背刺Time背刺Time背刺Time!!!'
        groups = [group['group_id'] for group in group_list]
        for group in groups:
            await bot.send_group_msg(group_id=group, message=msg)
    except:
        pass


@nonebot.scheduler.scheduled_job('cron', hour='8', minute='0', second='0', misfire_grace_time=60) # = UTC+8 1445

nonebot

An asynchronous QQ bot framework based on CoolQ.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis