var util = require("util");
var request = require("request");

var BaseTrigger = require("./baseTrigger.js").BaseTrigger;

var LinkName = function() {
	LinkName.super_.apply(this, arguments);
};

util.inherits(LinkName, BaseTrigger);

var type = "LinkName";

exports.triggerType = type;
exports.create = function(name, chatBot, options) {
	var trigger = new LinkName(type, name, chatBot, options);

	trigger.respectsMute = true;
	trigger.respectsFilters = true;
	// Other initializers

	return trigger;
};
// Return true if a message was sent
LinkName.prototype._respondToFriendMessage = function(userId, message) {
	return this._respond(userId, message);
}
// Return true if a message was sent
LinkName.prototype._respondToChatMessage = function(roomId, chatterId, message) {
	return this._respond(roomId, message);
}

LinkName.prototype._respond = function(toId, message) {
	var that = this;
	//split the message into words. Without it, this omits all messages that include words together with links.
	var re = /(<\s*title[^>]*>(.+?)<\s*\/\s*title)>/gi;
	var splitmes = message.split(" ");
	var i = 0;
	for (i = 0; i < splitmes.length; ++i) {
		//if this part of the message is a link
		request(splitmes[i], function (error, response, body) {
			if (!error && response.statusCode === 200) {
				//split at <title>
				var match = re.exec(body);
				if (match && match[2]) {
					//send title message
					var ln = "" + match[2];
					that._sendMessageAfterDelay(toId, ln);
				}
				match = re.exec(body);
			}
		});
	}
}
@@ -128,16 +128,23 @@
 LinkName
+Trigger
  = funct
@@ -160,16 +160,23 @@
 LinkName
+Trigger
 .super_.
@@ -225,16 +225,23 @@
 LinkName
+Trigger
 , BaseTr
@@ -269,16 +269,23 @@
 LinkName
+Trigger
 %22;%0A%0Aexpo
@@ -387,16 +387,23 @@
 LinkName
+Trigger
 (type, n
@@ -571,32 +571,39 @@
 as sent%0ALinkName
+Trigger
 .prototype._resp
@@ -730,32 +730,39 @@
 as sent%0ALinkName
+Trigger
 .prototype._resp
@@ -870,16 +870,23 @@
 LinkName
+Trigger
 .prototy
@@ -1572,8 +1572,9 @@
 %7D);%0A%09%7D%0A%7D
+%0A

rename LinkName to LinkNameTrigger (consistency) 2/2