--CHAT_MSG_SAY CHAT_MSG_YELL CHAT_MSG_WHISPER ADD_KEYWORD REMOVE_KEYWORD LIST_KEYWORDS TOGGLE_MAGUS
function(e, msg, sender, ...)
	if not aura_env.toggle then aura_env.toggle = 1 end
	if not WeakAurasSaved.MagusKeywords then WeakAurasSaved.MagusKeywords = {
		["port"] = 1,
		["portal"] = 1,
		["org"] = 1,
		["og"] = 1,
		["uc"] = 1,
		["under"] = 1,
		["thunder"] = 1,
		["tb"] = 1,
		["wtb"] = 1, 
	}
	end
	if e == "CHAT_MSG_SAY" or e == "CHAT_MSG_YELL" or e == "CHAT_MSG_WHISPER" then
		local class = select(2, GetPlayerInfoByGUID(select(10, ...)))
		if msg and aura_env.toggle == 1 then
			msg = msg:lower()
			local noRealmSender = sender:match("(.+)-%w+")
			for k,v in pairs(WeakAurasSaved.MagusKeywords) do
				if msg:match(k) then
					local st, en = msg:find(k)
					if not (st > 1 and msg:match(".", st - 1) ~= " ") and not (en < strlen(msg) and msg:match(".", en + 1) ~= " ") and class ~= "MAGE" then
						InviteUnit(sender)
						return true
					end
				end
			end
		end
	elseif e == "TOGGLE_MAGUS" then
		if aura_env.toggle == 0 then
			print("Toggling script on")
			aura_env.toggle = 1
		else
			print("Toggling script off")
			aura_env.toggle = 0
		end
	elseif e == "ADD_KEYWORD" then
		if msg then
			print("Adding", msg)
			msg = msg:lower()
			WeakAurasSaved.MagusKeywords[msg] = 1
		else
			print("No keyword provided")
		end
	elseif e == "LIST_KEYWORDS" then
		local test = ""
		for k,v in pairs(WeakAurasSaved.MagusKeywords) do
			print(k)
			test = test .. k .. "\n"
		end
		message(test)
	elseif e == "REMOVE_KEYWORD" then
		if msg then
			if WeakAurasSaved.MagusKeywords[msg] then
				print("Removing", msg)
				WeakAurasSaved.MagusKeywords[msg] = nil
			else
				print(msg, "does not exist in the keyword table")
			end
		else
			print("No keyword provided")
		end
	end
end

--INIT
aura_env.button = CreateFrame("Button", "buton", UIParent, "SecureActionButtonTemplate")
aura_env.button:SetAttribute("type", "macro")
aura_env.button:SetPoint("CENTER", UIParent, "CENTER")
aura_env.button:SetWidth(128)
aura_env.button:SetHeight(128)
aura_env.button:SetNormalTexture("interface/icons/inv_misc_enggizmos_rocketchicken.blp")
aura_env.button:SetPushedTexture("interface/icons/inv_misc_enggizmos_rocketchicken.blp")
if not aura_env.toggle then aura_env.toggle = 1 end
if not WeakAurasSaved.MagusKeywords then WeakAurasSaved.MagusKeywords = {
	"port",
	"portal",
	"org",
	"og",
	"UC",
	"under",
	"thunder",
	"tb",
	"wtb", 
}