Included notices in print_activity, don't always print channel name
This commit is contained in:
parent
2ea2dd17da
commit
46e124a5db
1 changed files with 26 additions and 5 deletions
|
@ -10,6 +10,13 @@ class Module(object):
|
||||||
bot.events.on("self").on("message").on("channel").hook(
|
bot.events.on("self").on("message").on("channel").hook(
|
||||||
self.self_channel_message)
|
self.self_channel_message)
|
||||||
|
|
||||||
|
bot.events.on("received").on("notice").on("channel").hook(
|
||||||
|
self.channel_notice, priority=EventManager.PRIORITY_HIGH)
|
||||||
|
bot.events.on("received").on("notice").on("private").hook(
|
||||||
|
self.private_notice, priority=EventManager.PRIORITY_HIGH)
|
||||||
|
bot.events.on("received").on("server-notice").hook(
|
||||||
|
self.server_notice, priority=EventManager.PRIORITY_HIGH)
|
||||||
|
|
||||||
bot.events.on("received").on("join").hook(self.join)
|
bot.events.on("received").on("join").hook(self.join)
|
||||||
bot.events.on("self").on("join").hook(self.self_join)
|
bot.events.on("self").on("join").hook(self.self_join)
|
||||||
|
|
||||||
|
@ -24,24 +31,38 @@ class Module(object):
|
||||||
bot.events.on("received").on("kick").hook(self.kick)
|
bot.events.on("received").on("kick").hook(self.kick)
|
||||||
bot.events.on("self").on("kick").hook(self.self_kick)
|
bot.events.on("self").on("kick").hook(self.self_kick)
|
||||||
|
|
||||||
def print_line(self, event, line):
|
def print_line(self, event, line, channel=None):
|
||||||
timestamp = datetime.datetime.now().isoformat()
|
timestamp = datetime.datetime.now().isoformat()
|
||||||
target = str(event["server"])
|
target = str(event["server"])
|
||||||
if "channel" in event:
|
if not channel == None:
|
||||||
target += event["channel"].name
|
target += channel
|
||||||
print("[%s] %s | %s" % (timestamp, target, line))
|
print("[%s] %s | %s" % (timestamp, target, line))
|
||||||
|
|
||||||
def _on_message(self, event, nickname):
|
def _on_message(self, event, nickname):
|
||||||
if not self.bot.args.verbose:
|
if not self.bot.args.verbose:
|
||||||
if event["action"]:
|
if event["action"]:
|
||||||
self.print_line(event, "* %s %s" % (nickname, event["message"]))
|
self.print_line(event, "* %s %s" % (
|
||||||
|
nickname, event["message"]),
|
||||||
|
channel=event["channel"].name)
|
||||||
else:
|
else:
|
||||||
self.print_line(event, "<%s> %s" % (nickname, event["message"]))
|
self.print_line(event, "<%s> %s" % (
|
||||||
|
nickname, event["message"]),
|
||||||
|
channel=event["channel"].name)
|
||||||
def channel_message(self, event):
|
def channel_message(self, event):
|
||||||
self._on_message(event, event["user"].nickname)
|
self._on_message(event, event["user"].nickname)
|
||||||
def self_channel_message(self, event):
|
def self_channel_message(self, event):
|
||||||
self._on_message(event, event["server"].nickname)
|
self._on_message(event, event["server"].nickname)
|
||||||
|
|
||||||
|
def _on_notice(self, event, target):
|
||||||
|
self.print_line(event, "(notice->%s) <%s> %s" % (
|
||||||
|
target, event["user"].nickname, event["message"]))
|
||||||
|
def channel_notice(self, event):
|
||||||
|
self._on_notice(event, event["channel"].name)
|
||||||
|
def private_notice(self, event):
|
||||||
|
self._on_notice(event, event["server"].nickname)
|
||||||
|
def server_notice(self, event):
|
||||||
|
self.print_line(event, "(server notice) %s" % event["message"])
|
||||||
|
|
||||||
def _on_join(self, event, nickname):
|
def _on_join(self, event, nickname):
|
||||||
if not self.bot.args.verbose:
|
if not self.bot.args.verbose:
|
||||||
self.print_line(event, "%s joined %s" % (nickname,
|
self.print_line(event, "%s joined %s" % (nickname,
|
||||||
|
|
Loading…
Reference in a new issue