Skip to content

Commit

Permalink
Added IRC Notices. (errbotio#984)
Browse files Browse the repository at this point in the history
* Added IRC Notices.

They are forwarded as normal messages (public or private) with an
extra['notice'] == True if they were notices.

* style
  • Loading branch information
gbin authored Apr 8, 2017
1 parent eeefe9d commit 2122b59
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions errbot/backends/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ def on_welcome(self, _, e):
t.setDaemon(True)
t.start()

def on_pubmsg(self, _, e):
msg = Message(e.arguments[0])
def _pubmsg(self, e, notice=False):
msg = Message(e.arguments[0], extras={'notice': notice})
room_name = e.target
if room_name[0] != '#' and room_name[0] != '$':
raise Exception('[%s] is not a room' % room_name)
Expand All @@ -402,12 +402,24 @@ def on_pubmsg(self, _, e):
mentions = [self.bot.build_identifier(mention) for mention in mentions]
self.bot.callback_mention(msg, mentions)

def on_privmsg(self, _, e):
msg = Message(e.arguments[0])
def _privmsg(self, e, notice=False):
msg = Message(e.arguments[0], extras={'notice': notice})
msg.frm = IRCPerson(e.source)
msg.to = IRCPerson(e.target)
self.bot.callback_message(msg)

def on_pubmsg(self, _, e):
self._pubmsg(e)

def on_privmsg(self, _, e):
self._privmsg(e)

def on_pubnotice(self, _, e):
self._pubmsg(e, True)

def on_privnotice(self, _, e):
self._privmsg(e, True)

def on_kick(self, _, e):
if not self._reconnect_on_kick:
log.info("RECONNECT_ON_KICK is 0 or None, won't try to reconnect")
Expand Down

0 comments on commit 2122b59

Please sign in to comment.