Browse Source

Add a 'part' hook. Updates.

tags/v0.2
Ben Kurtovic 9 years ago
parent
commit
a17f0ec47b
4 changed files with 14 additions and 6 deletions
  1. +3
    -0
      CHANGELOG
  2. +4
    -3
      docs/customizing.rst
  3. +3
    -3
      earwigbot/commands/__init__.py
  4. +4
    -0
      earwigbot/irc/frontend.py

+ 3
- 0
CHANGELOG View File

@@ -1,6 +1,9 @@
v0.2 (unreleased): v0.2 (unreleased):


- Added a new command syntax allowing the caller to redirect replies to another
user. Example: "!dictionary >Fred earwig"
- Added 'rc' hook type to allow IRC commands to respond to RC watcher events. - Added 'rc' hook type to allow IRC commands to respond to RC watcher events.
- Added 'part' hook type as a counterpart to 'join'.
- Added !stalk/!watch. - Added !stalk/!watch.
- Added !watchers. - Added !watchers.
- Added !epoch as a subcommand of !time. - Added !epoch as a subcommand of !time.


+ 4
- 3
docs/customizing.rst View File

@@ -108,9 +108,10 @@ are the basics:
- Class attribute :py:attr:`~earwigbot.commands.Command.hooks` is a list of the - Class attribute :py:attr:`~earwigbot.commands.Command.hooks` is a list of the
"IRC events" that this command might respond to. It defaults to ``["msg"]``, "IRC events" that this command might respond to. It defaults to ``["msg"]``,
but options include ``"msg_private"`` (for private messages only), but options include ``"msg_private"`` (for private messages only),
``"msg_public"`` (for channel messages only), and ``"join"`` (for when a user
joins a channel). See the afc_status_ plugin for a command that responds to
other hook types.
``"msg_public"`` (for channel messages only), ``"join"`` (for when a user
joins a channel), ``"part"`` (for when a user parts a channel), and ``"rc"``
(for recent change messages from the IRC watcher). See the afc_status_ plugin
for a command that responds to other hook types.


- Method :py:meth:`~earwigbot.commands.Command.setup` is called *once* with no - Method :py:meth:`~earwigbot.commands.Command.setup` is called *once* with no
arguments immediately after the command is first loaded. Does nothing by arguments immediately after the command is first loaded. Does nothing by


+ 3
- 3
earwigbot/commands/__init__.py View File

@@ -43,9 +43,9 @@ class Command(object):
# be triggered by the command's name and its name only: # be triggered by the command's name and its name only:
commands = [] commands = []


# Hooks are "msg", "msg_private", "msg_public", and "join". "msg" is the
# default behavior; if you wish to override that, change the value in your
# command subclass:
# Hooks are "msg", "msg_private", "msg_public", "join", "part", and "rc".
# "msg" is the default behavior; if you wish to override that, change the
# value in your command subclass:
hooks = ["msg"] hooks = ["msg"]


def __init__(self, bot): def __init__(self, bot):


+ 4
- 0
earwigbot/irc/frontend.py View File

@@ -62,6 +62,10 @@ class Frontend(IRCConnection):
data = Data(self.bot, self.nick, line, msgtype="JOIN") data = Data(self.bot, self.nick, line, msgtype="JOIN")
self.bot.commands.call("join", data) self.bot.commands.call("join", data)


elif line[1] == "PART":
data = Data(self.bot, self.nick, line, msgtype="PART")
self.bot.commands.call("part", data)

elif line[1] == "PRIVMSG": elif line[1] == "PRIVMSG":
data = Data(self.bot, self.nick, line, msgtype="PRIVMSG") data = Data(self.bot, self.nick, line, msgtype="PRIVMSG")
if data.is_private: if data.is_private:


Loading…
Cancel
Save