Compare commits
7 Commits
89d5a4f9c3
...
master
Author | SHA1 | Date |
---|---|---|
Skyflare | 1a014238c5 | |
Ron Nazarov | 3fc14cbaad | |
Skyflare | e92c453c4f | |
Skyflare | 1646be3c47 | |
franzo | d2611ca615 | |
franzo | 19ffa45c38 | |
franzo | 1ad3ba6f7f |
14
bot.py
14
bot.py
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
python >=3.9
|
||||
ircrobots ~=0.6.6
|
||||
irctokens ~=2.0.2
|
Loading…
Reference in New Issue