summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-07-21 18:15:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-07-21 18:56:03 (GMT)
commit12024c66fe21c62b158552abe26b1bcfa142ffe8 (patch)
treecfedc6e34b147bbb05fedfd69eeaad27bd5eadbd /Swiftob/Commands.h
parent2a690f23a71f5f24550df112e0544b32826655db (diff)
downloadswift-contrib-12024c66fe21c62b158552abe26b1bcfa142ffe8.zip
swift-contrib-12024c66fe21c62b158552abe26b1bcfa142ffe8.tar.bz2
Allowing generic message listeners for Swiftob bots
Diffstat (limited to 'Swiftob/Commands.h')
-rw-r--r--Swiftob/Commands.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Swiftob/Commands.h b/Swiftob/Commands.h
index 8423252..5c55f39 100644
--- a/Swiftob/Commands.h
+++ b/Swiftob/Commands.h
@@ -21,6 +21,7 @@ namespace Swift {
class Storage;
class Commands {
+ typedef boost::function<void(Swift::Message::ref)> ListenerCallback;
public:
enum RoleList {Anyone, Owner};
public:
@@ -43,8 +44,10 @@ class Commands {
Commands(Users* users, Swift::Client* client, Storage* storage, MUCs* mucs);
bool hasCommand(const std::string&);
bool runCommand(const std::string& command, const std::string& params, Swift::Message::ref message);
+ void runListeners(Swift::Message::ref message);
void replyTo(Swift::Message::ref source, std::string replyBody, bool outOfMUC = false);
void registerCommand(const std::string& name, RoleList roles, const std::string& description, boost::function<void(const std::string& /*command*/, const std::string& /*params*/, Swift::Message::ref)> callback);
+ void registerListener(ListenerCallback);
void resetCommands();
void setRehashError(const std::string& error);
@@ -61,6 +64,7 @@ class Commands {
void handleRehashCommand(const std::string& command, const std::string& params, Swift::Message::ref message);
private:
std::map<std::string, Command*> commands_;
+ std::vector<ListenerCallback> listeners_;
Users* users_;
Swift::Client* client_;
Storage* storage_;