Example #1
0
def sync_main():
    PlaySoundeffectRequest(user="******", command="openingbell").save()

    while True:
        try:
            peasants = ChatLogs().recent_stream_peasants()
            # We need to make this better
            result = drop_random_soundeffect_to_user(
                random.sample(peasants, 1)[0])
            send_twitch_msg(result)

            for peasant in peasants:
                if peasant not in BLACKLIST:
                    user = User(peasant)
                    user_karma = user.karma()
                    print(f"@{peasant} Karma: {user.karma()}")
                    user.update_street_cred(1)
                    # user.update_street_cred(1 + user_karma)
                    user.revive(3 + user_karma)

            send_twitch_msg("CoolCat CoolCat CoolCat")
            # formatted_peasants = [f"@{peasant}" for peasant in peasants]
            # send_twitch_msg(
            #     f"Squid1 Enjoy your street cred: {' '.join(formatted_peasants)} Squid4"
            # )

            # Every 5 minutes, all the chatters have a chance at some street cred
            # os.system("time make deploy")
            time.sleep(300)
        except Exception as e:
            time.sleep(30)
            if e is KeyboardInterrupt:
                raise e
            else:
                traceback.print_exc()
Example #2
0
 def random_user(self, blacklisted_users=[]):
     try:
         looking_for_user = True
         while looking_for_user:
             users = ChatLogs().recent_stream_peasants()
             user = random.sample(users, 1)[0]
             if user not in INVALID_USERS + blacklisted_users:
                 looking_for_user = False
         return user
     except:
         traceback.print_exc()
Example #3
0
    def test_inform(self):
        Vote("fake_user").vote("peace")
        result = LaLibre.inform()
        self.coup = Command("coup")
        User("fake_user").save()

        peasants = ChatLogs().recent_stream_peasants()
        threshold = 3

        assert result == [
            "PowerUpL La Libre PowerUpR",
            "Total Votes: 1",
            f"Peace Count: 1 / {threshold}",
            f"Revolution Count: 0 / {threshold}",
            f"panicBasket Coup Cost: {self.coup.cost()} panicBasket",
        ]
Example #4
0
 def threshold(cls) -> int:
     peasants = ChatLogs().recent_stream_peasants()
     value = int(len(peasants) / REVOLUTION_LIKELYHOOD)
     if value < DEFAULT_THRESHOLD:
         return DEFAULT_THRESHOLD
     return value
Example #5
0
 def test_recent_stream_peasants(self):
     msg_counts = ChatLogs().recent_stream_peasants()
     assert msg_counts
Example #6
0
 def test_most_msgs(self):
     msg_counts = ChatLogs().most_msgs()
     assert len(msg_counts) > 10
Example #7
0
 def test_users(self):
     users = ChatLogs().users()
     assert len(users) > 10