Mercurial > wow > squawk
comparison 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 |
comparison
equal
deleted
inserted
replaced
21:e066473450c2 | 22:8df5d8ef2e27 |
---|---|
10 -- * Owner (Name) | 10 -- * Owner (Name) |
11 -- * Time (Epoch) | 11 -- * Time (Epoch) |
12 -- * Message (140 characters) | 12 -- * Message (140 characters) |
13 -- * ReplyTo (Name) | 13 -- * ReplyTo (Name) |
14 -- * Related (Names) | 14 -- * Related (Names) |
15 -- * Trends (Term) | |
15 -- | 16 -- |
16 -- Each User will have the following lists: | 17 -- Each User will have the following lists: |
17 -- * Follower | 18 -- * Follower |
18 -- * Following | 19 -- * Following |
19 -- * Blocked | 20 -- * Blocked |
26 -- | 27 -- |
27 -- When a user makes a request to follow a private user, the subsequent paths occur: | 28 -- When a user makes a request to follow a private user, the subsequent paths occur: |
28 -- - Followee is added to Settings.Requested | 29 -- - Followee is added to Settings.Requested |
29 -- - Followee receives 'follow request' -> (their) Settings.Pending | 30 -- - Followee receives 'follow request' -> (their) Settings.Pending |
30 -- - Followee acts on request -> (their) Settings.Pending cleared | 31 -- - Followee acts on request -> (their) Settings.Pending cleared |
31 -- 1) Follwer is online | 32 -- 1) Follower is online |
32 -- - Follower receives 'request accepted' -> Added to Settings.Following and | 33 -- - Follower receives 'request accepted' -> Added to Settings.Following and |
33 -- cleared from Settings.Requested | 34 -- cleared from Settings.Requested |
34 -- 2) Follower is offline | 35 -- 2) Follower is offline |
35 -- - The next time Follower is online and recieves a Squawk we check if there | 36 -- - The next time Follower is online and recieves a Squawk we check if there |
36 -- is a Settings.Requested for that name, and if so assume they have approved | 37 -- is a Settings.Requested for that name, and if so assume they have approved |
37 -- and clear/add records appropriately. | 38 -- and clear/add records appropriately. |
38 -- | 39 -- |
39 -- For updating, there can be a few methods. | 40 --For updating, there can be a few methods. |
40 -- | 41 -- |
41 -- Guild open: you're not private, you broadcast to the guild your last X | 42 -- Guild open: you're not private, you broadcast to the guild your last X |
42 -- squawks on login | 43 -- squawks on login |
43 -- | 44 -- |
44 -- followers: | 45 -- Followers: If you login and are following people, you send a request to them |
46 -- directly upon login (after a brief pause to load everything) to get the last | |
47 -- 5 tweets from them. You also broadcast your last 5 tweets to them. | |
48 -- | |
49 -- Problems inherent in the system: | |
50 -- - Number of transmissions if Follow group is large. | |
51 -- - Guild transmissions in large guilds, how do we get the information of | |
52 -- people who have already logged on previously without being spammed? We | |
53 -- send a request for a guild listing of people using the addon and then | |
54 -- go through that list requesting the last 5 of each user one by one. | |
55 -- - Transmission must be able to be delayed if sender is in combat. | |
45 --]] | 56 --]] |
46 Model.Squawks = {} | 57 Model.Squawks = {} |
47 local Squawks = Model.Squawks | 58 local Squawks = Model.Squawks |
48 Squawks.Main = {} | 59 Squawks.Main = {} |
49 Squawks.Owners = {} | 60 Squawks.Owners = {} |
60 ["SHAMAN"] = "2459FF", | 71 ["SHAMAN"] = "2459FF", |
61 ["WARLOCK"] = "9482C9", | 72 ["WARLOCK"] = "9482C9", |
62 ["WARRIOR"] = "C79C6E", | 73 ["WARRIOR"] = "C79C6E", |
63 } | 74 } |
64 | 75 |
65 local function wrap(str, limit) | |
66 limit = limit or 72 | |
67 local here = 1 | |
68 return str:gsub("|c%x-|H.-|h(.-)|h|r", "%1"):gsub("(%s+)()(%S+)()", | |
69 function(sp, st, word, fi) | |
70 if fi-here > limit then | |
71 here = st | |
72 return "\n"..word | |
73 end | |
74 end) | |
75 end | |
76 | |
77 function Squawks:new(Message, Owner, Class, ReplyStamp) | 76 function Squawks:new(Message, Owner, Class, ReplyStamp) |
78 View:Print("New: "..ReplyStamp) | 77 View:Print("New: "..ReplyStamp) |
79 local o = {} | 78 local o = {} |
80 o.Owner = Owner or UnitName("player") | 79 o.Owner = Owner or UnitName("player") |
81 o.Message = wrap(Message) | 80 o.Message = Message |
82 o.Time = time() | 81 o.Time = time() |
83 local reply, to = strsplit("@", ((strsplit(" ", Message)))) | 82 local reply, to = strsplit("@", ((strsplit(" ", Message)))) |
84 if reply == "" then | 83 if reply == "" then |
85 o.ReplyTo = to:match("%P+") -- Get everything except punctuation | 84 o.ReplyTo = to:match("%P+") -- Get everything except punctuation |
86 o.ReplyStamp = ReplyStamp | 85 o.ReplyStamp = ReplyStamp |
94 end | 93 end |
95 end | 94 end |
96 | 95 |
97 if #o.Related == 0 then | 96 if #o.Related == 0 then |
98 o.Related = nil | 97 o.Related = nil |
98 end | |
99 | |
100 o.Trends = {} | |
101 | |
102 for word in string.gmatch(Message, "#(%S+)") do | |
103 table.insert(o.Trends, word) | |
104 end | |
105 | |
106 if #o.Trends == 0 then | |
107 o.Trends = nil | |
99 end | 108 end |
100 | 109 |
101 table.insert(self.Main, o) | 110 table.insert(self.Main, o) |
102 | 111 |
103 if not self.Squawkers[Owner] then | 112 if not self.Squawkers[Owner] then |