Changeset - bf9f7b7a4163
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2015-12-08 18:47:19
jkaluza@redhat.com
Slack: parse the bots names from RTM
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spectrum/src/frontends/slack/SlackAPI.cpp
Show inline comments
 
@@ -281,52 +281,52 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
 

	
 
		STORE_BOOL(users[i], is_primary_owner);
 
		info.isPrimaryOwner = is_primary_owner;
 

	
 
		ret[info.id] = info;
 
		LOG4CXX_INFO(logger, info.id << " " << info.name);
 

	
 
		GET_OBJECT(users[i], profile);
 
		STORE_STRING_OPTIONAL(profile, bot_id);
 
		if (!bot_id.empty()) {
 
			ret[bot_id] = info;
 
			LOG4CXX_INFO(logger, bot_id << " " << info.name);
 
		}
 
	}
 

	
 
	GET_ARRAY(resp, bots);
 

	
 
	for (int i = 0; i < bots.Size(); i++) {
 
		if (!bots[i].IsObject()) {
 
			continue;
 
		}
 

	
 
		SlackUserInfo info;
 

	
 
		STORE_STRING(users[i], id);
 
		STORE_STRING(bots[i], id);
 
		info.id = id;
 

	
 
		STORE_STRING(users[i], name);
 
		STORE_STRING(bots[i], name);
 
		info.name = name;
 

	
 
		info.isPrimaryOwner = 0;
 

	
 
		ret[info.id] = info;
 
		LOG4CXX_INFO(logger, info.id << " " << info.name);
 
	}
 

	
 
	return;
 
}
 

	
 
std::string SlackAPI::SlackObjectToPlainText(const std::string &object, bool isChannel, bool returnName) {
 
	std::string ret = object;
 
	if (isChannel) {
 
		if (ret[0] == '<') {
 
			ret = ret.substr(2, ret.size() - 3);
 
		}
 
	} else {
 
		if (ret[0] == '<') {
 
			ret = ret.substr(1, ret.size() - 2);
 
			if (returnName) {
 
				ret = ret.substr(0, ret.find("|"));
 
			}
 
			else {
0 comments (0 inline, 0 general)