Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("ts3init")
- require("ts3defs")
- require("ts3events")
- local MSGRedirect = {
- info = {
- MODULE = "MSG Redirect Module",
- MODULESHORT = "MSGR",
- MODULEFOLDER = "MSGRedirect",
- MODULEFILE = "init",
- MODULEEXT = "lua",
- MODULEVERSION = "1.0",
- MODULEAUTHOR = "Bluscream",
- DEBUG = true,
- },
- var = {
- guestChannelGroup = "14",
- ENABLED = false,
- LAST = "0",
- },
- }
- BadWordArray = { 'hurensohn', 'ddos', 'wichser', 'egal', 'lizard', 'asshole', 'arschloch', 'fick', 'anus', 'scheide', 'vagina', 'fotze', 'schlampe', 'hitler', 'adolf', 'sieg', 'heil' }
- LinkArray = { '%://', 'www%.', '%.net', '%.de', '%.com', '%.me', '%.tk' }
- oldMSG = ""
- local function ScriptLog(logMSG)
- if MSGRedirect.info.DEBUG == true then
- local tsCol = { 'Green', 'Black', 'Red', 'Blue' }
- local RANDCOL = ( tsCol[ math.random( #tsCol ) ] )
- local scriptTimestamp = os.date("%x %X")
- ts3.printMessageToCurrentTab("[color=Black][[/color][color="..RANDCOL.."]"..scriptTimestamp.."[/color][color=Black]][/color]> "..MSGRedirect.info.MODULESHORT..": "..logMSG)
- -- ts3.logMessage(logMSG, 4, 0x0002, 1)
- -- debugPrint(logMSG)
- print(logMSG)
- end
- end
- local function isempty(s)
- return s == nil or s == ''
- end
- local function urlencode(str)
- if (str) then
- str = string.gsub (str, "\n", "\r\n")
- str = string.gsub (str, "([^%w ])",
- function (c) return string.format ("%%%02X", string.byte(c)) end)
- str = string.gsub (str, " ", "+")
- end
- return str
- end
- function msgredirect(serverConnectionHandlerID)
- if MSGRedirect.var.ENABLED == true then
- MSGRedirect.var.ENABLED = false
- ts3.printMessageToCurrentTab("MSGRedirect set to \"FALSE\"")
- else
- MSGRedirect.var.ENABLED = true
- ts3.printMessageToCurrentTab("MSGRedirect set to \"TRUE\"")
- end
- end
- function onClientMoveEvent(serverConnectionHandlerID, clientID, oldChannelID, newChannelID, visibility, moveMessage)
- if MSGRedirect.var.ENABLED == true and MSGRedirect.var.LAST ~= clientID then
- local ownID = ts3.getClientID(serverConnectionHandlerID)
- local ownChannelID = ts3.getChannelOfClient(serverConnectionHandlerID, ownID)
- if newChannelID == ownChannelID and clientID ~= ownID then
- local clientServerGroups = ts3.getClientVariableAsString(serverConnectionHandlerID,clientID,34)
- if string.find(clientServerGroups, MSGRedirect.var.guestChannelGroup) then
- MSGRedirect.var.LAST = clientID
- local clientName = ts3.getClientVariableAsString(serverConnectionHandlerID,clientID,ts3defs.ClientProperties.CLIENT_NICKNAME)
- ts3.requestSendPrivateTextMsg(serverConnectionHandlerID, "\n\nHallo [color=green]" .. clientName .. "[/color], du bist hier [color=red]Gast[/color] aber moechtest trozdem im Channel mitschreiben?\n\nDann schreib mir einfach zurueck und ich werde die Nachricht an den Channel weiterleiten.\n\n[color=red]INFO: SPAM ODER SONSTIGER ABUSE WIRD MIT SOFORTIGEM CHANNELBAN UND BLOCK BESTRAFT![/color]", clientID)
- end
- end
- end
- end
- function onTextMessageEvent(serverConnectionHandlerID, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored)
- local ownID = ts3.getClientID(serverConnectionHandlerID)
- local ownChannelID = ts3.getChannelOfClient(serverConnectionHandlerID, ownID)
- local clientChannelID = ts3.getChannelOfClient(serverConnectionHandlerID, fromID)
- local clientServerGroups = ts3.getClientVariableAsString(serverConnectionHandlerID,fromID,34)
- if MSGRedirect.var.ENABLED == true and ffIgnored == 0 and toID == ownID and clientChannelID == ownChannelID and string.find(clientServerGroups, MSGRedirect.var.guestChannelGroup) then
- lowMessage = string.lower(message)
- if lowMessage ~= oldMSG and string.len(lowMessage) > 1 and string.len(lowMessage) < 850 then
- local clientName = ts3.getClientVariableAsString(serverConnectionHandlerID,fromID,ts3defs.ClientProperties.CLIENT_NICKNAME)
- if string.find (lowMessage, "ts3server:" ) ~= nil then
- ScriptLog(clientName .. " hat versucht einen TS3Server Link zu versenden.")
- elseif string.find (lowMessage, '%d+%.%d+%.%d+%.%d') ~= nil or string.find (lowMessage, '%w%w%w%w::%w%w%w%w::%w%w%w%w::%w%w%w%w') ~= nil or string.find (lowMessage, '%w%w%w%w:%w%w%w%w:%w%w%w%w:%w%w%w%w:%w%w%w%w:%w%w%w%w:%w%w%w%w:%w%w%w%w') ~= nil then
- ScriptLog(clientName .. " hat versucht eine IP zu versenden.")
- -- elseif then
- -- ScriptLog(clientName .. " hat versucht eine IP zu versenden.")
- else
- local uniqueID = ts3.getClientVariableAsString(serverConnectionHandlerID,fromID,ts3defs.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
- local nickNameEncoded = urlencode(clientName)
- ts3.requestSendChannelTextMsg(serverConnectionHandlerID, "Weitergeleitete Nachricht von [URL=client://" .. fromID .. "/" .. uniqueID .. "~" .. nickNameEncoded .. "]\"" .. clientName .. "\"[/url]: " .. message, clientChannelID)
- oldMSG = lowMessage
- end
- end
- end
- end
- local registeredMSGREvents = {
- onClientMoveEvent = onClientMoveEvent,
- onTextMessageEvent = onTextMessageEvent
- }
- ts3RegisterModule(MSGRedirect.info.MODULE, registeredMSGREvents)
- ScriptLog("Loaded "..MSGRedirect.info.MODULE.." v"..MSGRedirect.info.MODULEVERSION.." by "..MSGRedirect.info.MODULEAUTHOR.." from "..ts3.getPluginPath().."lua_plugin/"..MSGRedirect.info.MODULEFOLDER.."/"..MSGRedirect.info.MODULEFILE.."."..MSGRedirect.info.MODULEEXT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement