Beispiel #1
0
                conn.commit()
            else:
                #print("UPDATE new SET name ="+name+ "WHERE id="+ str(event.get_user_id()))
                conn.execute("UPDATE new SET name ='" + name + "'  WHERE id=" +
                             event.get_user_id())
                conn.commit()
            await get_class(bot, event, conn, name)
            text = '绑定成功'
        except Exception as e:
            text = '绑定失败,错误提示' + str(e)
        finally:
            closeconnsql(conn)
    await bot.send(event, text, at_sender=True)


command_test = on_keyword({'绑定学号'})


@command_test.handle()
async def _echo(bot: Bot, event: MessageEvent):
    try:
        if re.match("绑定学号 [\d]{12}", event.get_plaintext()):
            return
        text = '绑定格式错误 请输入 绑定学号 631800000000 进行绑定'
    except Exception as e:
        text = e
    await bot.send(event, text, at_sender=True)


command_test = on_regex('刷新课表')
Beispiel #2
0
from nonebot.plugin import on_keyword, on_command
from nonebot.rule import to_me
from nonebot.adapters.mirai import Bot, MessageEvent

message_test = on_keyword({'reply'}, rule=to_me())


@message_test.handle()
async def _message(bot: Bot, event: MessageEvent):
    text = event.get_plaintext()
    await bot.send(event, text, at_sender=True)


command_test = on_command('miecho')


@command_test.handle()
async def _echo(bot: Bot, event: MessageEvent):
    text = event.get_plaintext()
    await bot.send(event, text, at_sender=True)
Beispiel #3
0
            except Exception as e:
                text = str(e)
            finally:
                time.sleep(1)
    closeconnsql(conn)

scheduler = require('nonebot_plugin_apscheduler').scheduler
@scheduler.scheduled_job('cron',hour='7',minute='0',second='0', id='moring')
async def moring():
   await sendmoring()

    #print(nonebot.get_bots())
        #print(i[0])


#test
command_test = on_keyword({"提示"},rule=to_me())
@command_test.handle()
async def _echo(bot: Bot, event: MessageEvent):
    if event.get_plaintext()!='提示':
        return
    bot = nonebot.get_bots()[get_attr('botqq')]
    if event.get_user_id()not in get_attr('SUPER'):
        text="你暂无此权限"
        await  bot.send(event,text,at_sender=True)
        return
    else:
        await sendmoring()

#
Beispiel #4
0
from nonebot.plugin import on_keyword, on_notice,on_request
from nonebot.adapters.mirai import Bot, MessageEvent,NewFriendRequestEvent,BotInvitedJoinGroupRequestEvent,BotJoinGroupEvent
from nonebot.adapters import Event
from nonebot.typing import T_State
from ._set import get_attr
import time

help_str=get_attr('help')


command_test = on_keyword({"帮助"})
@command_test.handle()
async def _echo(bot: Bot, event: MessageEvent):
    if event.get_plaintext()!='帮助':
        return
    text =help_str
    await bot.send(event,text,at_sender=True)




def NewFriendRequestEventRule(bot: Bot, event: Event, state: T_State):
    return isinstance(event, NewFriendRequestEvent)
new_friend = on_request(NewFriendRequestEventRule)
@new_friend.handle()
async def _(bot: Bot, event: NewFriendRequestEvent, state: T_State):
    await event.approve(bot)
    time.sleep(1)
    text='见到你我很高兴\n输入帮助即可尽情玩弄机器人哦QaQ'
    await bot.send_friend_message(event.from_id,text)
Beispiel #5
0
@nmsl.handle()
async def _(bot: Bot, event: Event, state: dict):
    user = str(event.user_id)
    count = counter(count_list_n, user)
    if 6 > count > 3:
        await bot.send(event, "还,还要吗?!")

    api = config["shadiao"]["zui_chou"]
    if count < 7:
        count_list_n.append(user)
    async with httpx.AsyncClient() as client:
        response = await client.get(api)
    await nmsl.finish(response.text)


pyq = on_keyword({"朋友圈"}, rule=to_me(), block=True)


@pyq.handle()
async def _(bot: Bot, event: Event, state: dict):
    api = config["shadiao"]["peng_you_quan"]

    async with httpx.AsyncClient() as client:
        response = await client.get(api)
    await pyq.finish(response.text)


chp = on_keyword({"夸"}, rule=to_me(), block=True)


@chp.handle()
Beispiel #6
0
        href = soup.select('a[href]')[0]["href"]
        s.get("http://libopp.cqjtu.edu.cn/" + href)

        rep = s.get("http://libopp.cqjtu.edu.cn/tsg.asp")
        rep.encoding = rep.apparent_encoding
        # print(rep.text)
        soup = BeautifulSoup(rep.text, "html.parser")
        resp = soup.select('font[color="white"]')[0].text

        if resp.find("已预约") <= 0:
            return "取消预约" + getdata(chodate) + "的" + chopos + "图书馆成功"
        else:
            return "取消预约" + getdata(chodate) + "的" + chopos + "失败,已满"


command_test = on_keyword({"预约今天图书馆"}, priority=2)


@command_test.handle()
async def _echo(bot: Bot, event: MessageEvent):
    #print(bot.config.custom_config1,type(bot.config.custom_config1))
    if event.get_user_id() not in get_attr('SUPER'):
        text = "你暂无此权限"
    else:
        text = getrep("one", "南岸", get_attr('cookiedic')[event.get_user_id()])
    await bot.send(event, text, at_sender=True)


command_test = on_keyword({"预约明天图书馆"}, priority=2)

Beispiel #7
0
    text = ''
    for i in a:
        cout += 1  # 课次
        if i[3] == cot:
            cot += 1
            text += '\n' + weekdic[i[3]]
        text += '\n' + i[0] + ' ' + i[1] + ' ' + i[2]
    if text:
        text = tishi_week[cho] + "周是" + str(zc) + "周\n一共有" + str(
            cout) + '节课' + text
    else:
        text = "你" + tishi_week[cho] + "周没课\n请好好休息"
    return text


message_test = on_keyword({'本周课表'})


@message_test.handle()
async def _message(bot: Bot, event: MessageEvent):
    try:
        conn = connsql()
        if event.get_plaintext() != '本周课表':
            return
        if not sql_isempty(event.get_user_id(), conn):
            text = tishi2
        else:
            text = await weekclass(event.get_user_id(), conn, "this")
    except Exception as e:
        text = str(e)
    finally:
Beispiel #8
0
from nonebot.plugin import on_keyword, on_command, on_regex, on_message
from nonebot.rule import to_me
from nonebot.adapters.mirai import Bot, MessageEvent
from nonebot.adapters.cqhttp import Bot, MessageEvent
from nonebot.rule import Rule

str = ''


def permission_check(bot: Bot, event: MessageEvent, state: dict):
    return True


command_test = on_keyword({'傻逼', 'sb', 'nmsl', '脑残', '狗逼', '吃屎', '爹'},
                          rule=to_me())


@command_test.handle()
async def _echo(bot: Bot, event: MessageEvent):
    if str in event.get_plaintext() and str in event.get_plaintext(
    ) and str in event.get_plaintext():
        text = '你是傻逼'
    else:
        text = '我是你爹'
        await bot.send(event, text, at_sender=True)


command_test = on_keyword({str}, rule=to_me())


@command_test.handle()
Beispiel #9
0
from nonebot.plugin import on_keyword, on_command
from nonebot.rule import to_me
from nonebot.adapters.mirai import Bot, MessageEvent

message_test = on_keyword({'是sb吗'}, rule=to_me(), priority=3)


@message_test.handle()
async def _message(bot: Bot, event: MessageEvent):
    text = event.get_plaintext()
    await message_test.finish("是")
Beispiel #10
0
        if i:
            print(i)
            kcmc = i['kclbmc'] if i['kclbmc'] else "?"
            zcj = i['zcj'] if i['zcj'] else '?'
            xf = i['xf'] if i['xf'] else '?'
            if kcmc != '校选':
                point = ScoreToGradePoint(zcj)
                gpa_only += point * xf
                sum_xf_only += xf
            point = ScoreToGradePoint(zcj)
            gpa += point * xf
            sum_xf += xf
    return gpa_only / sum_xf_only, gpa / sum_xf


message_test = on_keyword({'查成绩'})


@message_test.handle()
async def _message(bot: Bot, event: MessageEvent):
    if event.get_plaintext() != '查成绩':
        return
    try:
        conn = connsql()
        if not sql_isempty(event.get_user_id(), conn):
            text = tishi2
        else:
            a = conn.execute('select name from new where id={}'.format(
                event.get_user_id()))
            name = ''
            for i in a:
Beispiel #11
0
        "select name,classroom,start_time,week from class where zc={} and qq={} and week={}"
        .format(zc, qq, week))
    cout = 0  # 课次
    text = ''
    for i in a:
        cout += 1  # 课次
        text += '\n' + i[0] + ' ' + i[1] + ' ' + i[2]
    if text:
        text = tishi_day[cho] + "是" + weekdic[week] + "\n一共有" + str(
            cout) + '节课' + text
    else:
        text = "你" + tishi_day[cho] + "没有课了\n请好好休息QaQ"
    return text


message_test = on_keyword({'课表'}, block=False)


@message_test.handle()
async def _message(bot: Bot, event: MessageEvent):
    try:
        conn = connsql()
        if not (event.get_plaintext() == '今日课表' or event.get_plaintext()
                == '课表' or event.get_plaintext() == '今天课表'):
            return
        if not sql_isempty(event.get_user_id(), conn):
            text = tishi2
        else:
            text = await onedaycourse(event.get_user_id(), conn, "one")
    except Exception as e:
        text = str(e)
Beispiel #12
0
            os.system(f"rm {path_yulu_prefix}{msg[0]}")
            os.system(f"rm {path_threeciyuan_prefix}{msg[0]}")
            await del_img.finish("成功删除")
    else:
        await del_img.finish('错误参数,例子: rm 1.jpg')


async def get_img_url(path: str) -> str:
    return "file:///" + path


async def get_img_list(path):
    return os.listdir(f"{path}")


update_file = on_keyword(set(["更新图库", "更新语录", "更新色图"]), rule=to_me())


@update_file.handle()
async def update_file_handle(bot: Bot, event: Event, state: dict):
    if pingbi(event):
        return
    os.system("/root/QQbotFiles/QQbotFiles_update.sh")
    await update_file.finish("图库更新完成")


save = on_regex(pattern="^上传色图$")


@save.handle()
async def save_handle(bot: Bot, event: Event, state: dict):