use multiple lines to list game names

* output cuts off somewhere above 400 chars
* batch size of 20 should do it
* may as well sort list at the same time
This commit is contained in:
Phil Morrell 2021-08-31 14:33:51 +01:00
parent 15eab1a86f
commit 7921f44058
Signed by: emorrp1
GPG Key ID: DBCA65091F248E6C
1 changed files with 5 additions and 1 deletions

6
bot.py
View File

@ -75,13 +75,17 @@ class Server(BaseServer):
elif line.params[1].startswith(".list"):
user = line.source.split('!')[0]
if len(line.params[1].split(" ")) < 2:
await self.send(build("PRIVMSG", [chan, "list: " + str(list(match_players[self.name + '-' + chan].keys()))]))
games = sorted(match_players[self.name + '-' + chan].keys())
while len(games):
await self.send(build("PRIVMSG", [chan, "list: " + ', '.join(games[:20])]))
del games[:20]
else:
game = " ".join(line.params[1].split(" ")[1:]).lower()
if game not in match_players[self.name + '-' + chan]:
await self.send(build("PRIVMSG", [chan, "ERROR: no players in " + game + " list."]))
else:
await self.send(build("PRIVMSG", [chan, game + " players: " + str(['_' + e for e in match_players[self.name + '-' + chan][game]])]))
elif line.params[1].startswith(".del"):
user = line.source.split('!')[0]
if len(line.params[1].split(" ")) < 2: