Mercurial > wow > squawk
comparison Squawk.lua @ 10:2231fd3f139b
Qtip added for LDB
| author | wobin |
|---|---|
| date | Thu, 23 Apr 2009 04:11:42 +1000 |
| parents | c535960b1245 |
| children | 0ca5ec0b7502 |
comparison
equal
deleted
inserted
replaced
| 9:c535960b1245 | 10:2231fd3f139b |
|---|---|
| 79 | 79 |
| 80 function Squawk:new(Message, Owner) | 80 function Squawk:new(Message, Owner) |
| 81 local o = {} | 81 local o = {} |
| 82 o.Owner = Owner or UnitName("player") | 82 o.Owner = Owner or UnitName("player") |
| 83 o.Message = Message | 83 o.Message = Message |
| 84 o.Time = os.time() | 84 o.Time = time() |
| 85 local reply, to = strsplit("@", ((strsplit(" ", Message)))) | 85 local reply, to = strsplit("@", ((strsplit(" ", Message)))) |
| 86 if reply == "" then | 86 if reply == "" then |
| 87 o.ReplyTo = to | 87 o.ReplyTo = to |
| 88 end | 88 end |
| 89 | 89 |
| 112 return self:Sort(mine) | 112 return self:Sort(mine) |
| 113 end | 113 end |
| 114 | 114 |
| 115 function Settings:IsPrivate() | 115 function Settings:IsPrivate() |
| 116 return Settings.Private | 116 return Settings.Private |
| 117 end | |
| 118 | |
| 119 function Settings:TogglePrivate() | |
| 120 Settings.Private = not Settings.Private | |
| 117 end | 121 end |
| 118 | 122 |
| 119 function Settings:AddFollower(Name) | 123 function Settings:AddFollower(Name) |
| 120 Settings.Follower[Name] = 1 | 124 Settings.Follower[Name] = 1 |
| 121 self:RemovePending(Name) | 125 self:RemovePending(Name) |
| 203 Settings:AddFollowing(Name) | 207 Settings:AddFollowing(Name) |
| 204 View:NotifyOfNewFollowing(Name) | 208 View:NotifyOfNewFollowing(Name) |
| 205 end | 209 end |
| 206 | 210 |
| 207 function Controller:AddANewSquawk(Name, Message, Source) | 211 function Controller:AddANewSquawk(Name, Message, Source) |
| 208 if not Model.Blocked[Name] then | 212 if not Settings.Blocked[Name] then |
| 209 | 213 |
| 210 if Source == "WHISPER" then | 214 if Source == "WHISPER" then |
| 211 if Model.Requested[Name] then -- We've been approved offline! | 215 if Settings.Requested[Name] then -- We've been approved offline! |
| 212 Model:AddFollowing(Name) | 216 Settings:AddFollowing(Name) |
| 213 end | 217 end |
| 214 | 218 |
| 215 if not Model.Following[Name] then -- If we're no longer following this person | 219 if not Settings.Following[Name] then -- If we're no longer following this person |
| 216 self:SendMessageToTarget(Name, "#Unfollow|"..UnitName("player")) | 220 self:SendMessageToTarget(Name, "#Unfollow|"..UnitName("player")) |
| 217 return | 221 return |
| 218 end | 222 end |
| 219 | 223 end |
| 220 table.insert(Model.Squawks, Squawk:new(Message, Name)) | 224 |
| 221 View:UpdateSquawkList() | 225 if Source == "GUILD" and Name == UnitName("player") then |
| 226 return | |
| 222 end | 227 end |
| 228 | |
| 229 table.insert(Model.Squawks, Squawk:new(Message, Name)) | |
| 230 View:UpdateSquawkList() | |
| 223 end | 231 end |
| 224 end | 232 end |
| 225 | 233 |
| 226 function Controller:SendNewSquawk(Message) | 234 function Controller:SendNewSquawk(Message) |
| 227 if not Model:IsPrivate() then | 235 if not Settings:IsPrivate() then |
| 228 self:SendMessageToGuild("#Squawk|"..UnitName("player").."|"..Message) | 236 self:SendMessageToGuild("#Squawk|"..UnitName("player").."|"..Message) |
| 229 end | 237 end |
| 230 | 238 |
| 231 self:AddANewSquawk(UnitName("player"), Message) | 239 self:AddANewSquawk(UnitName("player"), Message) |
| 232 | 240 |
| 233 for name, _ in pairs(Model.Following) do | 241 for name, _ in pairs(Settings.Following) do |
| 234 self:SendMessageToTarget(name, "#Squawk|"..UnitName("player").."|"..Message) | 242 self:SendMessageToTarget(name, "#Squawk|"..UnitName("player").."|"..Message) |
| 235 end | 243 end |
| 236 end | 244 end |
| 237 | 245 |
| 238 function Controller:ImPending(Name) | 246 function Controller:ImPending(Name) |
| 241 | 249 |
| 242 function Controller:PutForwardFollowRequest(Name) | 250 function Controller:PutForwardFollowRequest(Name) |
| 243 View:NotifyOfPendingRequest(Name) | 251 View:NotifyOfPendingRequest(Name) |
| 244 end | 252 end |
| 245 | 253 |
| 254 function Controller:ApprovePendingRequest(Name) | |
| 255 Settings:AddFollower(Name) | |
| 256 View:NotifyOfNewFollower(Name) | |
| 257 self:SendMessageToTarget(Name, "#Follow|"..UnitName("player")) | |
| 258 end | |
| 259 | |
| 246 function Controller:SendMessageToTarget(Name, Message) | 260 function Controller:SendMessageToTarget(Name, Message) |
| 247 self:SendCommMessage("Squawk", Message, "WHISPER", Name, "BULK") | 261 self:SendCommMessage("Squawk", Message, "WHISPER", Name) |
| 248 end | 262 end |
| 249 | 263 |
| 250 function Controller:SendMessageToGuild(Message) | 264 function Controller:SendMessageToGuild(Message) |
| 251 self:SendCommMessage("Squawk", Message, "GUILD") | 265 self:SendCommMessage("Squawk", Message, "GUILD") |
| 252 end | 266 end |
| 257 ["#Unfollow"] = Controller.TheyWantToUnfollowMe, | 271 ["#Unfollow"] = Controller.TheyWantToUnfollowMe, |
| 258 ["#Squawk"] = Controller.AddANewSquawk, | 272 ["#Squawk"] = Controller.AddANewSquawk, |
| 259 ["#Request"] = Controller.TheyWantToFollowMe, | 273 ["#Request"] = Controller.TheyWantToFollowMe, |
| 260 } | 274 } |
| 261 | 275 |
| 262 function Controller:ReceiveMessage(Prefix, Message, Distribution, Sender) | 276 function Controller:ReceiveMessage(Message, Distribution, Sender) |
| 263 local command, name, info = strsplit("|",Message) | 277 local command, name, info = strsplit("|",Message) |
| 264 Parse[command](self, name, info, Distribution) | 278 View:Print(Distribution..":"..Message) |
| 279 Parse[command](Controller, name, info, Distribution) | |
| 265 end | 280 end |
| 266 -- View -- | 281 -- View -- |
| 267 | 282 |
| 268 function View:UpdateSquawkList() | 283 function View:UpdateSquawkList() |
| 269 self:Print("Updated Squawk List") | 284 self:Print("Updated Squawk List") |
| 314 self:Print("I've blocked:") | 329 self:Print("I've blocked:") |
| 315 for name,_ in pairs(Settings.Blocked) do | 330 for name,_ in pairs(Settings.Blocked) do |
| 316 self:Print(name) | 331 self:Print(name) |
| 317 end | 332 end |
| 318 end | 333 end |
| 334 | |
| 335 local LDBFeed = LibStub("LibDataBroker-1.1"):NewDataObject("Squawk", {type = "data source", text = "Awk!"}) | |
| 336 local QTip = LibStub("LibQTip-1.0") | |
| 337 | |
| 338 function LDBFeed:OnEnter() | |
| 339 local tooltip = QTip:Acquire("Squawk",3, "LEFT", "LEFT", "RIGHT") | |
| 340 self.tooltip = tooltip | |
| 341 tooltip:AddHeader('Name') | |
| 342 tooltip:AddLine('testUser', 'Squawk!', '3 min ago') | |
| 343 tooltip:SmartAnchorTo(self) | |
| 344 tooltip:Show() | |
| 345 end | |
| 346 | |
| 347 function LDBFeed:OnTooltipShow() | |
| 348 end | |
| 349 | |
| 350 function LDBFeed:OnLeave() | |
| 351 QTip:Release(self.tooltip) | |
| 352 end |
