Save actions, better date format, various bug fixes
This commit is contained in:
parent
9e9df3bd7d
commit
a951fd8e9f
2 changed files with 28 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
||||||
server = irc.freenode.net
|
server = irc.freenode.net
|
||||||
port = 6667
|
port = 6667
|
||||||
server_password = password
|
server_password = password
|
||||||
channels = #keryx
|
channels = #excid3
|
||||||
|
|
||||||
nick = Timber
|
nick = Timber
|
||||||
nick_password = password
|
nick_password = password
|
||||||
|
@ -21,8 +21,10 @@ join = -!- <span class="join">%user%</span> [%host%] has joined %channel%
|
||||||
kick = -!- <span class="kick">%user%</span> was kicked from %channel% by %kicker% [%reason%]
|
kick = -!- <span class="kick">%user%</span> was kicked from %channel% by %kicker% [%reason%]
|
||||||
mode = -!- mode/<span class="mode">%channel%</span> [%modes% %person%] by %giver%
|
mode = -!- mode/<span class="mode">%channel%</span> [%modes% %person%] by %giver%
|
||||||
nick = <span class="nick">%old%</span> is now known as <span class="nick">%new%</span>
|
nick = <span class="nick">%old%</span> is now known as <span class="nick">%new%</span>
|
||||||
part = -!- <span class="part">%user%</span> has parted %channel%
|
part = -!- <span class="part">%user%</span> [%host%] has parted %channel%
|
||||||
pubmsg = <span class="person" style="color:%color%"><%user%></span> %message%
|
pubmsg = <span class="person" style="color:%color%"><%user%></span> %message%
|
||||||
pubnotice = <span class="notice">-%user%:%channel%-</span> %message%
|
pubnotice = <span class="notice">-%user%:%channel%-</span> %message%
|
||||||
quit = -!- <span class="quit">%user%</span> has quit [%reason%]
|
quit = -!- <span class="quit">%user%</span> has quit [%reason%]
|
||||||
topic = <span class="topic">%user%</span> changed topic of <span class="topic">%channel%</span> to: %topic%
|
topic = <span class="topic">%user%</span> changed topic of <span class="topic">%channel%</span> to: %topic%
|
||||||
|
action = <span class="person" style="color:%color%">* %user% %action%</span>
|
||||||
|
help = Check out http://excid3.com
|
29
logbot.py
29
logbot.py
|
@ -74,6 +74,9 @@ class LogBot(SingleServerIRCBot):
|
||||||
self.nick_pass = nick_pass
|
self.nick_pass = nick_pass
|
||||||
self.chans = channels
|
self.chans = channels
|
||||||
|
|
||||||
|
print "Logbot %s" % __version__
|
||||||
|
print "Connecting to %s:%i" % (server, port)
|
||||||
|
|
||||||
def set_format(self, folder, format, stylesheet):
|
def set_format(self, folder, format, stylesheet):
|
||||||
self.folder = folder
|
self.folder = folder
|
||||||
self.format = format
|
self.format = format
|
||||||
|
@ -90,6 +93,9 @@ class LogBot(SingleServerIRCBot):
|
||||||
for channel in self.chans:
|
for channel in self.chans:
|
||||||
c.join(channel)
|
c.join(channel)
|
||||||
|
|
||||||
|
print "Connected"
|
||||||
|
print "Press Ctrl-C to quit"
|
||||||
|
|
||||||
def on_pubmsg(self, c, e):
|
def on_pubmsg(self, c, e):
|
||||||
user = nm_to_n(e.source())
|
user = nm_to_n(e.source())
|
||||||
message = e.arguments()[0]
|
message = e.arguments()[0]
|
||||||
|
@ -100,7 +106,16 @@ class LogBot(SingleServerIRCBot):
|
||||||
.replace("%color%", color))
|
.replace("%color%", color))
|
||||||
|
|
||||||
def on_invite(self, c, e):
|
def on_invite(self, c, e):
|
||||||
pass
|
c.join(e.arguments()[0])
|
||||||
|
|
||||||
|
def on_action(self, c, e):
|
||||||
|
user = nm_to_n(e.source())
|
||||||
|
action = e.arguments()[0]
|
||||||
|
channel = e.target()
|
||||||
|
color = gen_color(user)
|
||||||
|
self.write(channel, self.format["action"].replace("%user%", user) \
|
||||||
|
.replace("%action%", action) \
|
||||||
|
.replace("%color%", color))
|
||||||
|
|
||||||
def on_join(self, c, e):
|
def on_join(self, c, e):
|
||||||
user = nm_to_n(e.source())
|
user = nm_to_n(e.source())
|
||||||
|
@ -130,12 +145,14 @@ class LogBot(SingleServerIRCBot):
|
||||||
|
|
||||||
def on_part(self, c, e):
|
def on_part(self, c, e):
|
||||||
user = nm_to_n(e.source())
|
user = nm_to_n(e.source())
|
||||||
|
host = e.source()
|
||||||
channel = e.target()
|
channel = e.target()
|
||||||
self.write(channel, self.format["part"].replace("%user%", user) \
|
self.write(channel, self.format["part"].replace("%user%", user) \
|
||||||
|
.replace("%host%", host) \
|
||||||
.replace("%channel%", channel))
|
.replace("%channel%", channel))
|
||||||
|
|
||||||
def on_privmsg(self, c, e):
|
def on_privmsg(self, c, e):
|
||||||
pass
|
c.privmsg(nm_to_n(e.source()), self.format["help"])
|
||||||
|
|
||||||
def on_topic(self, c, e):
|
def on_topic(self, c, e):
|
||||||
user = nm_to_n(e.source())
|
user = nm_to_n(e.source())
|
||||||
|
@ -168,7 +185,7 @@ class LogBot(SingleServerIRCBot):
|
||||||
|
|
||||||
def write(self, channel, message):
|
def write(self, channel, message):
|
||||||
time = strftime("%H:%M:%S")
|
time = strftime("%H:%M:%S")
|
||||||
date = strftime("%d-%m-%Y")
|
date = strftime("%Y-%m-%d")
|
||||||
if channel:
|
if channel:
|
||||||
print "%s> %s %s" % (channel, time, message)
|
print "%s> %s %s" % (channel, time, message)
|
||||||
channels = [channel]
|
channels = [channel]
|
||||||
|
@ -258,15 +275,15 @@ def main(conf):
|
||||||
|
|
||||||
# Get the formation information
|
# Get the formation information
|
||||||
types = ["join", "kick", "mode", "nick", "part", "pubmsg", "pubnotice",
|
types = ["join", "kick", "mode", "nick", "part", "pubmsg", "pubnotice",
|
||||||
"quit", "topic"]
|
"quit", "topic", "action"]
|
||||||
format = {}
|
format = {}
|
||||||
for type in types:
|
for type in types:
|
||||||
format[type] = CONFIG.get("format", type)
|
format[type] = CONFIG.get("format", type)
|
||||||
|
|
||||||
bot = LogBot(server, port, server_pass, channels, owner, nick, nick_pass)
|
bot = LogBot(server, port, server_pass, channels, owner, nick, nick_pass)
|
||||||
bot.set_format(folder, format, stylesheet)
|
bot.set_format(folder, format, stylesheet)
|
||||||
bot.start()
|
try: bot.start()
|
||||||
|
except KeyboardInterrupt: pass
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Require a config
|
# Require a config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue