-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobotsDotTxtClient.lua
More file actions
24 lines (20 loc) · 921 Bytes
/
RobotsDotTxtClient.lua
File metadata and controls
24 lines (20 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if _G.RobotsDotTxtAPI then return end
local ROBOTS_PREFIX = "robots.txt"
C_ChatInfo.RegisterAddonMessagePrefix(ROBOTS_PREFIX)
RobotsDotTxtAPI = {}
-- Before messaging a customer, call this to notify them that a message is
-- coming so they can chose to filter that message out.
RobotsDotTxtAPI.NotifyCustomer = function(target, addon)
C_ChatInfo.SendAddonMessage(ROBOTS_PREFIX, "Q:" .. addon, "WHISPER", target)
end
local listener = CreateFrame("Frame")
listener:RegisterEvent("CHAT_MSG_ADDON")
listener:SetScript("OnEvent", function(self, event, prefix, text, channel, sender)
if prefix == ROBOTS_PREFIX and text:find("D:") then
local msgs = { "i cn", "me", "i can do tht", "sedn it", "wat u need" }
local _, delay = strsplit(":", text)
C_Timer.After(tonumber(delay), function()
SendChatMessage(msgs[math.random(#msgs)], "WHISPER", nil, sender)
end)
end
end)