예제 #1
0
    def start(self):
        if self.vk_event.msg.lower() in ['идиот?', 'ты идиот?']:
            return "Мне потанцевать нельзя?"
        elif self.vk_event.msg.lower() in ['да?']:
            return {'attachments': 'video162408856_456239566'}

        bad_words = get_bad_words()

        if not check_user_group(self.vk_event.sender, Role.ADMIN):
            min_index_bad = len(self.vk_event.msg)
            max_index_bad = -1
            for word in bad_words:
                ind = self.vk_event.msg.lower().find(word)
                if ind != -1:
                    if ind < min_index_bad:
                        min_index_bad = ind
                    if ind > max_index_bad:
                        max_index_bad = ind

            min_index_bad = self.vk_event.msg.rfind(' ', 0, min_index_bad)
            if min_index_bad == -1:
                min_index_bad = self.vk_event.msg.rfind(',', 0, min_index_bad)
                if min_index_bad == -1:
                    min_index_bad = self.vk_event.msg.rfind(
                        '.', 0, min_index_bad)
                    if min_index_bad == -1:
                        min_index_bad = self.vk_event.msg.find('/')
            min_index_bad += 1
            if max_index_bad != -1:
                len_bad = self.vk_event.msg.find(',', max_index_bad)
                if len_bad == -1:
                    len_bad = self.vk_event.msg.find(' ', max_index_bad)
                    if len_bad == -1:
                        len_bad = self.vk_event.msg.find('?', max_index_bad)
                        if len_bad == -1:
                            len_bad = len(self.vk_event.msg)

                rand_int = get_random_int(len(BAD_ANSWERS) - 1)
                messages = [BAD_ANSWERS[rand_int]]
                name = self.vk_event.sender.name
                if self.vk_event.sender.gender == '1':
                    msg_self = "сама"
                else:
                    msg_self = "сам"
                messages.append(
                    f"{name}, может ты {msg_self} {self.vk_event.msg[min_index_bad: len_bad]}?"
                )
                return messages

        random_events = [["Да", "Ага", "Канеш", "Само собой", "Абсолютно"],
                         ["Нет", "Неа", "Ни за что", "Невозможно", "NO"],
                         [
                             "Ну тут даже я хз", "ДА НЕ ЗНАЮ Я", "Хз",
                             "Спроси у другого бота", "Да нет наверное"
                         ]]
        probability_events1 = [47, 47, 6]
        probability_events2 = [40, 15, 15, 15, 15]
        selected_event = random_event(random_events, probability_events1)
        selected_event2 = random_event(selected_event, probability_events2)
        return selected_event2
예제 #2
0
def get_praise_or_scold(vk_bot, vk_event, _type):
    if vk_event.args:
        vk_event.args[-1] = vk_event.args[-1].replace('-', '')
    if vk_event.original_args and vk_event.args[-1] in gender_translator:
        translator_key = vk_event.args[-1]
        del vk_event.args[-1]
    else:
        try:
            user = vk_bot.get_user_by_name(vk_event.original_args, vk_event.chat)
            if user.gender == '1':
                translator_key = 'ж1'
            else:
                translator_key = 'м1'
        except RuntimeWarning:
            translator_key = 'м1'
    if vk_event.args:
        recipient = " ".join(vk_event.args)

        if "петрович" in recipient.lower():
            if _type == 'bad':
                msg = random_event(BAD_ANSWERS)
            elif _type == 'good':
                msg = "спс))"
            else:
                msg = "wtf"
        else:
            word = get_from_db(gender_translator[translator_key], _type)
            msg = add_phrase_before(recipient, word, gender_translator[translator_key])
    else:
        msg = get_from_db(gender_translator[translator_key], _type)
    return msg
예제 #3
0
    def start(self):
        with lock:
            gamer = self.vk_bot.get_gamer_by_user(self.vk_event.sender)

            MIN_GAMERS = int(
                len(VkUser.objects.filter(chats=self.vk_event.chat)) / 2)
            if MIN_GAMERS < 2:
                MIN_GAMERS = 2
            rates_gamers = RateModel.objects.filter(chat=self.vk_event.chat)
            existed_rate = rates_gamers.filter(gamer=gamer)

            rate_gamer_str = ""
            for rate_gamer in rates_gamers:
                if rate_gamer.random:
                    rate_gamer_str += f"{str(rate_gamer.gamer)} - {rate_gamer.rate} (R)\n"
                else:
                    rate_gamer_str += f"{str(rate_gamer.gamer)} - {rate_gamer.rate}\n"

            if len(existed_rate) > 0:
                return f"Ставка уже поставлена\n" \
                       f"Игроки {len(rates_gamers)}/{MIN_GAMERS}:\n" \
                       f"{rate_gamer_str}"
            if self.vk_event.args:
                random = False
                arg = self.vk_event.args[0]
                self.check_number_arg_range(arg, 1, 100)
            else:
                random = True
                available_list = [x for x in range(1, 101)]
                rates = RateModel.objects.filter(chat=self.vk_event.chat)
                for rate_entity in rates:
                    available_list.pop(available_list.index(rate_entity.rate))
                if len(available_list) == 0:
                    return "Какая-то жесть, 100 игроков в ставке, я не могу больше придумать чисел, играйте(("
                arg = random_event(available_list)

            existed_another_rate = RateModel.objects.filter(
                chat=self.vk_event.chat, rate=arg)
            if len(existed_another_rate) > 0:
                return "Эта ставка уже поставлена другим игроком"

            RateModel(
                **{
                    'gamer': gamer,
                    'chat': self.vk_event.chat,
                    'rate': arg,
                    'random': random
                }).save()
            if random:
                rate_gamer_str += f"{gamer} - {arg} (R)\n"
            else:
                rate_gamer_str += f"{gamer} - {arg}\n"

            return f"Игроки {len(rates_gamers) + 1}/{MIN_GAMERS}:\n" \
                   f"{rate_gamer_str}"
예제 #4
0
 def start(self):
     return random_event(sorry_phrases)
예제 #5
0
파일: Rofl.py 프로젝트: Xoma163/xoma163site
 def start(self):
     return random_event([
         "хд", ":D", "ор", "ору", "😆", ":DDD", "лол", "кек",
         "лол кек чебурек", "рофл", "ахаха", "АХАХА"
     ])
예제 #6
0
 def start(self):
     if self.vk_event.command == 'ммм':
         return random_event(["Данон", "Хуета"])
     return "Хуета"
예제 #7
0
 def start(self):
     return random_event(self.names)
예제 #8
0
 def menu_picture(self):
     attachment = random_event([
         self.vk_bot.get_attachment_by_id('photo', None, 457242125),
         self.vk_bot.get_attachment_by_id('photo', None, 457242126)
     ], [90, 10])
     return {'attachments': [attachment]}