Esempio n. 1
0
font_path = res.get('font/seguiemj.ttf').path

aliases = {
    '怎么拆', '怎么解', '怎么打', '如何拆', '如何解', '如何打', '怎麼拆', '怎麼解', '怎麼打', 'jjc查询',
    'jjc查詢'
}
aliases_b = {'b' + a for a in aliases}
aliases_b1 = {'B' + a for a in aliases}
aliases_b.update(aliases_b1)
aliases_tw = {'台' + a for a in aliases}
aliases_jp = {'日' + a for a in aliases}

sv = MatcherGroup(type='message')
sv_all = sv.on_command(cmd='arena_all',
                       aliases=aliases,
                       permission=MESSAGE,
                       block=True)


@sv_all.handle()
async def arena_all(bot: Bot, event: Event, state: dict):
    res = await _arena_query(bot, event, 1)
    await sv_all.finish(res)


sv_bl = sv.on_command(cmd='arena_bl',
                      aliases=aliases_b,
                      permission=MESSAGE,
                      block=True)

Esempio n. 2
0
    multiple = res['multiple']
    msg = ''
    if multiple:
        img_url = res['original_urls_proxy']
        for item in img_url:
            image = MessageSegment.image(item)
            msg += f'{image}\n'
        msg = msg.strip()
    else:
        img_url = res['original_url_proxy']
        msg = MessageSegment.image(img_url)
    return msg


sv_rank = sv.on_command(cmd='pixiv_rank',
                        aliases={'/p站排行榜'},
                        permission=MESSAGE,
                        block=True)


@sv_rank.handle()
async def pixiv_rank(bot: Bot, event: Event, state: dict):
    # uid = bot.config.superusers[0]
    # sid = bot.self_id

    now = datetime.datetime.now()
    last = datetime.timedelta(days=1)
    lastday = now - last
    yesterday = lastday.strftime('%Y-%m-%d')
    try:
        aapi.login(USERNAME, PWD)
        res = aapi.illust_ranking(mode='day', date=yesterday)
Esempio n. 3
0
        json.dump({}, j, indent=4)

with configfile.open(encoding='utf-8') as j:
    prob_settings = json.load(j)


def record_settings(gid: str, prob: float):
    prob_settings[gid] = prob
    with configfile.open('w', encoding='utf-8') as j:
        json.dump(prob_settings, j, indent=4)


chatbot = MatcherGroup(type='message')

set_prob = chatbot.on_command('聊天触发率',
                              rule=sv_sw(plugin_name, plugin_usage)
                              & comman_rule(GroupMessageEvent),
                              priority=2)


@set_prob.handle()
async def recieve_arg(bot: Bot, event: GroupMessageEvent, state: T_State):
    arg = event.message.extract_plain_text().strip()
    if arg:
        state['prob'] = arg


@set_prob.got("prob", prompt='请输入聊天触发率,范围0-50,输入[退出]取消设置触发率')
async def prob_handle(bot: Bot, event: GroupMessageEvent, state: T_State):
    prob = state[
        "prob"] if "prob" in state else event.message.extract_plain_text(
        ).strip()
Esempio n. 4
0
/绑定邮箱'''

# 声明本插件可配置的权限节点
__plugin_auth_node__ = ['basic']

# Init plugin export
init_export(export(), __plugin_name__, __plugin_usage__, __plugin_auth_node__)

# 注册事件响应器
OmegaEmail_admin = MatcherGroup(type='message',
                                rule=to_me(),
                                priority=20,
                                permission=SUPERUSER,
                                block=True)

admin_mail_add = OmegaEmail_admin.on_command('添加邮箱')


# 修改默认参数处理
@admin_mail_add.args_parser
async def parse(bot: Bot, event: MessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().split()
    if not args:
        await admin_mail_add.reject('你似乎没有发送有效的参数呢QAQ, 请重新发送:')
    state[state["_current_key"]] = args[0]
    if state[state["_current_key"]] == '取消':
        await admin_mail_add.finish('操作已取消')


@admin_mail_add.handle()
async def handle_first_receive(bot: Bot, event: MessageEvent, state: T_State):
Esempio n. 5
0
            #     '{admin}邀请{name}给大家展示女装姐妹丼啦,欸欸~米娜桑不要脱裤子啊(#°Д°)'
            #     ],
            'locked': False
            }  # 暂时没发现有条件能上报operator_id,所以invite就先不管了


def save_wl_settings():
    """保存群欢迎语句设置"""
    with welcome_settings_file.open('w', encoding='utf-8') as j:
        json.dump(welcome_settings, j, ensure_ascii=False, escape_forward_slashes=False, indent=4)


welcome = MatcherGroup()
welcome_sw = sv_sw(welcome_name, welcome_usage, hierarchy='群助手')

speech_editor = welcome.on_command('设置入群欢迎', rule=welcome_sw&comman_rule(GroupMessageEvent), priority=2)


@speech_editor.handle()
async def show_speech(bot: Bot, event: GroupMessageEvent, state: T_State):
    gid = str(event.group_id)
    if gid not in welcome_settings:
        wl_setting = DEFAULT_SPEECH
    else:
        wl_setting = welcome_settings[gid]
    ap_speeches = '\n'.join([f'{i+1}.{speech}' for i, speech in enumerate(wl_setting['approve'])])
    # in_speeches = '\n'.join([f'{i+1+len(wl_setting["approve"])}.{speech}' for i, speech in enumerate(wl_setting['invite'])])
    status = '已锁定' if wl_setting['locked'] else '未锁定'
    msg = '当前新人入群欢迎语句为:\n' + ap_speeches + '\n────────────\n可修改状态:' + status
    if wl_setting['locked'] and event.sender.role == 'member':
        await speech_editor.finish(Message(msg))
Esempio n. 6
0

#———————————————单次学习————————————————


def filter_selflearn(bot: Bot, event: MessageEvent, state: T_State):
    """过滤非bot管理员的自学"""
    if event.message.extract_plain_text().startswith(
            '自学') and event.user_id not in SUPERUSERS:
        return False
    return True


preprob = {}  # 出现率设置预备列表,在其中的用户刚使用了学习对话功能
learn = qanda.on_command('学习',
                         aliases={'学习对话', '群内学习', '私聊学习', '偷偷学习', '自学'},
                         rule=sv_sw('问答对话', plugin_usage) & filter_selflearn)
SANAE_BOTS = (1538482349, 2503554271, 1431906058, 2080247830, 2021507926,
              2078304161, 1979853134, 2974922146, 1670225564)
ALLOW_SEGMENT = ('text', 'face', 'image', 'at', 'record', 'video', 'share'
                 )  # 允许学习的CQ码


@learn.handle()
async def first_receive(bot: Bot, event: MessageEvent, state: T_State):

    # 过滤妖精的早苗
    if event.user_id in SANAE_BOTS:
        await learn.finish('两只AI成功握手,但被主人阻止掉了(;∀;)')

    command = state["_prefix"]["raw_command"]
Esempio n. 7
0
        fill = '█' * 9 + '▌'
        empty = ''
    elif pct < 0:
        fill = ''
        empty = '░' * 10
    else:
        bk_amt = round(pct * 10)
        fill = '█' * round(bk_amt)
        empty = '░' * (10 - bk_amt)

    return '┃%s┃' % (fill + empty)


level_sys = MatcherGroup(type="message")

sign = level_sys.on_command("签到")


@sign.handle()
async def sign_(bot: Bot, event: MessageEvent):
    uid = event.user_id
    user = UserLevel(uid)

    # 是否可以签到
    today = date.today()
    last_sign_day = user.last_sign.date()

    if today > last_sign_day:
        with QbotDB() as botdb:
            botdb.update(
                'update userinfo set `last_sign`=NOW(), total_sign=total_sign+1 where qq_number=%s;',
Esempio n. 8
0
config_file = f'{absPath}/config.json'

# data = {
#     'calendar_days': 7,  # 日程表返回包括今天在内多长时间的日程,默认是7天
#     'Refresh_date': '',  # 上次爬取日程表的日期
#     'schedule_data': ''  # 从官方日历爬取下来的数据
# }

# day_key里保存的是每天的信息分类,"qdhd"是多倍掉落庆典,"tdz"是公会战,
# "tbhd"是公会之家家具上架,"jqhd"是活动地图,"jssr"是角色生日
# 你可以自定义这个列表,删掉不想看到的活动
day_key = ["qdhd", "tdz", "tbhd", "jqhd"]


sv = MatcherGroup(type='message', rule=isInService('schedule', 1))
sv_query = sv.on_command(cmd='schedule', aliases={
                         '国服日程表', '日程表'}, permission=MESSAGE, block=True)


@sv_query.handle()
async def Schedule(bot: Bot, ev: Event, state: dict):
    # 调用的时候比对上次爬取日程表时间,不是今天就重新爬取日程表,是今天就直接返回
    p = config_file
    await checkFolder(p)
    data = await readJson(p)
    if data == FAILURE:
        data = {
            'calendar_days': 7,
            'Refresh_date': '',
            'schedule_data': ''
        }
        await writeJson(p, data)
Esempio n. 9
0
        name = (name, )
    if not isinstance(name, Iterable):
        raise ValueError('`name` of cb_cmd must be `str` or `Iterable[str]`')
    names = map(lambda x: helper.normalize_str(x), name)

    def deco(func) -> Callable:
        for n in names:
            if n in _registry:
                logger.warning(
                    f'出现重名命令:{func.__name__} 与 {_registry[n].__name__}命令名冲突')
            else:
                _registry[n] = (func, parser)
        return func

    return deco


from .cmdv2 import *

sv_msg = sv.on_command(cmd='battle_help',
                       aliases={'手册'},
                       permission=MESSAGE,
                       block=True)


@sv_msg.handle()
async def battle_help(bot: Bot, event: Event, state: dict):
    base_url = config.PUBLIC_BASE_URL
    url = f'{base_url}/guide/manual.html'
    await sv_msg.finish(url)
Esempio n. 10
0
/销假
/谁有空 [技能名称]
/谁在休假'''

# Init plugin export
init_export(export(), __plugin_name__, __plugin_usage__)

# 注册事件响应器
vocation = MatcherGroup(type='message',
                        rule=has_command_permission()
                        & permission_level(level=80),
                        permission=GROUP,
                        priority=10,
                        block=True)

my_status = vocation.on_command('我的状态')


@my_status.handle()
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    user_id = event.user_id
    user = DBUser(user_id=user_id)
    result = user.status()
    if result.success():
        status = result.result
        if status == 1:
            status = '请假中'
        elif status == 2:
            status = '工作中'
        else:
Esempio n. 11
0
import nonebot
from nonebot import MatcherGroup
from nonebot.permission import MESSAGE, SUPERUSER
from nonebot.adapters.cqhttp import Bot, Event
import cheru

sv = MatcherGroup(type='message')
sv_status = sv.on_command(cmd='status',
                          aliases={'/status'},
                          permission=SUPERUSER,
                          block=True)


@sv_status.handle()
async def handle_get_status(bot: Bot, event: Event, state: dict):
    try:
        sid = bot.self_id
        res = await bot.get_status(self_id=sid)
    except:
        await sv_status.finish('error')
    stat = res['stat']
    packet_received = stat['packet_received']
    packet_sent = stat['packet_sent']
    packet_lost = stat['packet_lost']
    message_received = stat['message_received']
    message_sent = stat['message_sent']
    disconnect_times = stat['disconnect_times']
    lost_times = stat['lost_times']
    info = await bot.call_api('get_login_info')
    nickname = info['nickname']
    msg = f'''
Esempio n. 12
0
def dump_pool_config():
    with open(_pool_config_file, 'w', encoding='utf8') as f:
        json.dump(_group_pool, f, ensure_ascii=False)


gacha_10_aliases = {
    '抽十连', '十连', '十连!', '十连抽', '来个十连', '来发十连', '来次十连', '抽个十连', '抽发十连', '抽次十连',
    '十连扭蛋', '扭蛋十连', '10连', '10连!', '10连抽', '来个10连'
}
gacha_1_aliases = {'单抽', '单抽!', '来发单抽', '来个单抽', '来次单抽', '扭蛋单抽', '单抽扭蛋'}
gacha_300_aliases = {'抽一井', '来一井', '来发井', '抽发井', '天井扭蛋', '扭蛋天井'}

sv_info = sv.on_command(
    cmd='gacha_info',
    aliases={'卡池资讯', '查看卡池', '看看卡池', '康康卡池', '看看up', '看看UP'},
    permission=MESSAGE,
    block=True)


@sv_info.handle()
async def gacha_info(bot: Bot, event: Event, state: dict):
    gid = str(event.group_id)
    gacha = Gacha(_group_pool[gid])
    up_chara = gacha.up
    up_chara = map(lambda x: str(chara.fromname(x, star=3).icon.cqcode) + x,
                   up_chara)
    up_chara = '\n'.join(up_chara)
    await sv_info.finish(
        f"本期卡池主打的角色:\n{up_chara}\nUP角色合计={(gacha.up_prob/10):.1f}% 3★出率={(gacha.s3_prob)/10:.1f}%\n"
    )
Esempio n. 13
0
from nonebot.plugin import on_keyword, on_command
from nonebot.rule import to_me
from nonebot.adapters.cqhttp import Bot, MessageEvent
from nonebot import MatcherGroup, CommandGroup, export, logger
from src.plugins.hoke.selectMysql import QueryWeiboAll, QueryQQ, QueryMobole, QueryWeibo
from src.urils.tool import is_number, validPhone, fomatMessage
'''聊天模式'''
pBot_mes_group = MatcherGroup(type='message', priority=20, block=True)
pbot_cmd = pBot_mes_group.on_command('q')


@pbot_cmd.handle()
async def queryPhoneInfo(bot: Bot, event: MessageEvent):
    mes = str(event.message).strip()
    if mes == '637442240':
        return 0
    bool = validPhone(mes)
    bList = ""
    mobiles = []
    weibo = []
    if is_number(mes):
        if bool:
            mobiles = QueryMobole(mes)
            weibo = QueryWeibo(mes)
        else:
            mobiles = QueryQQ(mes)
            weibo = QueryWeiboAll(mobiles)
        bList = fomatMessage(mobiles, weibo)
    else:
        bList = "你说啥?"