--CHAT_MSG_SAY CHAT_MSG_YELL CHAT_MSG_CHANNEL CHAT_MSG_WHISPER ADD_KEYWORD REMOVE_KEYWORD LIST_KEYWORDS TOGGLE_MAGUS
function(e, msg, sender, ...)
	if not WeakAurasSaved.MagusKeywords then WeakAurasSaved.MagusKeywords = {} end
	if e == "CHAT_MSG_SAY" or e == "CHAT_MSG_YELL" or e == "CHAT_MSG_WHISPER" or e == "CHAT_MSG_CHANNEL" 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)
					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
		for k,v in pairs(WeakAurasSaved.MagusKeywords) do
			print(k)
		end
	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.toggle = 0
if not WeakAurasSaved.MagusKeywords then WeakAurasSaved.MagusKeywords = {} end