diff Controller.lua @ 19:431f2fce08f2

Added in link stripping Coloured class names Reply to specific squawk Related squawks fixed new arrow to indicate reply limit to 140 characters
author wobin
date Tue, 12 May 2009 00:57:59 +1000
parents a3328fffef5c
children
line wrap: on
line diff
--- a/Controller.lua	Thu May 07 02:52:23 2009 +1000
+++ b/Controller.lua	Tue May 12 00:57:59 2009 +1000
@@ -10,11 +10,11 @@
 	if Settings:IsPrivate() then
 		Settings:AddPending(Name)
 		self:PutForwardFollowRequest(Name)
-		self:SendMessageToTarget(Name, "#Pending|"..UnitName("player"))
+		self:SendMessageToTarget(Name, "#Pending|"..self.Name)
 	else
 		Settings:AddFollower(Name)
 		View:NotifyOfNewFollower(Name)
-		self:SendMessageToTarget(Name, "#Follow|"..UnitName("player"))
+		self:SendMessageToTarget(Name, "#Follow|"..self.Name)
 	end
 end
 
@@ -23,13 +23,13 @@
 end
 
 function Controller:IWantToFollowThem(Name)
-	self:SendMessageToTarget(Name, "#Request|"..UnitName("player"))
+	self:SendMessageToTarget(Name, "#Request|"..self.Name)
 	Settings:AddRequested(Name)
 end
 
 function Controller:IWantToUnfollowThem(Name)
 	Settings:RemoveFollowing(Name)
-	self:SendMessageToTarget(Name, "#Unfollow|"..UnitName("player"))
+	self:SendMessageToTarget(Name, "#Unfollow|"..self.Name)
 	View:NotifyOfUnfollowing(Name)
 end
 
@@ -38,7 +38,7 @@
 	View:NotifyOfNewFollowing(Name)
 end
 
-function Controller:AddANewSquawk(Name, Message, Source)
+function Controller:AddANewSquawk(Name, Class, Message, Reply, Source)
 	if not Settings.Blocked[Name] then
 	
 		if Source == "WHISPER" then
@@ -47,17 +47,17 @@
 			end
 
 			if not Settings.Following[Name] then -- If we're no longer following this person
-				self:SendMessageToTarget(Name, "#Unfollow|"..UnitName("player"))
+				self:SendMessageToTarget(Name, "#Unfollow|"..self.Name)
 				return
 			end
 		end	
 		
-		if Source == "GUILD" and Name == UnitName("player") then
+		if Source == "GUILD" and Name == self.Name then
 			return
 		end
 
-		table.insert(Model.Squawks, Squawks:new(Message, Name))
-		View:UpdateSquawkList()	
+		table.insert(Model.Squawks, Squawks:new(Message, Name, Class, Reply))
+		--View:UpdateSquawkList()	
 	end
 end
 
@@ -75,14 +75,14 @@
 	end
 end
 
-function Controller:SendNewSquawk(Message)
+function Controller:SendNewSquawk(Message, ReplyStamp)
 	if not Settings:IsPrivate() then
-		self:SendMessageToGuild("#Squawk|"..UnitName("player").."|"..Message)
+		self:SendMessageToGuild("#Squawk|"..self.Name.."|"..self.Class.."|"..ReplyStamp or "".."|"..Message)
 	end
 
-	self:AddANewSquawk(UnitName("player"), Message)
+	self:AddANewSquawk(self.Name, self.Class, Message, ReplyStamp)
 	for name, _ in pairs(Settings.Following) do
-		self:SendMessageToTarget(name, "#Squawk|"..UnitName("player").."|"..Message)
+		self:SendMessageToTarget(name, "#Squawk|"..self.Name.."|"..self.Class.."|"..ReplyStamp or "".."|"..Message)
 	end
 end
 
@@ -97,7 +97,7 @@
 function Controller:ApprovePendingRequest(Name)
 	Settings:AddFollower(Name)
 	View:NotifyOfNewFollower(Name)
-	self:SendMessageToTarget(Name, "#Follow|"..UnitName("player"))
+	self:SendMessageToTarget(Name, "#Follow|"..self.Name)
 end
 
 
@@ -120,8 +120,7 @@
 	}
 
 function Controller:ReceiveMessage(Message, Distribution, Sender)
-	local command, name, info = strsplit("|",Message)
-	View:Print(Distribution..":"..Message)
-	Parse[command](Controller, name, info, Distribution)
+	local command, name, class, reply, info = strsplit("|",Message)
+	Parse[command](Controller, name, class, reply, info, Distribution)
 end