示例#1
0
    async def on_voice_state_update(self, member, before, after):
        Get = DB.Get()
        Set = DB.Set()
        if after.channel:
            channel = Get.options("channels")[0]
            category = Get.options("category")[0]

            if int(after.channel.id) == int(channel):
                cat = discord.utils.get(member.guild.categories,
                                        id=int(category))
                channel2 = await member.guild.create_voice_channel(
                    name=f"{member.name}#{member.discriminator}", category=cat)
                await member.move_to(channel2)
                await channel2.set_permissions(member, manage_channels=True)
                Set.privateChannels(channel2, member)

            elif before.channel:
                if str(before.channel.id) in str(
                        Get.privateChannels(member)[0]):
                    try:
                        await before.channel.delete()
                    except Exception:
                        pass

        else:
            if before.channel:
                if str(before.channel.id) in str(
                        Get.privateChannels(member)[0]):
                    try:
                        await before.channel.delete()
                    except Exception:
                        pass
示例#2
0
    async def unmutes(self, ctx, member: discord.Member):

        mutes = DB.Get().mute(member)
        mute = mutes[1]

        mute_role = discord.utils.get(ctx.message.guild.roles, name="Mute")

        if mute != 0:
            DB.Set().mute(member, 0)

            await member.remove_roles(mute_role)
            await ctx.send(embed=discord.Embed(
                description=f'**:white_check_mark: Mute by {member.mention} Successfully removed!**',))
        else:
            await ctx.send(
                embed=discord.Embed(description=f'**:warning: member {member.mention} Not muted!**',))
示例#3
0
    async def mutes(self, ctx, member: discord.Member, timenumber: int, typetime, *, reason):

        timed = 0

        if typetime == "s" or typetime == "sec" or typetime == "seconds":
            timed = timenumber
        elif typetime == "m" or typetime == "min" or typetime == "minutes":
            timed = timenumber * 60
        elif typetime == "h" or typetime == "hour" or typetime == "hours":
            timed = timenumber * 60 * 60
        elif typetime == "d" or typetime == "day" or typetime == "days":
            timed = timenumber * 60 * 60 * 24

        times = time.time()
        times += timed

        mute_role = discord.utils.get(ctx.message.guild.roles, name="RB_Muted")

        if not mute_role:
            mute_role = await ctx.guild.create_role(name="Muted")

        if mute_role in member.roles:
            await ctx.send(
                embed=discord.Embed(description=f'**:warning: Member {member.mention} already muted!**',))
        else:
            DB.Set().mute(member, times)

            await member.add_roles(mute_role,
                                   reason=f"Member {ctx.author.display_name} issued mute on {timenumber} {typetime} because of {reason}",
                                   atomic=True)
            await ctx.send(
                embed=discord.Embed(
                    description=f'**:shield: Mute to user {member.mention} successfully issued due to {reason}!**',))
示例#4
0
文件: sim.py 项目: vicever/zufang-1
def main(**args):
    modulepath = args['modulepath']
    finaldb_cut = os.path.join(modulepath, '../output/final.db.2')
    simdb = os.path.join(modulepath, '../output/sim.db')
    if os.path.exists(simdb):
        backup(simdb)
        os.remove(simdb)
    sim_merge(finaldb_cut, DB(simdb))
示例#5
0
def main(**args):
    modulepath = args['modulepath']
    linkdb = os.path.join(modulepath, '../data/link.db')
    path = os.path.join(modulepath, '../output/')
    pagelist = os.path.join(path, 'pagelist')

    pagespider = PageSpider()
    tasks = diff_task(linkdb, path, pagelist)

    db_pagelist = DB(pagelist)
    for filename in tasks:
        pagespider.crawl_to_file(
            url=tasks[filename]['url'],
            path=os.path.join(path, tasks[filename]['source']),
            filename=filename
        )
        db_pagelist.insert(filename)
示例#6
0
文件: main.py 项目: vicever/zufang-1
def main(**args):
    modulepath = args['modulepath']
    linkdb = os.path.join(modulepath, '../output/link.db')
    backup(linkdb)

    linkmeta = os.path.join(modulepath, '../output/link.meta')
    backup(linkmeta)
    run_linkspider(DB(linkdb), Meta(linkmeta))
示例#7
0
文件: main.py 项目: vicever/zufang-1
def main(**args):
    modulepath = args['modulepath']
    finaldb_cut = os.path.join(modulepath, '../output/final.db.2')
    jsondb_house = os.path.join(modulepath, '../output/zufang.house.json')
    simdb = os.path.join(modulepath, '../output/sim.db')
    if os.path.exists(jsondb_house):
        backup(jsondb_house)
        os.remove(jsondb_house)
    gen_house(finaldb_cut, DB(jsondb_house), simdb)
示例#8
0
 async def on_message(self, message):
     try:
         if message.channel.id in DB.Get().options("channels")["reactions"]:
             like = self.bot.get_emoji(671667959617552386)
             dislike = self.bot.get_emoji(671667959386603520)
             await message.add_reaction(like)
             await message.add_reaction(dislike)
     except Exception:
         pass
示例#9
0
    async def unwarn(self, ctx, ids: int):
        DB.Set().warns("remove", None, ids, None)
        unwarn_embed = discord.Embed(
            description=
            f"Варн, уникальный номер которого: `{ids}` был успешно снят!",
            color=config.COLOR_ERROR)

        unwarn_embed.set_footer(text=config.COPYRIGHT_TEXT,
                                icon_url=config.COPYRIGHT_ICON)
        await ctx.send(embed=unwarn_embed)
示例#10
0
    async def setreactions(self, ctx):
        await ctx.send("Введите ID каналов где бот будет ставить реакции для голосования (через пробелы) (у вас 60 секунд)")
        channels = await self.bot.wait_for('message', timeout=60.0, check=lambda
            message: message.author == ctx.author and message.channel == ctx.channel)

        data = [
            {"name": "channels", "update": f"reactions = '{channels.content}'", "insert": f'{channels.content}'}
        ]
        DB.Set().options(data)
        await ctx.send("Настройки успешно сохранены!")
示例#11
0
    async def unmute(self, ctx, member: discord.Member):

        mutes = DB.Get().mute(member)
        mute = mutes[1]

        mute_role = discord.utils.get(ctx.message.guild.roles, name="Mute")

        if mute != 0:
            DB.Set().mute(member, 0)

            await member.remove_roles(mute_role)
            await ctx.send(embed=discord.Embed(
                description=
                f'**:white_check_mark: Мьют у пользователя {member.mention} Успешно снят! **',
                color=config.COLOR_GOOD))
        else:
            await ctx.send(embed=discord.Embed(
                description=
                f'**:warning: Пользователь {member.mention} Не замьючен!**',
                color=config.COLOR_GOOD))
示例#12
0
def process(contentdb, housedb):
    hr = HouseRefinery(db=DB(housedb))
    hashurls = diff_task(contentdb, housedb)
    with open(contentdb, 'r') as f:
        for line in f:
            if not line:
                break
            hashurl, title, _, _, _, text = line.split('\t')[:6]
            if hashurl in hashurls:
                hr.parse(hashurl=hashurl, title=title, text=text)
                hashurls.remove(hashurl)
示例#13
0
    async def mute_loop(self):
        try:
            for mem in DB.Get().mute(None):
                mute = mem[1]
                guild = self.bot.get_guild(658658120309932062)
                if guild:
                    member = guild.get_member(int(mem[0]))
                    if member:
                        if float(mute) <= float(time.time()):
                            DB.Set().mute(member, 0)
                            mute_role = discord.utils.get(guild.roles,
                                                          name="Muted")
                            await member.remove_roles(
                                mute_role,
                                reason="Снят Мьют Временем",
                                atomic=True)

        except Exception as e:
            print(Fore.RED + "[ERROR] " + Style.RESET_ALL +
                  f"В цикле MUTE_LOOP произошла следующая ошибка:")
            print(Fore.RED + "[ERROR] " + Style.RESET_ALL + f"{e}")
            print(Fore.RED + "[ERROR] " + Style.RESET_ALL +
                  f"Цикл MUTE_LOOP продолжает свою работу!")
示例#14
0
def main():
    queries = []
    sentences = []
    # Reading the input file
    with open(queriesFile) as f:
        queries = f.readlines()
        sentences = [sent.strip() for sent in queries]

    tags = getCategory(queries)

    # Printing the result to console
    for i in range(len(tags)):
        print("Sentence: ", sentences[i])
        print("Category: ", DB(tags[i]).name, "\n")
示例#15
0
def process(pagedirs, contentdb):
    sources = os.listdir(pagedirs)
    ce = ContentExtractor(db=DB(contentdb))
    for source in sources:
        sourcedir = os.path.join(pagedirs, source)
        if not os.path.isdir(sourcedir):
            continue
        pagenames = os.listdir(sourcedir)
        pagenames = diff_task(pagenames, contentdb)
        for pagename in pagenames:
            hashurl = pagename
            pagename = os.path.join(sourcedir, pagename)
            with open(pagename, 'r') as f:
                ce.parse(page=f.read(), source=source, hashurl=hashurl)
示例#16
0
    async def setprivate(self, ctx):
        await ctx.send("Введите ID Категории для приватных каналов (у вас 60 секунд)")
        category = await self.bot.wait_for('message', timeout=60.0, check=lambda
            message: message.author == ctx.author and message.channel == ctx.channel)

        await ctx.send("Введите ID Канала для создания приватных каналов (у вас 60 секунд)")
        channel = await self.bot.wait_for('message', timeout=60.0, check=lambda
            message: message.author == ctx.author and message.channel == ctx.channel)

        data = [
            {"name": "channels", "update": f"private = '{channel.content}'", "insert": f'{channel.content}, null'},
            {"name": "category", "update": f"private = '{category.content}'", "insert": f'{category.content}'}
        ]
        DB.Set().options(data)
        await ctx.send("Настройки успешно сохранены!")
示例#17
0
    async def mute(self, ctx, member: discord.Member, timenumber: int,
                   typetime, *, reason):

        timed = 0

        if typetime == "s" or typetime == "сек" or typetime == "секунд":
            timed = timenumber
        elif typetime == "m" or typetime == "мин" or typetime == "минут":
            timed = timenumber * 60
        elif typetime == "h" or typetime == "час" or typetime == "часов":
            timed = timenumber * 60 * 60
        elif typetime == "d" or typetime == "день" or typetime == "дней":
            timed = timenumber * 60 * 60 * 24

        times = time.time()
        times += timed

        mute_role = discord.utils.get(ctx.message.guild.roles, name="RB_Muted")

        if not mute_role:
            mute_role = await ctx.guild.create_role(name="Muted")

        if mute_role in member.roles:
            await ctx.send(embed=discord.Embed(
                description=
                f'**:warning: Пользователь {member.mention} уже замьючен!**',
                color=config.COLOR_ERROR))
        else:
            DB.Set().mute(member, times)

            await member.add_roles(
                mute_role,
                reason=
                f"Пользователь {ctx.author.display_name} выдал мьют на {timenumber} {typetime} по причине {reason}",
                atomic=True)
            await ctx.send(embed=discord.Embed(
                description=
                f'**:shield: Мьют пользователю {member.mention} успешно выдан по причине {reason}!**',
                color=config.COLOR_GOOD))
示例#18
0
    async def warns(self, ctx, member: discord.Member = None):
        if not member:
            member = ctx.author

        a = []

        for i in DB.Get().warns(member):
            a.append(
                f"`ID - {i[0]}` | Модератор - {ctx.guild.get_member(int(i[2]))} | Причина - {i[3]}\n"
            )

        if not a:
            a = ["Юзер не имеет варнов"]

        embed = discord.Embed(title=f"Варны {member.display_name}",
                              description="".join(a),
                              color=config.COLOR_GOOD)

        embed.set_footer(text=config.COPYRIGHT_TEXT,
                         icon_url=config.COPYRIGHT_ICON)
        embed.set_thumbnail(url=ctx.author.avatar_url)
        await ctx.send(embed=embed)
示例#19
0
    async def warn(self, ctx, member: discord.Member, *, arg):
        ids = DB.Set().warns("add", member, ctx.author, arg)

        await ctx.send(
            f"Предупреждение пользователю {member.display_name} с причиной {arg} успешно выдано! (ID предупреждения - `{ids}`)"
        )
示例#20
0
    it to its corressponding SQL Query'''
arg_count = len(sys.argv) - 1
if arg_count == 1:
    filename = sys.argv[1]

with open(filename, 'r') as file:
    original = [line.strip() for line in file.readlines()]
sentences = original.copy()
tags = getCategory(sentences)

t = DBInterface()
t.start()

file = open("output.txt", "w")
for i, line in enumerate(original):
    tag = DB(tags[i]).name
    #print(tag,'||',line)
    categories = ['MOVIE', 'MUSIC', 'GEOGRAPHY']
    categories.remove(tag)
    query, eq = executeSQL(line, tag)
    if type(eq) == int:
        if eq == -1:
            stop = False
            while len(categories) > 0 and stop == False:
                tag = categories[0]
                categories.remove(tag)
                query, eq = executeSQL(line, tag)
                if type(eq) == int and eq == -1:
                    stop = False
                else:
                    stop = True