add: lastPlayed global variable and description of new cmd
This commit is contained in:
parent
9962c1e019
commit
b616edd808
11
bot.py
11
bot.py
|
@ -12,6 +12,7 @@ servers = []
|
||||||
match_players = {}
|
match_players = {}
|
||||||
connections = {}
|
connections = {}
|
||||||
admins = {}
|
admins = {}
|
||||||
|
lastPlayed = ""
|
||||||
|
|
||||||
def update_file(name):
|
def update_file(name):
|
||||||
with open(f"playerlist-{name}.txt", "wb") as file:
|
with open(f"playerlist-{name}.txt", "wb") as file:
|
||||||
|
@ -32,7 +33,7 @@ class Server(BaseServer):
|
||||||
|
|
||||||
print("Line Params: ", line.params)
|
print("Line Params: ", line.params)
|
||||||
if "PRIVMSG" in line.command and any(channel in line.params[0] for channel in self.params.autojoin):
|
if "PRIVMSG" in line.command and any(channel in line.params[0] for channel in self.params.autojoin):
|
||||||
chan = self.channels[line.params[0].lstrip("@")].name
|
chan = self.channels[line.params[0].lstrip("@")].name
|
||||||
if line.params[1].startswith(".match"):
|
if line.params[1].startswith(".match"):
|
||||||
channel = self.channels[line.params[0].lstrip("@")]
|
channel = self.channels[line.params[0].lstrip("@")]
|
||||||
if len(line.params[1].split(" ")) < 2:
|
if len(line.params[1].split(" ")) < 2:
|
||||||
|
@ -41,12 +42,14 @@ class Server(BaseServer):
|
||||||
game = " ".join(line.params[1].split(" ")[1:]).lower()
|
game = " ".join(line.params[1].split(" ")[1:]).lower()
|
||||||
ping = ""
|
ping = ""
|
||||||
user = line.source.split('!')[0]
|
user = line.source.split('!')[0]
|
||||||
|
global lastPlayed
|
||||||
|
lastPlayed = game
|
||||||
if game not in match_players[self.name + '-' + chan]:
|
if game not in match_players[self.name + '-' + chan]:
|
||||||
await self.send(build("PRIVMSG", [chan, "ERROR: no players in "+ game]))
|
await self.send(build("PRIVMSG", [chan, "ERROR: no players in "+ game]))
|
||||||
else:
|
else:
|
||||||
matches = 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
|
others = list(set(matches) - set([user])) # don't ping the user who .matched
|
||||||
|
|
||||||
if len(others) > 0:
|
if len(others) > 0:
|
||||||
for player in others:
|
for player in others:
|
||||||
pfold = self.casefold(player)
|
pfold = self.casefold(player)
|
||||||
|
@ -133,7 +136,7 @@ class Server(BaseServer):
|
||||||
await self.send(build("PRIVMSG", [chan, "Removed " + user + " from the " + game + " match list."]))
|
await self.send(build("PRIVMSG", [chan, "Removed " + user + " from the " + game + " match list."]))
|
||||||
|
|
||||||
elif line.params[1].startswith(".help"):
|
elif line.params[1].startswith(".help"):
|
||||||
await self.send(build("PRIVMSG", [chan, " .add game: Add user to the game list; .del game: Remove user from the game list; .match game: Ping everyone on the game list; .list game: list people added to the game; .list: list games; .remove game: removes the game from the list (admin command)"]))
|
await self.send(build("PRIVMSG", [chan, " .add game: Add user to the game list; .del game: Remove user from the game list; .match game: Ping everyone on the game list; .list game: list people added to the game; .list: list games; .remove game: removes the game from the list (admin command); .lastPlayed: show the last played game"]))
|
||||||
|
|
||||||
async def line_send(self, line: Line):
|
async def line_send(self, line: Line):
|
||||||
print(f"{self.name} > {line.format()}")
|
print(f"{self.name} > {line.format()}")
|
||||||
|
|
Loading…
Reference in New Issue