예제 #1
0
파일: main.py 프로젝트: Kosted/farbot
async def old(ctx, top: int = 9999):
    all_members_with_days = list()
    for member in ctx.guild.members:
        all_members_with_days.append([
            get_nick_or_name(member),
            (datetime.datetime.today() - member.joined_at).days
        ])

    all_members_with_days.sort(key=itemgetter(1), reverse=True)
    count = 0
    for member, time in all_members_with_days:
        if member == get_nick_or_name(ctx.author):
            res = '{author}, вы на {place} месте - {time} дней на сервере\n\n'.format(
                place=count, author=member, time=time)
            count = 0
            break
        count += 1

    for member, time in all_members_with_days[:top]:
        # res += member[0].name + " : " + str(member[1].days) + " дней на сервере\n"
        res += '{count}. {name} : {time} дней на сервере\n'.format(count=count,
                                                                   name=member,
                                                                   time=time)
        count += 1
        if len(res) > 1500:
            print(res)
            await send_and_add_reaction_for_delete(ctx, res)
            res = ''
    print(res)
    await send_and_add_reaction_for_delete(ctx, res)
예제 #2
0
파일: main.py 프로젝트: Kosted/farbot
async def say(ctx, *args):
    # TODO: проверить метод на кросгильдность и сделать его таким в противном случае
    author = ctx.message.author
    voice = author.voice
    author_name = get_nick_or_name(author)
    if voice is not None:
        voice = voice.channel
        if len(bot.voice_clients) == 0:
            await voice.connect()
    else:
        await send_and_add_reaction_for_delete(
            ctx,
            author_name + ", вы не подключены не к одному голосовому каналу")
        return

    text = " ".join(args)
    if text_converter.spam(text):
        await send_and_add_reaction_for_delete(
            ctx, author_name +
            " не спамь. Если бот ошибся и это не было спамом сообщите Fargus#3924"
        )
        return

    # text = text[:200]

    text = text_converter.remove_non_alphanumeric(
        author_name) + " говорит: " + text[:200]

    if text[:40] not in file_list:
        file_path = google_voice.convert_text_to_voice(text)
    else:
        file_path = "voice_files/" + text[:40] + ".mp3"
    voice_clients = bot.voice_clients
    voice_clients[0].play(discord.FFmpegPCMAudio(file_path))
예제 #3
0
파일: main.py 프로젝트: Kosted/farbot
async def members_with_role(ctx, *role_name: str):
    required_role = get_role_by_name(" ".join(role_name), ctx.guild.roles)
    if type(required_role) == list:
        await send_and_add_reaction_for_delete(
            ctx.channel,
            "Я нашел несколько ролей похожих на то, что вы искали: {}.\nУточните запрос."
            .format(", ".join(role.name for role in required_role)))
        return

    if required_role:
        res = 'Роль "' + required_role.name + '" имеют ' + str(
            len(required_role.members)) + ' человек.\n'
        if required_role.name == "@everyone":
            res += 'Или иными словами - все на этом сервере и для справки вообще каждый человек в дискорде'
            res = res.replace("@everyone", 'everyone')
        else:
            if len(required_role.members) != 0:
                members_with_required_role = [
                    get_nick_or_name(member)
                    for member in required_role.members
                ]
                res += 'А конкретно: ' + ", ".join(members_with_required_role)
        await send_and_add_reaction_for_delete(ctx, res)
    else:
        res = 'Не могу найти похожей роли. Вот все роли, что имеются на сервере:\n'
        res += ", ".join([roles.name for roles in ctx.guild.roles][1:])
        await send_and_add_reaction_for_delete(ctx, res)
예제 #4
0
파일: main.py 프로젝트: Kosted/farbot
async def stream_notify(ctx, *term):
    member = ctx.author
    member_name = get_nick_or_name(member)
    role = get_role_by_name("Жду стрима", ctx.guild.roles)
    if len(term) != 0:
        term = term[0]
    else:
        await send_and_add_reaction_for_delete(
            ctx,
            member_name + ", введите после команды stream \"+\" либо \"-\"")
        return
    if term == "+":
        await member.add_roles(role)
        await send_and_add_reaction_for_delete(
            ctx, member_name + ", роль \"Жду Стрима\" добавлена")
    elif term == "-":
        role = get_role_by_name("Жду стрима", member.roles)
        if role is not None:
            await member.remove_roles(role)
            await send_and_add_reaction_for_delete(
                ctx, member_name +
                ", больше вас не будут предупреждать о начале стрима")
        else:
            await send_and_add_reaction_for_delete(
                ctx, member_name + ", у вас нет роли \"Жду Стрима\"")

    else:
        await send_and_add_reaction_for_delete(
            ctx, member_name + ", введите \"+\" либо \"-\"")
예제 #5
0
파일: main.py 프로젝트: Kosted/farbot
async def when_i_joined(ctx):
    author_name = get_nick_or_name(ctx.author)
    temp = datetime.datetime.today() - ctx.author.joined_at
    # print(type(ctx.guild.members))
    # if ctx.channel.name == "флудильня":
    res = "Товарищ " + author_name + ", вы присоединились к серверу " + str(
        temp.days) + " дней назад"
    # else:
    #     res = 'Напиши во "флудильню", не захламляй другие чаты'
    await send_and_add_reaction_for_delete(ctx, res)
예제 #6
0
파일: events.py 프로젝트: Kosted/farbot
 async def t(self, ctx):
     url = 'https://i.gifer.com/RTjF.gif'
     embed_obj = make_embed(None,
                            None,
                            get_nick_or_name(ctx.author),
                            url,
                            'футерэ',
                            url,
                            url,
                            asdf='asdfasdf',
                            jasdjf='ifjaidjflasjdflsjadf')
     await ctx.send(embed=embed_obj)
예제 #7
0
파일: main.py 프로젝트: Kosted/farbot
async def clear_all_message(ctx, count_on_delete_message: int):
    count = 0
    authors_of_deleted_messages = {}
    async for message in ctx.channel.history(limit=count_on_delete_message +
                                             1):
        message_author_name = get_nick_or_name(message.author)
        if message_author_name in authors_of_deleted_messages:
            authors_of_deleted_messages[message_author_name] += 1
        else:
            authors_of_deleted_messages[message_author_name] = 1
        await message.delete()
        count += 1

    # удаление упомнинания об команде удаления в отчете от бота
    authors_of_deleted_messages[get_nick_or_name(ctx.author)] -= 1
    if authors_of_deleted_messages[get_nick_or_name(ctx.author)] == 0:
        authors_of_deleted_messages.pop(get_nick_or_name(ctx.author))

    res = "Я удалил " + str(count - 1) + " сообщений\n"
    for elem in list(authors_of_deleted_messages.items()):
        res += str(elem[1]) + ' от ' + elem[0] + '\n'
    await ctx.send(res, delete_after=5)
예제 #8
0
파일: main.py 프로젝트: Kosted/farbot
async def leave(ctx):
    # TODO: проверить метод на кроссерверность и сделать его таким в противном случае
    author = ctx.message.author
    voice = author.voice

    author_name = get_nick_or_name(author)

    if voice is not None:
        author_voice = voice.channel
    else:
        await send_and_add_reaction_for_delete(
            ctx,
            author_name + ", вы не подключены не к одному голосовому каналу")
        return
    if len(bot.voice_clients) == 0:
        await send_and_add_reaction_for_delete(ctx, "Бот не подключен к чату")
        return
    else:
        if bot.voice_clients[0].channel.id != author_voice.id:
            await send_and_add_reaction_for_delete(
                ctx, author_name + ", вы с ботом находитесь в разных чатах")
            return
        await bot.voice_clients[0].disconnect()