def send_success_message(self, bot): """Send a message for a successful pyramid.""" points = self.calculate_points(bot) if len(points) == 1: user = self.pyramid_builders[0] var = { "<USER>": bot.twitch.display_name(user), "<PRONOUN0>": bot.config.pronoun(user)[0], "<AMOUNT>": points[user], } bot.write(replace_vars(self.responses["pyramid"]["msg"], var)) bot.ranking.increment_points(user, points[user], bot) else: s = format_list( list( map(lambda x: bot.twitch.display_name(x), list(points.keys()))) ) # calls bot.displayName on every user p = format_list(list(points.values())) var = {"<MULTIUSERS>": s, "<AMOUNT>": p} bot.write(replace_vars(self.responses["multi_pyramid"]["msg"], var)) for u in list(points.keys()): bot.ranking.increment_points(u, points[u], bot) self.reset()
def successful_pleb_pyramid(self, bot): """Write messages and time out people on pleb pyramid.""" unique_users = list(set(self.pyramid_builders)) if len(unique_users) == 1: user = unique_users[0] if bot.get_permission(user) in [Permission.User, Permission.Subscriber]: var = { "<USER>": bot.twitch.display_name(user), "<PRONOUN0>": bot.config.pronoun(user)[0], } bot.write(replace_vars(self.responses["plebpyramid"]["msg"], var)) bot.timeout(user, 60) else: var = { "<USER>": bot.twitch.display_name(user), "<PRONOUN0>": bot.config.pronoun(user)[0], } bot.write(replace_vars(self.responses["mod_plebpyramid"]["msg"], var)) else: s = format_list( list(map(lambda x: bot.twitch.display_name(x), unique_users)) ) var = {"<MULTIUSERS>": s} bot.write(replace_vars(self.responses["multi_plebpyramid"]["msg"], var)) for u in unique_users: if bot.get_permission(u) in [Permission.User, Permission.Subscriber]: bot.timeout(u, 60) self.reset()
def game_winners(self, bot): """Announce game winners and give points.""" s = self.responses["game_over1"]["msg"] winners = self.monkalotparty.topranks() if winners is None: s += self.responses["game_over2"]["msg"] else: s += format_list(winners[0]) + " " for i in range(0, len(winners[0])): bot.ranking.increment_points(winners[0][i], winners[2], bot) var = {"<GAME_POINTS>": winners[1], "<USER_POINTS>": winners[2]} s += replace_vars(self.responses["game_over3"]["msg"], var) bot.write(s)