diff --git a/bot.py b/bot.py index b70c973..291cd13 100755 --- a/bot.py +++ b/bot.py @@ -40,26 +40,34 @@ class Server(BaseServer): else: game = " ".join(line.params[1].split(" ")[1:]).lower() ping = "" + user = line.source.split('!')[0] if game not in match_players[self.name + '-' + chan]: await self.send(build("PRIVMSG", [chan, "ERROR: no players in "+ game])) else: - for player in match_players[self.name + '-' + chan][game]: - pfold = self.casefold(player) - if pfold in channel.users: - ping += f"{channel.users[pfold].nickname} " - else: - ping += f"{player} " + matches = match_players[self.name + '-' + chan][game] + others = list(set(matches) - set([user])) # don't ping the user who .matched + + if len(others) > 0: + for player in others: + pfold = self.casefold(player) + if pfold in channel.users: + ping += f"{channel.users[pfold].nickname} " + else: + ping += f"{player} " + + await self.send(build("PRIVMSG", [chan, "Anyone ready for " + game + f" : {ping} ?"])) + if connections[self.name]: + for connection,address in connections[self.name].items(): + if connection in line.params[1]: + if ':' in address: + realaddress = address.split(':')[0] + port = address.split(':')[1] + self.send(build("PRIVMSG", [chan, f"Connect using nc {realaddress} {port}"])) + else: + self.send(build("PRIVMSG", [chan, f"Connect using nc {address} 1234"])) + else: + await self.send(build("PRIVMSG", [chan, user + ": you're the only one who plays this game :("])) - await self.send(build("PRIVMSG", [chan, "Anyone ready for " + game + f" : {ping} ?"])) - if connections[self.name]: - for connection,address in connections[self.name].items(): - if connection in line.params[1]: - if ':' in address: - realaddress = address.split(':')[0] - port = address.split(':')[1] - self.send(build("PRIVMSG", [chan, f"Connect using nc {realaddress} {port}"])) - else: - self.send(build("PRIVMSG", [chan, f"Connect using nc {address} 1234"])) elif line.params[1].startswith(".add"): user = line.source.split('!')[0]