예제 #1
0
 async def check_rage_situations(self, user: discord.Member,
                                 channel: discord.TextChannel, action: str,
                                 rage_to: discord.Member):
     if action == self.rage_replies[0]:
         await channel.send(f'{user.mention}{action}'.format(
             rage_to.mention))
         if bool(random.getrandbits(1)):
             throw = random.choice(self.rage_throw_glass)
             await channel.send(
                 throw.format(
                     rage_to.mention,
                     Utility.gender(rage_to, "возбудился", "возбудилась")))
         else:
             await channel.send(
                 f'Вы промахнулись, стакан вдребезги разбился о стену')
     elif action == self.rage_replies[6]:
         alcoholic = Alcoholic(user.id)
         drink_name = random.choice(list(self.random_drinks.keys()))
         drink = self.random_drinks[drink_name]
         alcoholic.set_alco(alcoholic.alco_test() + drink[1])
         await channel.send(f'{user.mention}{action}'.format(
             drink_name, rage_to.mention))
     else:
         await channel.send(f'{user.mention}{action}'.format(
             rage_to.mention))
예제 #2
0
async def gift_drink_to_user(author, user, channel, drink_name,
                             give_compliment):
    if user == author:
        await channel.send(
            f'{user.mention}, у Вас биполярочка? {Utility.emote("durka")}')
    elif Alcoholic(author.id).in_durka():
        if Alcoholic(user.id).in_durka():  # автор и юзер в дурке
            await channel.send(
                f'{user.mention}, Вас {Utility.gender(author, "угостил", "угостила")}'
                +
                f'{author.mention}! Держите, Ваши антидепрессанты {Utility.emote("pill")} {Utility.emote("durka")}'
            )
        else:  # только автор в дурке
            await channel.send(
                f'{user.mention}, Вам передачка из дурки! {author.mention} {Utility.gender(author, "угостил", "угостила")}'
                +
                f' Вас непонятными таблетками {Utility.emote("pill")} {Utility.emote("durka")}'
            )
    elif Alcoholic(user.id).in_durka():  # только юзер в дурке
        await channel.send(
            random.choice([
                f'{author.mention}, а может мы лучше Вас заберём? {Utility.emote("durka")}',
                f'{author.mention}, никаких передачек в дурку! {Utility.emote("durka")}'
            ]))
    else:
        await bartender.give_drink(user,
                                   channel,
                                   drink_name=drink_name,
                                   gift_giver=author,
                                   give_compliment=give_compliment)
예제 #3
0
def choose_set_alco_phrase(author, user, alco_diff, success):
    if success:
        alcoholic = Alcoholic(user.id)
        if user is author:
            if alco_diff < 0:
                return f'{author.mention} {Utility.gender(author, "разбавил", "разбавила")} водой свой напиток,' +\
                    f' и теперь {Utility.gender(author, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("MHM")}'
            elif alco_diff == 0:
                return f'{author.mention}, ты и так {Utility.gender(author, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("MHM")}'
            else:
                return f'{author.mention} {Utility.gender(author, "подмешал", "подмешала")} что-то себе в напиток,' +\
                    f' и теперь {Utility.gender(author, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("monkaS")}'
        else:
            if alco_diff < 0:
                return f'{author.mention} {Utility.gender(author, "разбавил", "разбавила")} водой напиток {user.mention} \n' +\
                    f'Теперь {Utility.gender(user, "он", "она")} {Utility.gender(user, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("MHM")}'
            elif alco_diff == 0:
                return f'{author.mention} {Utility.gender(author, "подмешал", "подмешала")} что-то {user.mention} в напиток \n' +\
                    f'Это ничего не изменило, и {user.mention} до сих пор {Utility.gender(user, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("MHM")}'
            else:
                return f'{author.mention} {Utility.gender(author, "подмешал", "подмешала")} что-то {user.mention} в напиток \n' +\
                    f'{user.mention} теперь {Utility.gender(user, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("monkaS")}'
    elif user is author or user is None:
        return f'У {Utility.gender(author, "юного клофелинщика", "юной клофелинщицы")} {author.mention} ничего не получилось, и ' +\
            f'{Utility.gender(author, "он", "она")} до сих пор {Utility.gender(author, "пьян", "пьяна")}' +\
            f' на {Alcoholic(author.id).alco_test()}% {Utility.emote("LULW")}'
    else:
        return f'У {Utility.gender(author, "юного клофелинщика", "юной клофелинщицы")} {author.mention} ничего не получилось, и {user.mention} до сих пор ' +\
            f'{Utility.gender(user, "пьян", "пьяна")} на {Alcoholic(user.id).alco_test()}% {Utility.emote("LULW")}'
예제 #4
0
 async def rage(self, user: discord.Member, channel: discord.TextChannel,
                rage_to: discord.Member):
     alcoholic = Alcoholic(user.id)
     if rage_to.id == Constants.ZAKHOZHKA_ID:
         await channel.send(
             f"{rage_to.mention} получает ладошкой по лбу от {user.mention}"
         )
     elif alcoholic.timeout_mins_left() > 0:
         await channel.send(
             f"{user.mention}, ты слишком пьян для этого, проспись!")
     elif alcoholic.alco_test() >= 50:
         action = random.choice(self.rage_replies)
         await self.check_rage_situations(user, channel, action, rage_to)
     else:
         await channel.send(
             f'Вы же не настолько пьяны, чтобы делать это? {Utility.emote("monkaSpolice")}'
         )
예제 #5
0
async def gift_drink_to_multiple_users(author, users, channel, drink_name):
    for user in users:
        if Alcoholic(user.id).in_durka():
            await channel.send(
                f'{user.mention}, Вам {Utility.gender(author, "передал", "передала")} успокоительное '
                +
                f'{Utility.gender(author, "Ваш вымышленный друг", "Ваша вымышленная подруга")} {author.mention} {Utility.emote("durka")}'
            )
        else:
            await bartender.give_drink(user,
                                       channel,
                                       drink_name=drink_name,
                                       gift_giver=author,
                                       give_compliment=None)
예제 #6
0
    async def give_drink(self,
                         user: discord.Member,
                         channel: discord.TextChannel,
                         drink_name: str = None,
                         gift_giver: discord.Member = None,
                         give_compliment: bool = None):
        alcoholic = Alcoholic(user.id)
        if alcoholic.alco_test() == 0:
            alcoholic.reset()

        if (minutes_left :=
                alcoholic.timeout_mins_left()) > 0:  # таймаут уже есть
            if gift_giver:
                await channel.send(
                    f'{gift_giver.mention}, не трогай {user.mention}, {Utility.gender(user, "ему", "ей")} бы проспаться.'
                    +
                    f' {Utility.emote("Pepechill")} Попробуй угостить через {str(minutes_left)} {Utility.minutes(minutes_left)}.'
                )
            else:
                await channel.send(
                    f'{user.mention}, тебе бы проспаться. {Utility.emote("Pepechill")} Приходи через {minutes_left} {Utility.minutes(minutes_left)}.'
                )
            return
예제 #7
0
 async def check_alco(self, user: discord.Member,
                      channel: discord.TextChannel):
     alcoholic = Alcoholic(user.id)
     if alcoholic.timeout_mins_left == 0 and alcoholic.hangover is True:
         # тайамут из-за полного опьянения был, но прошёл. обнуляем значения, и поднимаем процент оставшегося опьянения до рандомного значения
         mins_after_timeout = (
             datetime.datetime.now() -
             alcoholic.hangover_untill).total_seconds() // 60
         recovered_after_timeout = mins_after_timeout * alcoholic.recovery_rate
         alcoholic.set_alco(
             random.randrange(30, 70) - recovered_after_timeout)
     alco_test = alcoholic.alco_test()
     if alco_test == 0:
         alcoholic.reset()
     if alco_test == 100:
         await channel.send(
             random.choice([
                 f'{user.mention}, выглядишь на все :100: {Utility.emote("MonkaChrist")}',
                 f'{user.mention}, ты {Utility.gender(user, "пьян", "пьяна")} на 100% {Utility.emote("Pepechill")} \nИди проспись! {Utility.emote("MHM")}'
             ]))
     else:
         await channel.send(
             f'{user.mention}, ты {Utility.gender(user, "пьян", "пьяна")} на {alcoholic.alco_test()}% {Utility.emote("Pepechill")}'
         )
예제 #8
0
 def is_available(u: discord.Member):
     return u.status is not discord.Status.offline and u not in banned_users and not Alcoholic(
         u.id).in_durka()
예제 #9
0
async def on_message(message: discord.Message):
    if message.author == client.user:
        return

    if ('бармен' in message.content.lower()
            or client.user.mention in message.content) and any(
                thanks in message.content.lower()
                for thanks in ['спасибо', 'благодарю', 'спс', 'благодарен']):
        if Alcoholic(message.author.id).in_durka():
            await message.channel.send(
                f'{message.author.mention}, Вы с кем разговариваете? {Utility.emote("durka")}'
            )
        else:
            await bartender.reply_thanks(message.author, message.channel)

    elif message.content == '!БАРМЕН' or message.content.startswith('БАРМЕН'):
        await message.channel.send(
            f'{message.author.mention}, зачем Вы кричите на меня? {Utility.emote("pepeHands")}'
        )

    elif message.content.lower() == '!бармен' or message.content.lower(
    ) == 'бармен?' or message.content.lower() == 'бармен!':
        if Alcoholic(message.author.id).in_durka():
            await message.channel.send(
                f'{message.author.mention}, Вы с кем разговариваете? {Utility.emote("durka")}'
            )
        elif message.author.id == Constants.HACKERMAN_ID and message.content == 'бармен!':  # админская команда на активацию всякой всячины
            bartender.special = not bartender.special
            await message.channel.send(
                f'{message.author.mention}, я за барной стойкой! {Utility.emote("pepeClown")}'
            )
        else:
            await message.channel.send(
                f'{message.author.mention}, я за барной стойкой! {Utility.emote("pepeOK")}'
            )

    # !алко - проверяет степень опьянённости юзера
    # Денис, мы по тебе скучаем
    if message.content == '!алко':
        if Alcoholic(message.author.id).in_durka():
            await message.channel.send(
                f'{message.author.mention}, опять за своё? {Utility.emote("durka")}'
            )
        else:
            await bartender.check_alco(message.author, message.channel)

    # !алко [new_alco [@юзер]] - меняет степень опьянения юзера на new_aclo
    # если юзер не указан, действует на автора сообщения
    if message.content.startswith('!алко') and len(
            message.content.split()) > 1:
        if Alcoholic(message.author.id).in_durka():
            await message.channel.send(
                f'{message.author.mention}, опять за своё? {Utility.emote("durka")}'
            )
            return
        if len(message.content.split()) == 2:
            user = message.author
        else:
            user = Utility.get_user_from_mention(message.content.split()[2])
            if user:
                try:
                    new_alco_percent = Utility.clip(
                        int(message.content.split()[1]), 0, 100)
                except ValueError:
                    new_alco_percent = None
            else:
                user = Utility.get_user_from_mention(
                    message.content.split()[1])
                try:
                    new_alco_percent = Utility.clip(
                        int(message.content.split()[2]), 0, 100)
                except ValueError:
                    new_alco_percent = None
        if user:
            alcoholic = Alcoholic(user.id)
        if new_alco_percent is not None and user:
            # шанс успеха команды зависит от разницы нового и старого значений
            # чем меньше разница, тем больше шанс на успех
            alco_diff = new_alco_percent - alcoholic.alco_test()
            success = random.randrange(101) >= abs(alco_diff)
            if message.content.split(
            )[0] == '!алко_' and Utility.has_permissions(message.author):
                # админская команда для 100% шанса на успех
                success = True
            elif alcoholic.timeout_mins_left(
            ) > 0:  # у полностью пьяного юзера нельзя менять степень опьянения
                success = False
        else:
            alco_diff = 0
            success = False
        if success and alco_diff != 0:
            alcoholic.remove_timeout()
            alcoholic.set_alco(new_alco_percent)
        if user:
            del alcoholic  # call the destructor to push data into the db
        await message.channel.send(
            choose_set_alco_phrase(message.author, user, alco_diff, success))

    # !выпить [напиток] - наливает автору напиток
    # если напиток не указан, наливает рандомный напиток
    if message.content.startswith('!выпить'):
        if Alcoholic(message.author.id).in_durka():
            await message.channel.send(
                f'Пожалуйста, {message.author.mention}, Ваше успокоительное {Utility.emote("durka")}'
            )
        elif len(message.content.split()) > 1:
            drink = ' '.join(message.content.split()[1:])
            await bartender.give_drink(message.author, message.channel, drink)
        else:
            await bartender.give_drink(message.author, message.channel)

    if message.content == '!угостить барную стойку':
        if Alcoholic(message.author.id).in_durka():
            await message.channel.send(
                f'Пациент начинает буянить! {Utility.emote("durka")}')
            return
        voice_channel = discord.utils.get(Constants.GUILD.voice_channels,
                                          name='Ещё на барных стульях')
        for user in [
                u for u in voice_channel.members if u is not message.author
        ]:
            if Alcoholic(user.id).in_durka():
                await message.channel.send(
                    f'{user.mention}, Вам {Utility.gender(message.author, "передал", "передала")} успокоительное '
                    +
                    f'{Utility.gender(message.author, "Ваш вымышленный друг", "Ваша вымышленная подруга")} {message.author.mention} {Utility.emote("durka")}'
                )
            else:
                await bartender.give_drink(user,
                                           message.channel,
                                           gift_giver=message.author)

    # !угостить (@юзер [напиток]) - наливает юзеру напиток
    # если напиток не указан, наливает рандомный напиток
    elif message.content.startswith('!угостить'):
        if len(message.content.split()) <= 1:
            await message.channel.send(
                f'{message.author.mention}, кого угощать собрались? {Utility.emote("CoolStoryBob")}'
            )
            return
        users = []
        drink = ' '.join(message.content.split()[2:]).lower() if len(
            message.content.split()) > 2 else None
        if message.mention_everyone:
            if Utility.has_permissions(message.author):
                users = Utility.get_available_users(
                    Constants.GUILD.members, [message.author, Constants.BOT])
            else:
                await message.channel.send(
                    f'Сразу так много клиентов не смогу обслужить, простите {Utility.emote("FeelsBanMan")}'
                )
                return
        else:
            if (voice_channel :=
                    Utility.get_voice_channel_from_message(message.content)):
                drink_name = message.content.lower().replace(
                    f'!угостить {voice_channel.name.lower()}', '').lstrip()
                if not drink_name:
                    drink_name = None
                for user in [
                        u for u in voice_channel.members
                        if u is not message.author
                ]:
                    if Alcoholic(user.id).in_durka() > 0:
                        await message.channel.send(
                            f'{user.mention}, Вам {Utility.gender(message.author, "передал", "передала")} успокоительное '
                            +
                            f'{Utility.gender(message.author, "Ваш вымышленный друг", "Ваша вымышленная подруга")} {message.author.mention} {Utility.emote("durka")}'
                        )
                    else:
                        await bartender.give_drink(user,
                                                   message.channel,
                                                   gift_giver=message.author,
                                                   drink_name=drink_name)
                return
            else:
                if (role := Utility.get_role_from_mention(
                        message.content.split()[1])):
                    users = Utility.get_available_users(
                        role.members, [message.author, Constants.BOT])
                    if not users and len(role.members) == 1 and message.author in role.members and \
                            not Alcoholic(message.author.id).in_durka():
                        await gift_drink_to_user(message.author,
                                                 message.author,
                                                 message.channel, drink, None)
                        return
                else:
예제 #10
0
     users = Utility.get_available_users(
         role.members, [message.author, Constants.BOT])
     if not users and len(role.members) == 1 and message.author in role.members and \
             not Alcoholic(message.author.id).in_durka():
         await gift_drink_to_user(message.author,
                                  message.author,
                                  message.channel, drink, None)
         return
 else:
     if (user := Utility.get_user_from_mention(
             message.content.split()[1])):
         if user.id == Constants.COOKIE_ID and drink == 'пиво':
             await message.channel.send(
                 f'{user.mention}, тебя {Utility.gender(message.author, "угостил", "угостила")} {message.author.mention}. Держи своё холодное пиво и горячие гренки. Кушай, кушай! {Utility.emote("beer")} {Utility.emote("MHM")}'
             )
             alcoholic = Alcoholic(user.id)
             if alcoholic.alco_test() <= 50:
                 alcoholic.set_alco(69)
             else:
                 alcoholic.set_alco(alcoholic.alco_test() + 5)
             return
         else:
             await gift_drink_to_user(message.author, user,
                                      message.channel, drink,
                                      None)
             return
     elif message.content.split()[1] == Utility.emote('YROD'):
         user = discord.utils.get(Constants.GUILD.members,
                                  id=Constants.HACKERMAN_ID)
         await gift_drink_to_user(message.author, user,
                                  message.channel, drink, False)