Compare commits

...

7 Commits

Author SHA1 Message Date
Skyflare 1a014238c5 Merge pull request 'Replace #!/bin/env with #!/usr/bin/env in bot.py' (#9) from noisytoot/matchmaking-bot:fix-shebang into master
Reviewed-on: #9
2024-04-16 06:35:00 +02:00
Ron Nazarov 3fc14cbaad
Replace #!/bin/env with #!/usr/bin/env in bot.py
Neither is POSIX, but /usr/bin/env is more widely used and /bin/env
does not exist on GNU Guix System.
2023-10-15 18:44:30 +01:00
Skyflare e92c453c4f fix requirements.txt 2023-08-26 22:39:49 +03:00
Skyflare 1646be3c47 update ConnectionParams parameters in bot.py to support ircrobots v0.6.6
parialy closes issue #6
parameters of function ConnectionParams from ircrobots were changed in but never documented properly
BREAKING CHANGE: requires ircrobots v0.6.6 instead of v0.6.1
2023-08-26 09:49:59 +03:00
franzo d2611ca615 fix: adding a non-existing game to the .last command output 2022-10-08 14:10:40 +02:00
franzo 19ffa45c38 fix: minor cmd list fix 2022-10-06 00:21:29 +02:00
franzo 1ad3ba6f7f fix: stupid indentation 2022-10-06 00:10:58 +02:00
2 changed files with 10 additions and 7 deletions

14
bot.py
View File

@ -1,4 +1,4 @@
#!/bin/env python3
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
import asyncio, configparser
from irctokens import build, Line
@ -41,14 +41,14 @@ class Server(BaseServer):
else:
game = " ".join(line.params[1].split(" ")[1:]).lower()
ping = ""
user = line.source.split('!')[0]
global lastPlayed
lastPlayed = game
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:
matches = match_players[self.name + '-' + chan][game]
others = list(set(matches) - set([user])) # don't ping the user who .matched
global lastPlayed
lastPlayed = game
if len(others) > 0:
for player in others:
@ -90,7 +90,7 @@ class Server(BaseServer):
elif line.params[1].startswith(".last"):
await self.send(build("PRIVMSG", [chan, "Last game played: " + lastPlayed]))
elif line.params[1].startswith(".list"):
elif line.params[1].startswith(".list"):
user = line.source.split('!')[0]
if len(line.params[1].split(" ")) < 2:
games = sorted(match_players[self.name + '-' + chan].keys())
@ -140,7 +140,7 @@ class Server(BaseServer):
await self.send(build("PRIVMSG", [chan, "Removed " + user + " from the " + game + " match list."]))
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); .lastPlayed: show the last played game"]))
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); .last: show last played game"]))
async def line_send(self, line: Line):
print(f"{self.name} > {line.format()}")
@ -194,7 +194,7 @@ async def main():
botnick = entry['opts']['nickname']
channels = entry['opts']['channels']
params = ConnectionParams(botnick, server, 6697, True)
params = ConnectionParams(botnick, server, 6697)
for channel in channels:
params.autojoin.append(channel)
print("Reading channel", channel)

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
python >=3.9
ircrobots ~=0.6.6
irctokens ~=2.0.2