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
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")}' )
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:
else: user = Utility.get_user_from_mention(message.content.split()[1]) alcoholic = Alcoholic(user.id) if not user: await message.channel.send( f'{message.author.mention}, тебе бы самому протрезветь {Utility.emote("CoolStoryBob")}' ) return if alcoholic.in_durka(): await message.channel.send( f'{user.mention}, меньше пить надо было! {Utility.emote("durka")}' ) return if alcoholic.timeout_mins_left() > 0 or alcoholic.alco_test() != 0: # юзер пьян, проверяем на наличие админских прав if Utility.has_permissions( message.author ): # админские права есть, снимаем опьянение и таймаут alcoholic.reset() alcoholic.hangover = False alcoholic.remove_timeout() if user is message.author: await message.channel.send( f'{user.mention} принял анальгина и протрезвел {Utility.emote("pill")}' ) else: await message.channel.send( f'{message.author.mention} дал {user.mention} анальгина, и {Utility.gender(user, "тот протрезвел.", "та протрезвела.")}' )