-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
local addonName, addonTable = ... | ||
AutoInvite = addonTable | ||
|
||
AutoInvite.autoInviteFrame = CreateFrame("Frame", "AutoInvite", UIParent) | ||
AutoInvite.autoInviteFrame:RegisterEvent("PLAYER_LOGIN") | ||
AutoInvite.autoInviteFrame:RegisterEvent("CHAT_MSG_WHISPER") | ||
AutoInvite.autoInviteFrame:SetScript("OnEvent", function(self, event, ...) | ||
if event == "PLAYER_LOGIN" then | ||
AutoInvite:Initialize() | ||
end | ||
|
||
if event == "CHAT_MSG_WHISPER" then | ||
AutoInvite:ProcessWhisper(...) | ||
end | ||
end) | ||
|
||
function AutoInvite:Initialize() | ||
if AutoInviteSettings == nil then | ||
AutoInvite:LoadDefaults() | ||
else | ||
AutoInvite:ApplySavedVariables() | ||
end | ||
end | ||
|
||
function AutoInvite:ApplySavedVariables() | ||
AutoInvite:SetEnableDisable(AutoInviteSettings.AutoInviteEnabled) | ||
AutoInvite:SetInviteKeyword(AutoInviteSettings.AutoInviteKeyword, 0) | ||
AutoInvite:SetInviteChannel(AutoInviteSettings.AutoInviteChannel, 0) | ||
end | ||
|
||
function AutoInvite:ProcessWhisper(text, playerName) | ||
if not AutoInviteSettings.AutoInviteEnabled then | ||
return | ||
end | ||
|
||
if text == AutoInviteSettings.AutoInviteKeyword then | ||
InviteUnit(playerName) | ||
end | ||
end | ||
|
||
SLASH_AUTOINVITE1 = "/autoinvite" | ||
SLASH_AUTOINVITE2 = "/autoinvite help" | ||
SLASH_AUTOINVITE3 = "/autoinvite enable" | ||
SLASH_AUTOINVITE4 = "/autoinvite disable" | ||
SLASH_AUTOINVITE5 = "/autoinvite b" | ||
SLASH_AUTOINVITE6 = "/autoinvite broadcast" | ||
SLASH_AUTOINVITE7 = "/autoinvite k" | ||
SLASH_AUTOINVITE8 = "/autoinvite keyword" | ||
SLASH_AUTOINVITE9 = "/autoinvite c" | ||
SLASH_AUTOINVITE10 = "/autoinvite channel" | ||
|
||
SlashCmdList["AUTOINVITE"] = function(msg) | ||
if AutoInvite:StringIsNullOrEmpty(msg) then | ||
AutoInvite:PrintHelpInformation() | ||
end | ||
|
||
local slashCommandMsg = AutoInvite:SplitString(msg, " ") | ||
local subCommand = slashCommandMsg[1] | ||
local subCommandMsg = nil | ||
|
||
if table.getn(slashCommandMsg) > 1 then | ||
subCommandMsg = slashCommandMsg[2] | ||
end | ||
|
||
if subCommand == "help" then | ||
AutoInvite:PrintHelpInformation() | ||
end | ||
|
||
if subCommand == "enable" then | ||
AutoInvite:SetEnableDisable(true) | ||
end | ||
|
||
if subCommand == "disable" then | ||
AutoInvite:SetEnableDisable(false) | ||
end | ||
|
||
if subCommand == "broadcast" or subCommand == "b" then | ||
AutoInvite:ProcessBroadcast(subCommandMsg, AutoInviteSettings.AutoInviteChannel) | ||
end | ||
|
||
if subCommand == "keyword" or subCommand == "k" then | ||
AutoInvite:ProcessKeyword(subCommandMsg) | ||
end | ||
|
||
if subCommand == "channel" or subCommand == "c" then | ||
AutoInvite:ProcessChannel(subCommandMsg) | ||
end | ||
end | ||
|
||
function AutoInvite:PrintHelpInformation() | ||
print("AutoInvite Help Information") | ||
print("/autoinvite, /autoinvite help -- Displays help information for AutoInvite addon.") | ||
print("/autoinvite enable -- Turns on the AutoInvite functionality.") | ||
print("/autoinvite disable -- Turns off the AutoInvite functionality.") | ||
print("/autoinvite broadcast [keyword], /autoinvite b [keyword] -- Broadcasts the invite keyword to the guild channel and enables addon if it is disabled.") | ||
print("/autoinvite keyword [keyword], /autoinvite k [keyword] -- Changes the invite keyword.") | ||
print("/autoinvite channel [channel], /autoinvite c [channel] -- Changes the invite channel. Possible examples: 'SAY', 'YELL', 'PARTY', 'GUILD', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'") | ||
end | ||
|
||
function AutoInvite:ProcessBroadcast(subCommandMsg, chatChannel) | ||
AutoInvite:SetEnableDisable(true) | ||
|
||
if not AutoInvite:StringIsNullOrEmpty(subCommandMsg) then | ||
AutoInvite:SetInviteKeyword(subCommandMsg, 0) | ||
end | ||
|
||
if AutoInvite:StringIsNullOrEmpty(AutoInviteSettings.AutoInviteKeyword) then | ||
print("AutoInvite keyword is not set.") | ||
return | ||
end | ||
|
||
if AutoInvite:StringIsNullOrEmpty(AutoInviteSettings.AutoInviteChannel) then | ||
print("AutoInvite channel is not set.") | ||
return | ||
end | ||
|
||
SendChatMessage("Whisper me '" .. AutoInviteSettings.AutoInviteKeyword .. "' for invite.", chatChannel) | ||
end | ||
|
||
function AutoInvite:ProcessKeyword(keyword) | ||
if not AutoInvite:StringIsNullOrEmpty(keyword) then | ||
AutoInvite:SetInviteKeyword(keyword, 0) | ||
end | ||
|
||
if AutoInvite:StringIsNullOrEmpty(AutoInviteSettings.AutoInviteKeyword) then | ||
print("AutoInvite keyword is not set.") | ||
else | ||
print("AutoInvite keyword is set to '" .. AutoInviteSettings.AutoInviteKeyword .. "'.") | ||
end | ||
end | ||
|
||
function AutoInvite:ProcessChannel(channel) | ||
if not AutoInvite:StringIsNullOrEmpty(channel) then | ||
AutoInvite:SetInviteChannel(channel, 0) | ||
end | ||
|
||
if AutoInvite:StringIsNullOrEmpty(AutoInviteSettings.AutoInviteChannel) then | ||
print("AutoInvite channel is not set.") | ||
else | ||
print("AutoInvite channel is set to '" .. AutoInviteSettings.AutoInviteChannel .. "'.") | ||
end | ||
end | ||
|
||
function AutoInvite:StringIsNullOrEmpty(s) | ||
if s == nil or s == '' then | ||
return true | ||
end | ||
end | ||
|
||
function AutoInvite:SplitString(slashCommand, delimiter) | ||
result = {} | ||
|
||
for match in (slashCommand .. delimiter):gmatch("(.-)" .. delimiter) do | ||
table.insert(result, match) | ||
end | ||
|
||
return result | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Interface: 11302 | ||
## Title: AutoInvite | ||
## Author: Eulav | ||
## Version: 0.1 | ||
## SavedVariablesPerCharacter: AutoInviteSettings | ||
|
||
AutoInvite.lua | ||
AutoInviteDefaults.lua | ||
AutoInviteOptions.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
local addonName, addonTable = ... | ||
AutoInvite = addonTable | ||
|
||
function AutoInvite:LoadDefaults() | ||
AutoInviteSettings = { | ||
AutoInviteEnabled = false, | ||
AutoInviteKeyword = "invite", | ||
AutoInviteChannel = "SAY" | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
local addonName, addonTable = ... | ||
AutoInvite = addonTable | ||
|
||
AutoInvite.optionsFrame = CreateFrame("Frame", addonName .. "Config", InterfaceOptionsFramePanelContainer) | ||
AutoInvite.optionsFrame.name = addonName | ||
InterfaceOptions_AddCategory(AutoInvite.optionsFrame) | ||
|
||
-- Start Title Section | ||
|
||
AutoInvite.title = AutoInvite.optionsFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") | ||
AutoInvite.title:SetPoint("TOP", 0, -16) | ||
AutoInvite.title:SetText(addonName) | ||
|
||
--End Title Section | ||
|
||
-- Start Enable/Disable CheckButton Section | ||
|
||
AutoInvite.optionsEnable = CreateFrame("CheckButton", nil, AutoInvite.optionsFrame, "ChatConfigCheckButtonTemplate") | ||
AutoInvite.optionsEnable:SetPoint("TOPLEFT", 16, -32); | ||
AutoInvite.optionsEnable:SetText("AutoInvite Enable/Disable") | ||
AutoInvite.optionsEnable.tooltip = "Enable/Disable" | ||
AutoInvite.optionsEnable:SetScript("OnClick", | ||
function() | ||
AutoInvite:SetEnableDisable(AutoInvite.optionsEnable:GetChecked()) | ||
end | ||
); | ||
|
||
AutoInvite.optionsEnableLabel= AutoInvite.optionsFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") | ||
AutoInvite.optionsEnableLabel:SetPoint("TOPLEFT", 42, -38) | ||
AutoInvite.optionsEnableLabel:SetText("Enable AutoInvite") | ||
|
||
function AutoInvite:SetEnableDisable(enabled) | ||
AutoInviteSettings.AutoInviteEnabled = enabled | ||
AutoInvite.optionsEnable:SetChecked(enabled) | ||
end | ||
|
||
-- End Enable/Disable CheckButton Section | ||
|
||
-- Start Invite Keyword Section | ||
|
||
AutoInvite.optionsInviteKeywordLabel = AutoInvite.optionsFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") | ||
AutoInvite.optionsInviteKeywordLabel:SetPoint("TOPLEFT", 20, -64) | ||
AutoInvite.optionsInviteKeywordLabel:SetText("Invite Keyword") | ||
|
||
AutoInvite.optionsInviteKeyword = CreateFrame("EditBox", nil, AutoInvite.optionsFrame, "InputBoxTemplate") | ||
AutoInvite.optionsInviteKeyword:SetAutoFocus(false) | ||
AutoInvite.optionsInviteKeyword:SetWidth(250) | ||
AutoInvite.optionsInviteKeyword:SetHeight(20) | ||
AutoInvite.optionsInviteKeyword:SetPoint("TOPLEFT", 20, -80) | ||
AutoInvite.optionsInviteKeyword:SetScript("OnTextChanged", | ||
function() | ||
local keyword = AutoInvite.optionsInviteKeyword:GetText():gsub("^%s*(.-)%s*$", "%1") | ||
AutoInvite:SetInviteKeyword(keyword, AutoInvite.optionsInviteKeyword:GetCursorPosition()) | ||
end | ||
); | ||
|
||
function AutoInvite:SetInviteKeyword(inviteKeyword, cursorPosition) | ||
AutoInviteSettings.AutoInviteKeyword = inviteKeyword:gsub("^%s*(.-)%s*$", "%1") | ||
AutoInvite.optionsInviteKeyword:SetText(inviteKeyword) | ||
AutoInvite.optionsInviteKeyword:SetCursorPosition(cursorPosition) | ||
end | ||
|
||
-- End Invite Keyword Section | ||
|
||
-- Start Channel Section | ||
|
||
AutoInvite.optionsInviteChannelLabel = AutoInvite.optionsFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") | ||
AutoInvite.optionsInviteChannelLabel:SetPoint("TOPLEFT", 20, -106) | ||
AutoInvite.optionsInviteChannelLabel:SetText("Channel") | ||
|
||
AutoInvite.optionsInviteChannel = CreateFrame("EditBox", nil, AutoInvite.optionsFrame, "InputBoxTemplate") | ||
AutoInvite.optionsInviteChannel:SetAutoFocus(false) | ||
AutoInvite.optionsInviteChannel:SetWidth(250) | ||
AutoInvite.optionsInviteChannel:SetHeight(20) | ||
AutoInvite.optionsInviteChannel:SetPoint("TOPLEFT", 20, -122) | ||
AutoInvite.optionsInviteChannel:SetScript("OnTextChanged", | ||
function() | ||
local keyword = AutoInvite.optionsInviteChannel:GetText():gsub("^%s*(.-)%s*$", "%1") | ||
AutoInvite:SetInviteChannel(keyword, AutoInvite.optionsInviteChannel:GetCursorPosition()) | ||
end | ||
); | ||
|
||
function AutoInvite:SetInviteChannel(inviteChannel, cursorPosition) | ||
AutoInviteSettings.AutoInviteChannel = inviteChannel:gsub("^%s*(.-)%s*$", "%1") | ||
AutoInvite.optionsInviteChannel:SetText(inviteChannel) | ||
AutoInvite.optionsInviteChannel:SetCursorPosition(cursorPosition) | ||
end | ||
|
||
-- End Channel Section |