|
@@ -5,13 +5,14 @@ import irc.bot#, irc.strings
|
|
|
from irc.client import ip_numstr_to_quad#, ip_quad_to_numstr
|
|
from irc.client import ip_numstr_to_quad#, ip_quad_to_numstr
|
|
|
from postgres import Postgres
|
|
from postgres import Postgres
|
|
|
import commands.public, commands.admin, commands.games, commands.statistics
|
|
import commands.public, commands.admin, commands.games, commands.statistics
|
|
|
-import events.on_join, events.on_kick, events.on_pubmsg
|
|
|
|
|
-from common.networkservices import NickServ
|
|
|
|
|
|
|
+import events.on_welcome, events.on_join, events.on_kick, events.on_mode, events.on_pubmsg, events.on_whoreply, events.on_nick
|
|
|
from common import log
|
|
from common import log
|
|
|
|
|
+from common.networkservices import NickServ
|
|
|
|
|
+
|
|
|
bold = "\x02"
|
|
bold = "\x02"
|
|
|
italic = "\x1D"
|
|
italic = "\x1D"
|
|
|
underline = "\x1F"
|
|
underline = "\x1F"
|
|
|
-reverse = "\x16" # swap background and foreground colors ("reverse video")
|
|
|
|
|
|
|
+reverse = "\x16" # swap background and foreground colors ("reverse video")
|
|
|
reset = "\x0F"
|
|
reset = "\x0F"
|
|
|
blue = "\x0302"
|
|
blue = "\x0302"
|
|
|
green = "\x0303"
|
|
green = "\x0303"
|
|
@@ -26,6 +27,8 @@ class PyRot(irc.bot.SingleServerIRCBot):
|
|
|
self.password = password
|
|
self.password = password
|
|
|
self.cmdchar = cmdchar
|
|
self.cmdchar = cmdchar
|
|
|
self.helpchar = helpchar
|
|
self.helpchar = helpchar
|
|
|
|
|
+ self.protectees = {}
|
|
|
|
|
+ self.channelkeys = {}
|
|
|
|
|
|
|
|
if usessl:
|
|
if usessl:
|
|
|
factory = irc.connection.Factory(wrapper=ssl.wrap_socket)
|
|
factory = irc.connection.Factory(wrapper=ssl.wrap_socket)
|
|
@@ -45,40 +48,35 @@ class PyRot(irc.bot.SingleServerIRCBot):
|
|
|
NickServ.recover_nick(connection, self.password)
|
|
NickServ.recover_nick(connection, self.password)
|
|
|
|
|
|
|
|
def on_welcome(self, connection, event):
|
|
def on_welcome(self, connection, event):
|
|
|
- log.info(event) # Handy for debugging. Keep this.
|
|
|
|
|
- if self.password: # Id with NickServ
|
|
|
|
|
- connection.privmsg("NickServ", "identify " + connection.nickname + " " + self.password) # Identify with NickServ.
|
|
|
|
|
- channels = self.db.all("SELECT name FROM channels WHERE network='" + self.network + "' AND autojoin=True")
|
|
|
|
|
- connection.join(self.homechannel)
|
|
|
|
|
- for channel in channels: # Join channels with autojoin function.
|
|
|
|
|
- connection.join(channel)
|
|
|
|
|
- connection.join(self.homechannel)
|
|
|
|
|
|
|
+ events.on_welcome.process_event(self, connection, event)
|
|
|
|
|
|
|
|
def on_error(self, connection, event):
|
|
def on_error(self, connection, event):
|
|
|
log.notice(event)
|
|
log.notice(event)
|
|
|
connection.privmsg(self.homechannel, "ERROR: " + event)
|
|
connection.privmsg(self.homechannel, "ERROR: " + event)
|
|
|
|
|
|
|
|
- def on_nick(self, connection, event):
|
|
|
|
|
- if event.source.nick == connection.nickname: # If the nick boing changes is the bots prefered nickname.
|
|
|
|
|
- log.info("Assuming original nick.")
|
|
|
|
|
- NickServ.recover_nick(connection, self.password)
|
|
|
|
|
|
|
+ def on_nick(self, connection, event):
|
|
|
|
|
+ events.on_nick.process_event(self, connection, event)
|
|
|
|
|
|
|
|
def on_join(self, connection, event):
|
|
def on_join(self, connection, event):
|
|
|
- log.info(event)
|
|
|
|
|
events.on_join.process_event(self, connection, event)
|
|
events.on_join.process_event(self, connection, event)
|
|
|
|
|
|
|
|
def on_kick(self, connection, event):
|
|
def on_kick(self, connection, event):
|
|
|
- log.info(event)
|
|
|
|
|
events.on_kick.process_event(self, connection, event)
|
|
events.on_kick.process_event(self, connection, event)
|
|
|
|
|
|
|
|
def on_mode(self, connection, event):
|
|
def on_mode(self, connection, event):
|
|
|
- log.info(event)
|
|
|
|
|
|
|
+ events.on_mode.process_event(self, connection, event)
|
|
|
|
|
|
|
|
def on_part(self, connection, event):
|
|
def on_part(self, connection, event):
|
|
|
- log.info(event)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # Update protectees
|
|
|
|
|
+ if event.target == self.homechannel and event.source.nick in self.protectees: # Protectee parted home channel.
|
|
|
|
|
+ del self.protectees[event.source.nick] # Delete from protectees.
|
|
|
|
|
|
|
|
def on_quit(self, connection, event):
|
|
def on_quit(self, connection, event):
|
|
|
- log.info(event)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # Update protectees
|
|
|
|
|
+ if event.source.nick in self.protectees: # Protectee parted home channel.
|
|
|
|
|
+ del self.protectees[event.source.nick] # Delete from protectees.
|
|
|
|
|
|
|
|
def on_invite(self, connection, event):
|
|
def on_invite(self, connection, event):
|
|
|
log.info(event)
|
|
log.info(event)
|
|
@@ -90,17 +88,9 @@ class PyRot(irc.bot.SingleServerIRCBot):
|
|
|
commands.public.do_command(self, connection, event)
|
|
commands.public.do_command(self, connection, event)
|
|
|
commands.admin.do_command(self, connection, event)
|
|
commands.admin.do_command(self, connection, event)
|
|
|
commands.statistics.do_command(self, connection, event)
|
|
commands.statistics.do_command(self, connection, event)
|
|
|
- try:
|
|
|
|
|
- games = self.db.one("SELECT games FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'")
|
|
|
|
|
- except:
|
|
|
|
|
- pass
|
|
|
|
|
- if games:
|
|
|
|
|
- commands.games.do_command(self, connection, event)
|
|
|
|
|
|
|
+ commands.games.do_command(self, connection, event)
|
|
|
events.on_pubmsg.process_event(self, connection, event)
|
|
events.on_pubmsg.process_event(self, connection, event)
|
|
|
|
|
|
|
|
- def on_pubnotice(self, connection, event):
|
|
|
|
|
- log.info(event)
|
|
|
|
|
-
|
|
|
|
|
def on_privmsg(self, connection, event):
|
|
def on_privmsg(self, connection, event):
|
|
|
log.info(event)
|
|
log.info(event)
|
|
|
commands.public.do_command(self, connection, event)
|
|
commands.public.do_command(self, connection, event)
|
|
@@ -108,18 +98,31 @@ class PyRot(irc.bot.SingleServerIRCBot):
|
|
|
commands.statistics.do_command(self, connection, event)
|
|
commands.statistics.do_command(self, connection, event)
|
|
|
commands.games.do_command(self, connection, event)
|
|
commands.games.do_command(self, connection, event)
|
|
|
|
|
|
|
|
|
|
+ def on_pubnotice(self, connection, event):
|
|
|
|
|
+ log.info(event)
|
|
|
|
|
+
|
|
|
def on_privnotice(self, connection, event):
|
|
def on_privnotice(self, connection, event):
|
|
|
log.info(event)
|
|
log.info(event)
|
|
|
commands.public.do_command(self, connection, event)
|
|
commands.public.do_command(self, connection, event)
|
|
|
commands.admin.do_command(self, connection, event)
|
|
commands.admin.do_command(self, connection, event)
|
|
|
commands.statistics.do_command(self, connection, event)
|
|
commands.statistics.do_command(self, connection, event)
|
|
|
commands.games.do_command(self, connection, event)
|
|
commands.games.do_command(self, connection, event)
|
|
|
- if event.source.nick == NickServ and event.arguments[0].startswith("This nickname is registered"):
|
|
|
|
|
- connection.privmsg("NickServ", "identify " + connection.nickname + " " + connection.password) # Identify with NickServ.
|
|
|
|
|
|
|
+ if event.source.nick == "NickServ" and event.arguments[0].startswith("This nickname is registered"):
|
|
|
|
|
+ connection.privmsg("NickServ", "identify " + connection.nickname + " " + self.password) # Identify with NickServ.
|
|
|
|
|
+ if event.source.nick == "ChanServ" and event.arguments[0].startswith("Key for channel ") and len(event.arguments[0]) > 5: # Received channel key.
|
|
|
|
|
+ connection.join(event.arguments[0].split(' ')[3], event.arguments[0].split(' ')[5][:-1])
|
|
|
|
|
|
|
|
def on_action(self, connection, event):
|
|
def on_action(self, connection, event):
|
|
|
log.info(event)
|
|
log.info(event)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ def on_userhost(self, connection, event):
|
|
|
|
|
+ print(event)
|
|
|
|
|
+
|
|
|
|
|
+ def on_whoreply(self, connection, event):
|
|
|
|
|
+ events.on_whoreply.process_event(self, connection, event)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
# DCC stuff from originalexample file.
|
|
# DCC stuff from originalexample file.
|
|
|
def on_dccmsg(self, c, e):
|
|
def on_dccmsg(self, c, e):
|
|
|
log.info(e)
|
|
log.info(e)
|