-
Notifications
You must be signed in to change notification settings - Fork 1
/
plink.lua
112 lines (98 loc) · 3.18 KB
/
plink.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
local profList = {
["!bs"] = "Blacksmithing",
["!blacksmithing"] = "Blacksmithing",
["!jc"] = "Jewelcrafting",
["!jewelcrafting"] = "Jewelcrafting",
["!enchanting"] = "Enchanting",
["!tailoring"] = "Tailoring",
["!alchemy"] = "Alchemy",
["!engineering"] = "Engineering",
["!inscription"] = "Inscription",
["!lw"] = "Leatherworking",
["!leatherworking"] = "Leatherworking",
["!cooking"] = "Cooking",
-- ["!smelting"] = "Smelting",
-- ["!mining"] = "Smelting",
}
-- Custom text to send when sending to a channel
local customText = " no fee, tips are welcome"
-- Text to send when someone tries to request a profession you don't have
local whisperText = "I dont have "
-- Text to print when you try to send a profession you don't have to a channel
local channelLinkText = "You don't seem to have that profession"
-- guildDelay/whisperDelay wait time before sending guild/whisper
local guildDelay, whisperDelay = 3, 3
-- Store time sent and who requested the link
local spamTable = {}
local f = CreateFrame("Frame", "bProfLink", nil)
f:SetScript("OnEvent", function(self, event, ...)
self[event](self, event, ...)
end)
function f:CHAT_MSG_WHISPER(event, msg, author, ...)
if(author == UnitName("player")) then return end
for k,v in pairs(profList) do
if msg:lower() == k or msg:sub(0,4) == k:sub(0,4) then
local currentTime = GetTime()
if not spamTable[author] or currentTime > (spamTable[author]+whisperDelay) then
local spell = select(2,GetSpellLink(v))
if spell then
SendChatMessage(spell, "WHISPER", nil, author)
spamTable[author] = currentTime
else
SendChatMessage(whisperText .. v, "WHISPER", nil, author)
end
break
end
end
end
end
function f:CHAT_MSG_GUILD(event, msg, author, ...)
if(author == UnitName("player")) then return end
for k,v in pairs(profList) do
if msg:lower() == k or msg:sub(0,4) == k:sub(0,4) then
local currentTime = GetTime()
if not spamTable[author] or currentTime > (spamTable[author]+guildDelay) then
local spellCheck = select(2,GetSpellLink(v))
if spellCheck then
SendChatMessage(spellCheck, "GUILD", nil)
spamTable[author] = currentTime
end
break
end
end
end
end
f:RegisterEvent("CHAT_MSG_WHISPER")
f:RegisterEvent("CHAT_MSG_GUILD")
SLASH_BLIB_PROF1 = '/pf'
--sneak some code from instancefuuuuuu
SlashCmdList['BLIB_PROF'] = function(arg1)
local eb, prof, chattype
if(GetCVar("chatStyle") == 'classic') then
eb = LAST_ACTIVE_CHAT_EDIT_BOX
chattype = eb:GetAttribute"chatType"
else
eb = _G['ChatFrame1EditBox']
chattype = eb:GetAttribute"chatType"
end
for link, spell in pairs(profList) do
if(arg1:lower() == link:sub(2)) then
local spellCheck = select(2,GetSpellLink(spell))
if spellCheck then
prof = spell
break
end
end
end
if prof then
if(chattype == "WHISPER") then
SendChatMessage(select(2,GetSpellLink(prof)), chattype, nil, eb:GetAttribute"tellTarget")
elseif (chattype == "CHANNEL") then
SendChatMessage(select(2,GetSpellLink(prof)) .. customText, chattype, nil, eb:GetAttribute"channelTarget")
else
SendChatMessage(select(2,GetSpellLink(prof)), chattype)
end
else
print("|cFF37FDFCb|rProflink: " .. channelLinkText)
end
end