Don't ping the user .match ing, fixes #1

This commit is contained in:
Rampoina 2022-02-15 16:13:43 +01:00
parent 5f945f33a5
commit 9962c1e019
1 changed files with 24 additions and 16 deletions

10
bot.py
View File

@ -40,10 +40,15 @@ 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]:
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} "
@ -60,6 +65,9 @@ class Server(BaseServer):
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 :("]))
elif line.params[1].startswith(".add"):
user = line.source.split('!')[0]