Example #1
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

        command = ctx.Content.split(' ', 1)
        print(command)
        if command[0] == "latex" and len(command) > 1:
            latex_content = command[1]
            url = 'https://quicklatex.com/latex3.f'

            data = {"formula": transfer_spacing(latex_content), "fcolor": "000000", "fsize": "70px", "mode": "0", "out": "1", "remhost": "quicklatex.com"}
            response = post(url, data)
            content = response.text.split("\r\n")
            if content[0] == "0":
                pic_url = content[1].split(' ')[0]
                print(pic_url)
                action.send_friend_pic_msg(ctx.FromUin, picUrl=pic_url, timeout=20)
            else:
                action.send_friend_text_msg(ctx.FromUin, "无法识别公式!")
Example #2
0
def receive_friend_msg(ctx: FriendMsg):
    setu_allow = False
    if ctx.FromUin != configuration.qq:
        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':
            command = ctx.Content.split(' ')
            if command[0] == "setu":
                if setu_allow:
                    if len(command) == 2:
                        execute = command[1]
                    else:
                        execute = "drawings"

                    id_url = "http://jinfans.top/setu/latest/view/random?type=" + execute
                    id_image = get_html_text(id_url)
                    id_json = json.loads(id_image)
                    url = "http://jinfans.top/setu/latest/view/direct/" + id_json["_id"]
                    action.send_friend_pic_msg(ctx.FromUin, content=execute, picUrl=url)
                else:
                    action.send_friend_text_msg(ctx.FromUin, content='ф╜ахЬицГ│ЁЯНС')
Example #3
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':
            command = ctx.Content.split(' ')
            if command[0] == "点歌":

                # check
                plugin = PluginControl()
                if not plugin.check("点歌", ctx.FromUserId, ctx.FromGroupId):
                    return

                if len(command) == 2:
                    content = xml_get_qq(command[1])
                    print(content)
                    action.send_group_xml_msg(ctx.FromGroupId, content)
                if len(command) == 3:
                    content = xml_get_qq(command[1], int(command[2]))
                    print(content)
                    action.send_group_xml_msg(ctx.FromGroupId, content)
Example #4
0
def receive_group_msg(ctx: GroupMsg):
    userGroup = ctx.FromGroupId
    if (userGroup in blockGroupNumber):
        return
    qq = ctx.FromUserId
    c = ctx.Content
    if (c.startswith('#赞我')):
        f = read(ctx.FromUserId)
        if (f == 0):
            Action(ctx.CurrentQQ).send_group_text_msg(
                ctx.FromGroupId,
                content='正在赞~~请稍等,大概花费30s左右',
                atUser=ctx.FromUserId)
            nowTime = returnDate()
            save(nowTime, ctx.FromUserId)

            for i in range(50):
                Action(ctx.CurrentQQ).like(ctx.FromUserId)
                time.sleep(0.4)
            Action(ctx.CurrentQQ).send_group_text_msg(ctx.FromGroupId,
                                                      content='赞好啦~请查收',
                                                      atUser=ctx.FromUserId)
        else:
            if (isToday(f) == 1):
                Text('你已经赞过了,请明天在来吧~')
            else:
                Action(ctx.CurrentQQ).send_group_text_msg(
                    ctx.FromGroupId,
                    content='正在赞~~请稍等,大概花费30s左右',
                    atUser=ctx.FromUserId)
                nowTime = returnDate()
                save(nowTime, ctx.FromUserId)

                for i in range(50):
                    Action(ctx.CurrentQQ).like(ctx.FromUserId)
                    time.sleep(0.4)
                Action(ctx.CurrentQQ).send_group_text_msg(
                    ctx.FromGroupId, content='赞好啦~请查收', atUser=ctx.FromUserId)
Example #5
0
def receive_events(ctx: EventMsg):
    # 这样写是因为第一次整这个插件时事件上下文还是字典,
    # 这里我因为懒得改了,所以这样写
    # 用对象的字段会方便和简洁一点,自己修改吧
    ctx = ctx.message  #
    ######################
    action = Action(ctx['CurrentQQ'])
    data = ctx['CurrentPacket']['Data']

    # 欢迎新群员
    if data['EventName'] == "ON_EVENT_GROUP_JOIN":
        uid = data['EventData']['UserID']
        uname = data['EventData']['UserName']
        gid = data['EventMsg']['FromUin']
        action.send_group_text_msg(gid, '欢迎<%s>入群![表情175]' % uname, uid)
        return

    # 群友退群
    if data['EventName'] == "ON_EVENT_GROUP_EXIT":
        uid = data['EventData']['UserID']
        gid = data['EventMsg']['FromUin']
        action.send_group_text_msg(
            gid, f'群友【{uid}】\n[表情107]离开了本群!\n[表情66]请珍惜在一起的每一分钟!')
        return
Example #6
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

        command = ctx.Content.split(' ')
        if command[0] == "runpython" and len(command) == 2:

            if not judge_name(command[1]):
                action.send_friend_text_msg(ctx.FromUin, content="文件名非法")
                return

            res = runpy(command[1])
            action.send_friend_text_msg(ctx.FromUin, content=res)

        # 判断用\r还是\n
        char_r = ctx.Content.find('\r')
        char_n = ctx.Content.find('\n')
        if (char_r < char_n and char_r != -1) or char_n == -1:
            char = '\r'
        else:
            char = '\n'

        print(char_r, char_n, char_r < char_n or char_n == -1, char)

        all_content = ctx.Content.split(char, 1)

        if len(all_content) == 2:
            command = all_content[0].split(' ')
            pycontent = all_content[1]

        if len(command) == 2 and command[0] == "newpython" and command[1][
                -3:] == ".py":

            if not judge_name(command[1]):
                action.send_friend_text_msg(ctx.FromUin, content="文件名非法")
                return

            if not judge_py(pycontent):
                action.send_friend_text_msg(ctx.FromUin, content="文件包含不允许的字符串")
                return

            res = newpy(command[1], pycontent)
            if res:
                action.send_friend_text_msg(ctx.FromUin,
                                            content=command[1] + " 创建成功")
            else:
                action.send_friend_text_msg(ctx.FromUin, content="文件创建失败")
Example #7
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':

            if ctx.Content[:3] == "计时 ":

                # check
                plugin = PluginControl()
                if not plugin.check("计时", ctx.FromUserId, ctx.FromGroupId):
                    return

                command_time = ctx.Content.lstrip("计时 ")
                if time_shift(command_time):
                    sleep_time = time_shift(command_time)
                    if sleep_time > 4294967:
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   "爷发现你输入了非法参数:\n设置时间过长!")
                    elif sleep_time < 0:
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   "爷发现你输入了非法参数:\n设置时间为负!")
                    else:
                        action.send_group_text_msg(ctx.FromGroupId, "爷开始计时啦!")
                        time.sleep(sleep_time)
                        msg = " 计时 " + command_time + " 结束!"
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   atUser=ctx.FromUserId,
                                                   content=msg)
                else:
                    action.send_group_text_msg(ctx.FromGroupId, "非法时间格式!")

            if ctx.Content[:3] == "闹钟 ":

                # check
                plugin = PluginControl()
                if not plugin.check("闹钟", ctx.FromUserId, ctx.FromGroupId):
                    return

                command = ctx.Content.lstrip("闹钟 ").split(' ', 1)
                time_array = alarm_shift(command[1])
                if time_array:
                    time_stamp = int(time.mktime(time_array))
                    sleep_time = time_stamp - int(time.time())
                    print(sleep_time)
                    if sleep_time <= 0:
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   "爷发现你输入了非法参数:\n设定时间已过!")
                    else:
                        action.send_group_text_msg(ctx.FromGroupId, "爷设好闹钟啦!")
                        time.sleep(sleep_time)
                        msg = " 闹钟 " + f"""{command[0]}""" + " 到时间啦!"
                        action.send_group_text_msg(ctx.FromGroupId,
                                                   atUser=ctx.FromUserId,
                                                   content=msg)
                else:
                    action.send_group_text_msg(ctx.FromGroupId,
                                               "爷发现你输入了非法参数:\n非法时间格式!")
Example #8
0
    """
    for ch in check_str:
        if u'\u4e00' <= ch <= u'\u9fff':
            return True
    return False


def to_unicode(check_str):
    ret = ""
    for v in check_str:
        ret = ret + hex(ord(v)).upper().replace("0X", "\\u")
    return ret


bot = IOTBOT(157199224, log=False)
action = Action(bot, queue=False)

bOpenThisBOT = True
dataCiliGroupData = {}

nAAAAAAAA = 91

nReciveTimes = 0

LEFT_PART_VERTICAL_BLANK_MULTIPLY_FONT_HEIGHT = 2
LEFT_PART_HORIZONTAL_BLANK_MULTIPLY_FONT_WIDTH = 1 / 4
RIGHT_PART_VERTICAL_BLANK_MULTIPLY_FONT_HEIGHT = 1
RIGHT_PART_HORIZONTAL_BLANK_MULTIPLY_FONT_WIDTH = 1 / 4
RIGHT_PART_RADII = 10
BG_COLOR = "#000000"
BOX_COLOR = "#F7971D"
Example #9
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':
        command = ctx.Content.split(' ')
        if command[0] == "说话" and len(command) >= 2:

            text = command[1]
            voiceId = "geyou"
            speed = "1.5"
            volume = "100"
            audioType = "wav"
            for i in range(len(command) - 2):
                if command[i + 2][:8] == 'voiceId=':
                    voiceId = command[i + 2].lstrip('voice=Id')
                elif command[i + 2][:6] == 'speed=':
                    speed = command[i + 2].lstrip('speed=')
                elif command[i + 2][:7] == 'volume=':
                    volume = command[i + 2].lstrip('volume=')
                elif command[i + 2][:10] == 'audioType=':
                    audioType = command[i + 2].lstrip('audioType=')

            url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \
               "&volume=" + volume + "&audioType=" + audioType + "&text=" + text

            action.send_friend_voice_msg(ctx.FromUin, url)

        elif command[0] == "对话" and len(command) >= 2:

            ask = command[1]
            voiceId = "geyou"
            speed = "1.5"
            volume = "100"
            audioType = "wav"
            for i in range(len(command) - 2):
                if command[i + 2][:8] == 'voiceId=':
                    voiceId = command[i + 2].lstrip('voice=Id')
                elif command[i + 2][:6] == 'speed=':
                    speed = command[i + 2].lstrip('speed=')
                elif command[i + 2][:7] == 'volume=':
                    volume = command[i + 2].lstrip('volume=')
                elif command[i + 2][:10] == 'audioType=':
                    audioType = command[i + 2].lstrip('audioType=')

            res_url = "https://api.ownthink.com/bot?appid=xiaosi&spoken=" + ask

            res = json.loads(get_html_text(res_url))

            print(res)
            if res["message"] == "error":
                action.send_friend_text_msg(ctx.FromUin, "对话请求错误!")
                return
            elif not res["data"]["type"] == 5000:
                action.send_friend_text_msg(ctx.FromUin, "对话返回错误!")
                return
            else:
                text = res["data"]["info"]["text"]

            url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \
               "&volume=" + volume + "&audioType=" + audioType + "&text=" + text

            action.send_friend_voice_msg(ctx.FromUin, url)
Example #10
0
def receive_friend_msg(ctx: FriendMsg):
    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

        if ctx.Content[:3] == "计时 ":

            command_time = ctx.Content.lstrip("计时 ")
            if time_shift(command_time):
                sleep_time = time_shift(command_time)
                if sleep_time > 4294967:
                    action.send_friend_text_msg(ctx.FromUin,
                                                "爷发现你输入了非法参数:\n设置时间过长!")
                elif sleep_time < 0:
                    action.send_friend_text_msg(ctx.FromUin,
                                                "爷发现你输入了非法参数:\n设置时间为负!")
                else:
                    action.send_friend_text_msg(ctx.FromUin, "爷开始计时啦!")
                    time.sleep(sleep_time)
                    msg = " 计时 " + command_time + " 结束!"
                    action.send_friend_text_msg(ctx.FromUin, content=msg)
            else:
                action.send_friend_text_msg(ctx.FromUin, "非法时间格式!")

        if ctx.Content[:3] == "闹钟 ":

            command = ctx.Content.lstrip("闹钟 ").split(' ', 1)
            time_array = alarm_shift(command[1])
            if time_array:
                time_stamp = int(time.mktime(time_array))
                sleep_time = time_stamp - int(time.time())
                print(sleep_time)
                if sleep_time <= 0:
                    action.send_friend_text_msg(ctx.FromUin,
                                                "爷发现你输入了非法参数:\n设定时间已过!")
                else:
                    action.send_friend_text_msg(ctx.FromUin, "爷设好闹钟啦!")
                    time.sleep(sleep_time)
                    msg = " 闹钟 " + f"""{command[0]}""" + " 到时间啦!"
                    action.send_friend_text_msg(ctx.FromUin, content=msg)
            else:
                action.send_friend_text_msg(ctx.FromUin,
                                            "爷发现你输入了非法参数:\n非法时间格式!")
Example #11
0
from iotbot import Action, GroupMsg
from iotbot.decorators import equal_content, not_botself

action = Action(123456, queue=False, queue_delay=2)  # 唯一写法


@not_botself
@equal_content('queue')
def receive_group_msg(ctx: GroupMsg):
    action.send_group_text_msg(ctx.FromGroupId, '这条消息每次发送间隔不会低于2秒。。。')
Example #12
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':
            command = ctx.Content.split(' ')
            if command[0] == "说话" and len(command) >= 2:

                # check
                plugin = PluginControl()
                if not plugin.check("说话", ctx.FromUserId, ctx.FromGroupId):
                    return

                text = command[1]

                # param
                param = plugin.find_one("说话", ctx.FromGroupId)["param"]
                voiceId = str(param["voiceId"])
                speed = str(param["speed"])
                volume = str(param["volume"])
                audioType = str(param["audioType"])
                for i in range(len(command) - 2):
                    if command[i + 2][:8] == 'voiceId=':
                        voiceId = command[i + 2].lstrip('voice=Id')
                    elif command[i + 2][:6] == 'speed=':
                        speed = command[i + 2].lstrip('speed=')
                    elif command[i + 2][:7] == 'volume=':
                        volume = command[i + 2].lstrip('volume=')
                    elif command[i + 2][:10] == 'audioType=':
                        audioType = command[i + 2].lstrip('audioType=')

                url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \
                   "&volume=" + volume + "&audioType=" + audioType + "&text=" + text

                action.send_group_voice_msg(ctx.FromGroupId, url)

            elif command[0] == "对话" and len(command) >= 2:

                # check
                plugin = PluginControl()
                if not plugin.check("对话", ctx.FromUserId, ctx.FromGroupId):
                    return

                ask = command[1]

                # param
                param = plugin.find_one("对话", ctx.FromGroupId)["param"]
                voiceId = str(param["voiceId"])
                speed = str(param["speed"])
                volume = str(param["volume"])
                audioType = str(param["audioType"])
                for i in range(len(command) - 2):
                    if command[i + 2][:8] == 'voiceId=':
                        voiceId = command[i + 2].lstrip('voice=Id')
                    elif command[i + 2][:6] == 'speed=':
                        speed = command[i + 2].lstrip('speed=')
                    elif command[i + 2][:7] == 'volume=':
                        volume = command[i + 2].lstrip('volume=')
                    elif command[i + 2][:10] == 'audioType=':
                        audioType = command[i + 2].lstrip('audioType=')

                res_url = "https://api.ownthink.com/bot?appid=xiaosi&spoken=" + ask

                res = json.loads(get_html_text(res_url))

                print(res)
                if res["message"] == "error":
                    action.send_group_text_msg(ctx.FromGroupId, "对话请求错误!")
                    return
                elif not res["data"]["type"] == 5000:
                    action.send_group_text_msg(ctx.FromGroupId, "对话返回错误!")
                    return
                else:
                    text = res["data"]["info"]["text"]

                url = "https://dds.dui.ai/runtime/v1/synthesize?voiceId=" + voiceId + "&speed=" + speed + \
                   "&volume=" + volume + "&audioType=" + audioType + "&text=" + text

                action.send_group_voice_msg(ctx.FromGroupId, url)
Example #13
0
def receive_friend_msg(ctx: FriendMsg):

    action = Action(configuration.qq)
    if ctx.MsgType == 'TextMsg':

        command = ctx.Content.split(' ')
        if command[0] == "百度" and len(command) > 1:
            baidu_content = get_text(command[1])
            url_new = "https:" + get_html_url("https://baike.baidu.com/search/word?word=" + command[1])
            print("内容", baidu_content, baidu_content == "")

            if baidu_content == "":
                action.send_friend_text_msg(ctx.FromUin, "爷没有搜索到结果!")
            else:
                if len(command) == 2:
                    action.send_friend_text_msg(ctx.FromUin, baidu_content[:] + url_new)
                elif len(command) == 3:
                    try:
                        i = int(command[2])
                    except:
                        action.send_friend_text_msg(ctx.FromUin, "爷发现你输入了非法参数!")
                    if i > 0:
                        action.send_friend_text_msg(ctx.FromUin, baidu_content[:i] + "......\n\n" + url_new)
                    else:
                        action.send_friend_text_msg(ctx.FromUin, "爷发现你输入了非法参数!")
                else:
                    action.send_friend_text_msg(ctx.FromUin, "爷发现你输入了非法参数!")
Example #14
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        # check
        plugin = PluginControl()
        if not plugin.check("百度", ctx.FromUserId, ctx.FromGroupId):
            return

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':

            command = ctx.Content.split(' ')
            if command[0] == "百度" and len(command) > 1:
                baidu_content = get_text(command[1])
                url_new = "https:" + get_html_url("https://baike.baidu.com/search/word?word=" + command[1])
                print("内容", baidu_content, baidu_content == "")

                if baidu_content == "":
                    action.send_group_text_msg(ctx.FromGroupId, "爷没有搜索到结果!")
                else:
                    if len(command) == 2:
                        action.send_group_text_msg(ctx.FromGroupId, baidu_content[:] + url_new)
                    elif len(command) == 3:
                        try:
                            i = int(command[2])
                        except:
                            action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
                        if i > 0:
                            action.send_group_text_msg(ctx.FromGroupId, baidu_content[:i] + "......\n\n" + url_new)
                        else:
                            action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
                    else:
                        action.send_group_text_msg(ctx.FromGroupId, "爷发现你输入了非法参数!")
Example #15
0
from iotbot import Action, GroupMsg
from iotbot.decorators import equal_content, not_botself

action = Action(123456, queue=True, queue_delay=2)  # 唯一写法


@not_botself
@equal_content('queue')
def receive_group_msg(ctx: GroupMsg):
    action.send_group_text_msg(ctx.FromGroupId, '这条消息每次发送间隔不会低于2秒。。。', callback=print)
import json
import os
import random
import re
import threading
import time
from time import sleep

import iotbot.decorators as deco
import schedule
from iotbot import IOTBOT, Action, GroupMsg, EventMsg

from Utils import utils, SQLiteUtils, BaiduApi, ciyunUtil, weatherUtil

bot = IOTBOT(1328382485, log_file=True)
action = Action(bot, queue=True, queue_delay=2)


def getGroupList():
    GroupID = []
    groupList = action.get_group_list()
    TroopList = groupList['TroopList']
    for group in TroopList:
        GroupID.append(group['GroupId'])
    return GroupID


def sent_wyy():
    print("网抑云定时任务执行成功")
    file = os.listdir('wyy')[random.randint(0, 9)]
    groupList = getGroupList()
Example #17
0
# ==========================================

import base64
import os
from enum import Enum

import requests
from googletrans import Translator
from iotbot import Action, GroupMsg, FriendMsg

try:
    import ujson as json
except:
    import json

bot = Action(qq_or_bot=int(os.getenv('BOTQQ')), queue=True, queue_delay=0.5)

# ==========================================


def receive_friend_msg(ctx: FriendMsg):
    if ctx.FromUin == ctx.CurrentQQ:
        return

    userQQ = ctx.FromUin
    msg = ctx.Content

    handlingmessages_friend(msg, bot, userQQ)


def receive_group_msg(ctx: GroupMsg):
Example #18
0
# https://github.com/yuban10703/IOTQQ-color_pic
import os
import re

import requests
from iotbot import Action
from iotbot import GroupMsg
from iotbot import decorators as deco
from iotbot.sugar import Text

pattern = r'来(.*?)[点丶份张幅](.*?)的?[色瑟涩][图圖]'
api = 'http://api.yuban10703.xyz:2333/setu_v3'

action = Action(int(os.getenv('BOTQQ') or 123456), queue=True)


@deco.not_botself
@deco.in_content(pattern)
def receive_group_msg(ctx: GroupMsg):
    num = 1
    tag = ''

    info = re.findall(pattern, ctx.Content)
    if info:
        num = int(info[0][0] or 1)
        tag = info[0][1]
    if num > 5:
        Text('服了,要那么多干嘛,我只发5张!')
        num = 5

    try:
Example #19
0
import httpx
from PIL import Image, ImageDraw, ImageFilter, ImageFont
from dateutil.parser import parse
from iotbot import Action, GroupMsg

try:
    import ujson as json
except:
    import json

# ==========================================

bot = Action(
    # 注意更换您的 bot.py 文件为最新
    qq_or_bot=int(os.getenv('BOTQQ')),
    queue=True,
    queue_delay=0.5)


# @not_botself
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId == ctx.CurrentQQ:
        return
    userGroup = ctx.FromGroupId

    if Tools.commandMatch(userGroup, blockGroupNumber):
        return

    if not Tools.textOnly(ctx.MsgType):
        return
Example #20
0
def receive_group_msg(ctx: GroupMsg):
    if ctx.FromUserId != configuration.qq:

        # check
        plugin = PluginControl()
        if not plugin.check("python", ctx.FromUserId, ctx.FromGroupId):
            return

        action = Action(configuration.qq)
        if ctx.MsgType == 'TextMsg':

            command = ctx.Content.split(' ')
            if command[0] == "runpython" and len(command) == 2:

                if not judge_name(command[1]):
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content="文件名非法")
                    return

                res = runpy(command[1])
                action.send_group_text_msg(ctx.FromGroupId, content=res)

            # 判断用\r还是\n
            char_r = ctx.Content.find('\r')
            char_n = ctx.Content.find('\n')
            if (char_r < char_n and char_r != -1) or char_n == -1:
                char = '\r'
            else:
                char = '\n'

            all_content = ctx.Content.split(char, 1)

            if len(all_content) == 2:
                command = all_content[0].split(' ')
                pycontent = all_content[1]

            if len(command) == 2 and command[0] == "newpython" and command[1][
                    -3:] == ".py":

                if not judge_name(command[1]):
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content="文件名非法")
                    return

                if not judge_py(pycontent):
                    action.send_group_text_msg(ctx.FromGroupId, " 文件包含不允许的字符串")
                    return

                res = newpy(command[1], pycontent)

                if res:
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content=command[1] + " 创建成功")
                else:
                    action.send_group_text_msg(ctx.FromGroupId,
                                               content="文件创建失败")
Example #21
0
# -*- coding:utf-8 -*-

import json
import os
import time

import pymysql
from iotbot import GroupMsg, FriendMsg, Action

from util.db.config import config

action = Action(
    # 注意更换您的 bot.py 文件为最新
    qq_or_bot=int(os.getenv('BOTQQ')))


class Mysql:
    def __init__(self):
        self.db = pymysql.connect(host=config.mysql_host,
                                  port=config.mysql_port,
                                  user=config.mysql_user,
                                  password=config.mysql_pass,
                                  database=config.mysql_db,
                                  charset='utf8mb4')
        self.cursor = self.db.cursor(pymysql.cursors.DictCursor)

    def __del__(self):
        self.cursor.close()
        self.db.close()

    def commit(self, sql):
Example #22
0
parser.add_argument('--log-path',
                    default=os.path.sep.join(('logs', 'log.txt')),
                    help='Path to log file')
args = parser.parse_args()

if args.verbose:
    logging.basicConfig(level=logging.INFO)
else:
    logging.basicConfig(level=logging.ERROR)

# bot类
bot = IOTBOT(configuration.qq,
             use_plugins=True,
             plugin_dir=args.plugin_dir,
             log_file_path=args.log_path)
action = Action(bot)

# 插件控制类
plugins = PluginControl()

# admin命令接受

from admin.admin_else import admin_else_group, admin_else_friend

bot.add_group_msg_receiver(admin_else_group)
bot.add_friend_msg_receiver(admin_else_friend)

from admin.admin_refresh import admin_refresh_group, admin_refresh_friend

bot.add_group_msg_receiver(partial(admin_refresh_group, bot))
bot.add_friend_msg_receiver(partial(admin_refresh_friend, bot))
Example #23
0
def receive_group_msg(ctx: GroupMsg):
    bot = Action(qq_or_bot=ctx.CurrentQQ, host=host, port=port)
    if not Tools.commandMatch(ctx.FromGroupId, blockGroupNumber):
        mainEntrance(ctx.Content.strip(), ctx.FromUserId, ctx.FromGroupId, bot)