diff Model.lua @ 22:8df5d8ef2e27 tip

switch back to LibQTip-1.0 as LQTC is depreciated Fixed up the line resizing as LQT does this automatically now
author wobin
date Wed, 22 Jul 2009 23:16:42 +1000
parents 431f2fce08f2
children
line wrap: on
line diff
--- a/Model.lua	Wed Jul 22 22:06:36 2009 +1000
+++ b/Model.lua	Wed Jul 22 23:16:42 2009 +1000
@@ -12,6 +12,7 @@
 -- * Message (140 characters)
 -- * ReplyTo (Name)
 -- * Related (Names)
+-- * Trends (Term)
 --
 -- Each User will have the following lists:
 -- * Follower
@@ -28,7 +29,7 @@
 -- - Followee is added to Settings.Requested 
 -- - Followee receives 'follow request' -> (their) Settings.Pending
 -- - Followee acts on request -> (their) Settings.Pending cleared
---  1) Follwer is online
+--  1) Follower is online
 --		- Follower receives 'request accepted' -> Added to Settings.Following and
 --		cleared from Settings.Requested
 --  2) Follower is offline
@@ -36,12 +37,22 @@
 --		is a Settings.Requested for that name, and if so assume they have approved
 --		and clear/add records appropriately.
 --
---		For updating, there can be a few methods.
+--For updating, there can be a few methods.
 --
 --		Guild open: you're not private, you broadcast to the guild your last X
 --		squawks on login
 --
---		followers:
+--		Followers: If you login and are following people, you send a request to them
+--		directly upon login (after a brief pause to load everything) to get the last 
+--		5 tweets from them. You also broadcast your last 5 tweets to them.
+--
+--		Problems inherent in the system:
+--			- Number of transmissions if Follow group is large.
+--			- Guild transmissions in large guilds, how do we get the information of 
+--			  people who have already logged on previously without being spammed? We 
+--			  send a request for a guild listing of people using the addon and then 
+--			  go through that list requesting the last 5 of each user one by one.
+--			- Transmission must be able to be delayed if sender is in combat.
 --]]
 Model.Squawks = {}
 local Squawks = Model.Squawks
@@ -62,23 +73,11 @@
 ["WARRIOR"] = "C79C6E",
 }
 	
-local function wrap(str, limit)
-  limit = limit or 72
-	local here = 1
-  return str:gsub("|c%x-|H.-|h(.-)|h|r", "%1"):gsub("(%s+)()(%S+)()",
-                          function(sp, st, word, fi)
-                            if fi-here > limit then
-                              here = st 
-                              return "\n"..word
-                            end
-                          end)
-end
-
 function Squawks:new(Message, Owner, Class, ReplyStamp)
 	View:Print("New: "..ReplyStamp)
 	local o = {}
 	o.Owner = Owner or UnitName("player")
-	o.Message = wrap(Message)
+	o.Message = Message
 	o.Time = time()
 	local reply, to = strsplit("@", ((strsplit(" ", Message))))
 	if reply == "" then
@@ -97,6 +96,16 @@
 	if #o.Related == 0 then
 		o.Related = nil
 	end
+	
+	o.Trends = {}
+
+	for word in string.gmatch(Message, "#(%S+)") do
+		table.insert(o.Trends, word)
+	end
+	
+	if #o.Trends == 0 then
+		o.Trends = nil
+	end
 
 	table.insert(self.Main, o)