Beispiel #1
0
    async def set_modrole(self, ctx, *, role_id=None):
        """Set the role for moderators"""

        guild_id = ctx.guild.id

        if not role_id:
            await ctx.send(f"Usage: modrole role_id", delete_after=5)
            return

        if not ctx.guild.get_role(int(role_id)):
            ctx.send(f"Role with that ID could not be found", delete_after=5)
            return

        settings.set_value(guild_id, 'modrole', role_id)

        try:
            settings.save_config()

            await ctx.send(
                f'Moderator role changed to "{ctx.guild.get_role(int(role_id))}", {owouwu.gen()}'
            )
            print(
                f'Moderator role for {ctx.guild.id} ({ctx.guild.name}) changed to "{ctx.guild.get_role(int(role_id))}"'
            )
            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
Beispiel #2
0
    async def set_role(self, ctx, *, role_id=None):
        """Set no filter role"""

        guild_id = ctx.guild.id

        if not role_id:
            await ctx.send("Usage: filterrole role_id", delete_after=5)
            return

        try:
            role = ctx.guild.get_role(int(role_id))
            # save file
            settings.set_value(guild_id, 'filterrole', role_id)
            try:
                settings.save_config()
            except:
                await ctx.send(f'Command failed to execute', delete_after=5)
        except:
            print(f'Role for ID {role_id} not found')
            await ctx.send(f'Role for ID {role_id} not found', delete_after=5)
            return

        print(
            f'No filter role set to {ctx.guild.get_role(int(role_id))} in guild {ctx.guild.name}-{guild_id}'
        )
        await ctx.send(
            f'No filter role set to "{ctx.guild.get_role(int(role_id))}", {owouwu.gen()}',
            delete_after=5)
        await ctx.message.add_reaction('✅')
Beispiel #3
0
    async def filter_command(self, ctx, *, input=None):
        """Adjust filtered words"""

        guild_id = ctx.guild.id

        if not input:
            await ctx.send(f'Usage: filter add/remove word', delete_after=5)
            return

        args = input.split()

        if (len(args) < 2):
            await ctx.send(f'Usage: filter add/remove word', delete_after=5)
            return

        filter = json.loads(settings.get_value(guild_id, 'filter'))
        words = input.split()
        del words[0]  # delete the first term, the "operand"

        if (args[0] == 'add'):
            for word in words:
                filter.append(word)
        elif (args[0] == 'remove'):
            for word in words:
                filter.remove(word)
        else:
            await ctx.send(f'Usage: filter add/remove word word word',
                           delete_after=5)
            return

        # save the file, convert the ' to " first, since json dies
        settings.set_value(guild_id, 'filter', f'{filter}'.replace('\'', '"'))

        try:
            settings.save_config()

            if (args[0] == 'add'):
                await ctx.send(
                    f'{len(words)} words added to filter, {owouwu.gen()}',
                    delete_after=5)
            elif (args[0] == 'remove'):
                await ctx.send(
                    f'{len(words)} words removed from filter, {owouwu.gen()}',
                    delete_after=5)

            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
Beispiel #4
0
    async def set_logging(self, ctx, *, option: str):
        """Set guild logging yes/no"""

        guild_id = ctx.guild.id

        if not option or (option != 'yes' and option != 'no'):
            await ctx.send(f'Usage: logging yes/no', delete_after=5)
            return

        settings.set_value(guild_id, 'loggingenabled', option)

        try:
            settings.save_config()

            await ctx.send(f'Logging set to "{option}", {owouwu.gen()}')
            print(
                f'Logging for guild {ctx.guild.name} - {guild_id} set to "{option}", {owouwu.gen()}'
            )
            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
Beispiel #5
0
    async def set_prefix(self, ctx, *, prefix=None):
        """Set the prefix for all commands"""

        guild_id = ctx.guild.id

        if not prefix:
            await ctx.send(f"Usage: prefix prefix", delete_after=5)
            return

        settings.set_value(guild_id, 'prefix', prefix)

        try:
            settings.save_config()

            await ctx.send(f'Prefix changed to "{prefix}')
            print(
                f'Prefix for {ctx.guild.id} ({ctx.guild.name}) changed to "{prefix}"'
            )
            await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Command failed to execute', delete_after=5)
def get_ent_pos(path, out_path, machineName):
    origin_height = clip_specific_pic(path,
                                      out_path + machineName + "_clip.jpg")
    img = cv2.imread(out_path + machineName + "_clip.jpg")
    height, width, something = img.shape
    print "height = {}, width = {}".format(height, width)
    start_time = datetime.datetime.now()
    y_array = [0]
    array_flag = False
    for i in range(0, height, 2):
        # 行数遍历
        count = 0
        for j in range(0, width, 2):
            if img[i, j][0] >= 252 and img[i,
                                           j][1] >= 252 and img[i,
                                                                j][2] >= 252:
                count += 1
        if count >= width / 4:
            # print count
            if not array_flag:
                y_array.append(i)
                array_flag = True
        else:
            if array_flag:
                y_array.append(i - 1)
                array_flag = False
    print "pre-deal time = {}".format(datetime.datetime.now() - start_time)
    print y_array
    ent_part_pair = []
    for t in range(1, len(y_array)):
        if y_array[t] - y_array[t - 1] > 120:
            # 测试过程可以打开这个
            ent_part_pair.append((y_array[t - 1], y_array[t]))
    print ent_part_pair
    print "all time = {}".format(datetime.datetime.now() - start_time)
    x = width * 3 / 4
    leng_arr = len(ent_part_pair)
    # 特征直播间存起来,似乎不用裁剪,只要专门往上算10个px(有坐标就行),看这10个px平均RGB多少,拿什么存坐标呢(settings)
    # 还是要裁剪图片的,因为需要图片来判断是否进入直播间成功
    # 裁第几格子,这个要靠app判断,读配置文件
    conf_default = Config("default.ini")
    app_key = conf_default.getconf("default").app
    count = 2
    if app_key == "bigo":
        count = 1
    clip_specific_area(out_path + machineName + "_clip.jpg",
                       out_path + machineName + "_feature.jpg", width / 4,
                       ent_part_pair[leng_arr - count][0], width,
                       ent_part_pair[leng_arr - count][1])
    settings.set_value("feature_path", out_path + machineName + "_feature.jpg")
    settings.set_value("ent_top_pos_x", x)
    settings.set_value(
        "ent_top_pos_y",
        ent_part_pair[leng_arr - count][0] + origin_height * 0.12)
    # 潜规则,要加上12%的高度,因为裁图裁掉了12%
    y = (ent_part_pair[leng_arr - count][0] +
         ent_part_pair[leng_arr - count][1]) / 2 + origin_height * 0.12
    print "finally x = {}, y = {}".format(x, y)
    return x, y
Beispiel #7
0
    async def set_logchannel(self, ctx, *, channel_id: str):
        """Set guild logs channel"""

        guild_id = ctx.guild.id

        if not channel_id:
            await ctx.send(f'Usage: logchannel channel_id', delete_after=5)
            return

        try:
            if ctx.guild.get_channel(int(channel_id)):
                settings.set_value(guild_id, 'logchannel', channel_id)
                settings.save_config()

                await ctx.send(
                    f'Logging channel set to "{channel_id}", {owouwu.gen()}')
                print(
                    f'Logging channel for guild {ctx.guild.name} - {guild_id} set to "{channel_id}", {owouwu.gen()}'
                )
                await ctx.message.add_reaction('✅')
        except:
            await ctx.send(f'Usage: logchannel channel_id', delete_after=5)
            return
Beispiel #8
0
def start_python(serial_num, params):
    bussinessEntarnce = BusinessEntrance(serial_num, params)
    # 加上下面两行
    settings._init()
    settings.set_value("ffmpeg", 30)
    bussinessEntarnce.screenmain()
Beispiel #9
0
            serial.append(item)
    return serial


def enterMethodDelegate(methodDelegatedObject):
    return methodDelegatedObject.screenmain()


def start_python(serial_num, params):
    bussinessEntarnce = BusinessEntrance(serial_num, params)
    # 加上下面两行
    settings._init()
    settings.set_value("ffmpeg", 30)
    bussinessEntarnce.screenmain()


if __name__ == "__main__":
    getDevices()
    # p = Pool(5)
    for index in range(len(serial)):
        serNum = serial[index]
        bussinessEntarnce = BusinessEntrance(serNum, 1)
        # 加上下面两行
        settings._init()
        settings.set_value("ffmpeg", 30)
        bussinessEntarnce.screenmain()
    #     result = p.apply_async(enterMethodDelegate, args=(bussinessEntarnce,))
    #     result.get()
    # p.close()
    # p.join()