Changeset - c358589ec5c0
[Not reviewed]
0 1 0
Jan Kaluza - 9 years ago 2016-02-01 10:08:18
jkaluza@redhat.com
Slack: Ignore purpose messages for now
1 file changed with 4 insertions and 0 deletions:
0 comments (0 inline, 0 general)
spectrum/src/frontends/slack/SlackRTM.cpp
Show inline comments
 
@@ -98,46 +98,50 @@ void SlackRTM::handlePayloadReceived(const std::string &payload) {
 
		LOG4CXX_ERROR(logger, "Error while parsing JSON");
 
		LOG4CXX_ERROR(logger, payload);
 
		return;
 
	}
 

	
 
	STORE_STRING(d, type);
 

	
 
	if (type == "message") {
 
		STORE_STRING(d, channel);
 
		STORE_STRING(d, text);
 
		STORE_STRING(d, ts);
 
		STORE_STRING_OPTIONAL(d, subtype);
 
		STORE_STRING_OPTIONAL(d, purpose);
 

	
 
		rapidjson::Value &attachments = d["attachments"];
 
		if (attachments.IsArray()) {
 
			for (int i = 0; i < attachments.Size(); i++) {
 
				STORE_STRING_OPTIONAL(attachments[i], fallback);
 
				if (!fallback.empty()) {
 
					text += fallback;
 
				}
 
			}
 
		}
 

	
 
		if (subtype == "bot_message") {
 
			STORE_STRING(d, bot_id);
 
			onMessageReceived(channel, bot_id, text, ts);
 
		}
 
		else if (subtype == "me_message") {
 
			text = "/me " + text;
 
			STORE_STRING(d, user);
 
			onMessageReceived(channel, user, text, ts);
 
		}
 
		else if (subtype == "channel_join") {
 
			
 
		}
 
		else if (!purpose.empty()) {
 
			
 
		}
 
		else {
 
			STORE_STRING(d, user);
 
			onMessageReceived(channel, user, text, ts);
 
		}
 
	}
 
	else if (type == "channel_joined"
 
		  || type == "channel_created") {
 
		std::map<std::string, SlackChannelInfo> &channels = m_idManager->getChannels();
 
		SlackAPI::getSlackChannelInfo(NULL, true, d, payload, channels);
 
	}
 
}
0 comments (0 inline, 0 general)