summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-07-22 17:13:24 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-07-22 17:13:24 (GMT)
commitc3c24fd8fb8f91696b4e38e0f212a35a8e1fe137 (patch)
tree02145bdb8a0f059be43d58c3942c0050ebbae1a9 /Swiftob/MUCs.cpp
parent053128df5c36b80c35e8ec5483125305f8fc86ea (diff)
downloadswift-c3c24fd8fb8f91696b4e38e0f212a35a8e1fe137.zip
swift-c3c24fd8fb8f91696b4e38e0f212a35a8e1fe137.tar.bz2
Allow nick changing and restart for Swiftob bots
Diffstat (limited to 'Swiftob/MUCs.cpp')
-rw-r--r--Swiftob/MUCs.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Swiftob/MUCs.cpp b/Swiftob/MUCs.cpp
index 695cbd9..5bad3a1 100644
--- a/Swiftob/MUCs.cpp
+++ b/Swiftob/MUCs.cpp
@@ -18,12 +18,17 @@
#include <Swiftob/Storage.h>
#define MUC_LIST_SETTING "muc_list"
+#define NICK "default_nick"
typedef std::pair<JID, MUC::ref> JIDMUCPair;
MUCs::MUCs(Client* client, Storage* storage) : defaultNick_("Kanchil+") {
client_ = client;
storage_ = storage;
+ std::string storedNick = storage_->getSetting(NICK);
+ if (!storedNick.empty()) {
+ defaultNick_ = storedNick;
+ }
client_->onConnected.connect(boost::bind(&MUCs::handleConnected, this));
}
@@ -118,3 +123,13 @@ void MUCs::save() {
MUC::ref MUCs::getMUC(const JID& room) {
return (mucs_.find(room) != mucs_.end()) ? mucs_[room] : MUC::ref();
}
+
+bool MUCs::setDefaultNick(const std::string& nick) {
+ JID testJID("alice", "wonderland.lit", nick);
+ if (testJID.isValid()) {
+ defaultNick_ = testJID.getResource();
+ storage_->saveSetting(NICK, defaultNick_);
+ return true;
+ }
+ return false;
+}