Exemplo n.º 1
0
    def start(self):
        clear = replace_similar_letters(self.event.message.clear)
        if clear in ['идиот?', 'ты идиот?']:
            return "Мне потанцевать нельзя?"
        elif clear in ['да?']:
            return "https://youtu.be/ePddSQQl2kc"

        bad_words = get_bad_words()

        # if not self.event.sender.check_role(Role.ADMIN):
        min_index_bad = len(clear)
        max_index_bad = -1
        for word in bad_words:
            ind = clear.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 = clear.rfind(' ', 0, min_index_bad)
        if min_index_bad == -1:
            min_index_bad = clear.rfind(',', 0, min_index_bad)
            if min_index_bad == -1:
                min_index_bad = clear.rfind('.', 0, min_index_bad)
                if min_index_bad == -1:
                    min_index_bad = clear.find('/')
        min_index_bad += 1
        if max_index_bad != -1:
            len_bad = clear.find(',', max_index_bad)
            if len_bad == -1:
                len_bad = clear.find(' ', max_index_bad)
                if len_bad == -1:
                    len_bad = clear.find('?', max_index_bad)
                    if len_bad == -1:
                        len_bad = len(clear)

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

        random_events = [["Да", "Ага", "Канеш", "Само собой", "Абсолютно"],
                         ["Нет", "Неа", "Ни за что", "Нуу... нет", "NO"],
                         ["Ну тут даже я хз", "ДА НЕ ЗНАЮ Я", "Хз", "Спроси у другого бота", "Да нет наверное"]]
        probability_events1 = [47, 47, 6]
        probability_events2 = [40, 15, 15, 15, 15]
        seed = clear
        selected_event = random_event(random_events, probability_events1, seed=seed)
        selected_event2 = random_event(selected_event, probability_events2, seed=seed)
        return selected_event2
Exemplo n.º 2
0
 def send_turett(self, event):
     chance = self.NOT_MENTIONED_CHANCE if event.chat.mentioning else self.MENTIONED_CHANCE
     if random_probability(chance):
         if isinstance(event.bot, TgBot):
             if random_probability(self.STICKER_CHANCE):
                 msg = random_event(TURETT_WORDS)
             else:
                 stickers = event.bot.get_sticker_set("SamPriFle")
                 random_sticker = random_event(stickers)
                 tg_sticker = StickerAttachment()
                 tg_sticker.parse_tg_sticker(random_sticker, event.bot)
                 msg = {'attachments': tg_sticker}
         else:
             msg = random_event(TURETT_WORDS)
         event.bot.parse_and_send_msgs(msg, event.peer_id)
Exemplo n.º 3
0
 def menu_picture(self):
     photos = random_event(
         [f"{STATIC_ROOT}/bot/img/roulette_game.jpg",
          f"{STATIC_ROOT}/bot/img/roulette.jpg"],
         [90, 10])
     attachments = self.bot.upload_photos(photos, peer_id=self.event.peer_id)
     return {'attachments': attachments}
Exemplo n.º 4
0
def get_praise_or_scold(bot, event, _type):
    if event.message.args_str and event.message.args[-1].replace('-', '') in gender_translator:
        translator_key = event.message.args[-1].replace('-', '')
        args_case = event.message.args_case[:-1]
    else:
        try:
            user = bot.get_profile_by_name(event.message.args_str, event.chat)
            if user.gender == '1':
                translator_key = 'ж1'
            else:
                translator_key = 'м1'
        except PWarning:
            translator_key = 'м1'
        args_case = event.message.args_case

    if event.message.args:
        recipient = " ".join(args_case)

        if "петрович" in recipient.lower():
            if _type == 'bad':
                msg = random_event(BAD_ANSWERS)
            elif _type == 'good':
                msg = "спс))"
            else:
                msg = "wtf"
        else:
            msg = get_from_db(gender_translator[translator_key], _type)
            if recipient:
                msg = add_phrase_before(recipient, msg, gender_translator[translator_key])

    else:
        msg = get_from_db(gender_translator[translator_key], _type)
    return msg
Exemplo n.º 5
0
    def start(self):
        with lock:
            gamer = self.bot.get_gamer_by_profile(self.event.sender)

            min_gamers = int(
                len(Profile.objects.filter(chats=self.event.chat)) / 2)
            if min_gamers < 2:
                min_gamers = 2
            rates_gamers = RateModel.objects.filter(chat=self.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:
                raise PWarning(f"Ставка уже поставлена\n"
                               f"Игроки {len(rates_gamers)}/{min_gamers}:\n"
                               f"{rate_gamer_str}")
            if self.event.message.args:
                random = False
                arg = self.event.message.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.event.chat)
                for rate_entity in rates:
                    available_list.pop(available_list.index(rate_entity.rate))
                if len(available_list) == 0:
                    raise PWarning(
                        "Какая-то жесть, 100 игроков в ставке, я не могу больше придумать чисел, играйте(("
                    )
                arg = random_event(available_list)

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

            RateModel(
                **{
                    'gamer': gamer,
                    'chat': self.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}"
Exemplo n.º 6
0
 def start(self):
     phrases = [
         "Извини", "Нет", "Сам извинись", "за что?", "КАВО", "Ты уверен?",
         "а может быть ты извинишься?", "ок"
     ]
     phrase = random_event(phrases)
     self.bot.parse_and_send_msgs(phrase, self.event.peer_id)
     if phrase == "Извини":
         if random_probability(33):
             time.sleep(3)
             self.bot.parse_and_send_msgs("сь", self.event.peer_id)
Exemplo n.º 7
0
 def start(self):
     answers = [
         "И ваc тоже, и вам тогоже", "УРААААААААААА",
         [
             "ННОООООВВЫЫЫЫЙ ГОД К НАМ МЧИТСЯ", "СКООООРААА ВСЁ СЛУЧИТСЯ",
             "СБУУДЕТСЯ ЧТО СНИТСЯ",
             "ЧТО ОПЯТЬ НАС ОБМАНУТ, НИЧЕГО НЕ ДАДУТ",
             "https://youtu.be/xviBEvbxgZ0"
         ], {
             'attachments':
             self.bot.upload_photos(f"{STATIC_ROOT}/bot/img/sng.jpg",
                                    peer_id=self.event.peer_id)
         }, "https://youtu.be/8PzPHKGpNXs", "https://youtu.be/pESX7mQwTNU"
     ]
     answer = random_event(answers)
     return answer
Exemplo n.º 8
0
    def menu_play(self):
        with lock:
            datetime_now = localize_datetime(datetime.datetime.utcnow(),
                                             DEFAULT_TIME_ZONE)
            winner_today = PetrovichGames.objects.filter(
                chat=self.event.chat).first()
            if winner_today:
                datetime_last = localize_datetime(remove_tz(winner_today.date),
                                                  DEFAULT_TIME_ZONE)
                if (datetime_now.date() - datetime_last.date()).days <= 0:
                    if winner_today.profile.gender and winner_today.profile.gender == '1':
                        winner_gender = "Петровна"
                    else:
                        winner_gender = "Петрович"
                    return f"{winner_gender} дня - {winner_today.profile}"

            group_banned = Group.objects.get(name=Role.BANNED.name)
            winner = PetrovichUser.objects.filter(
                chat=self.event.chat, active=True).exclude(
                    profile__groups=group_banned).order_by("?").first()
            if winner:
                winner = winner.profile
            else:
                raise PWarning(
                    "Нет участников игры. Зарегистрируйтесь! /петрович рег")

            winner_petrovich = PetrovichGames(profile=winner,
                                              chat=self.event.chat)
            winner_petrovich.save()
            if winner.gender and winner.gender == '1':
                winner_gender = "Наша сегодняшняя Петровна дня"
            else:
                winner_gender = "Наш сегодняшний Петрович дня"

            first_message = random_event([
                "Такс такс такс, кто тут у нас", "*барабанная дробь*",
                "Вы готовы узнать победителя голодных игр?", "Ну шо, погнали",
                "Вы не поверите...",
                "Опять вы в игрульки свои играете да? Ну ладно"
            ])

            return [
                first_message,
                f"{winner_gender} - {self.bot.get_mention(winner, str(winner))}"
            ]
Exemplo n.º 9
0
 def start(self):
     sorry_phrases = ["лан", "нет", "окей", "ничего страшного", "Петрович любит тебя", "я подумаю", "ой всё",
                      "ну а чё ты :(", "всё хорошо", "каво", "сь", '...', 'оке', 'ладно, но больше так не делай']
     return random_event(sorry_phrases)
Exemplo n.º 10
0
 def start(self):
     return random_event(self.full_names)
Exemplo n.º 11
0
 def start(self):
     if self.event.message.command == 'ммм':
         return random_event(["Данон", "Хуета"])
     return "Хуета"
Exemplo n.º 12
0
 def start(self):
     return random_event(
         ["Всегда пожалуйста", "На здоровье", "Обращайся", "<3"])