Skip to content

Commit

Permalink
Track the channel topic
Browse files Browse the repository at this point in the history
  • Loading branch information
embolalia committed Jan 30, 2016
1 parent db11d22 commit cd5d304
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sopel/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ def _send_who(bot, channel):
@sopel.module.unblockable
def track_join(bot, trigger):
if trigger.nick == bot.nick and trigger.sender not in bot.channels:
bot.write(('TOPIC', trigger.sender))

bot.privileges[trigger.sender] = dict()
bot.channels[trigger.sender] = Channel(trigger.sender)
_send_who(bot, trigger.sender)
Expand Down Expand Up @@ -691,3 +693,15 @@ def track_notify(bot, trigger):
bot.users[trigger.nick] = User(trigger.nick, trigger.user, trigger.host)
user = bot.users[trigger.nick]
user.away = bool(trigger.args)


@sopel.module.rule('.*')
@sopel.module.event(events.RPL_TOPIC)
@sopel.module.priority('high')
@sopel.module.thread(False)
@sopel.module.unblockable
def track_topic(bot, trigger):
channel = trigger.args[1]
if channel not in bot.channels:
return
bot.channels[channel].topic = trigger.args[-1]
2 changes: 2 additions & 0 deletions sopel/tools/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def __init__(self, name):
This maps username ``Identifier``s to bitwise integer values. This can
be compared to appropriate constants from ``sopel.module``."""
self.topic = ''
"""The topic of the channel."""

def clear_user(self, nick):
user = self.users[nick]
Expand Down

0 comments on commit cd5d304

Please sign in to comment.