-------------------------------------------------------------------------------- --// Announcer Bot v1.2 ---------------------------------------------------- -- by: gg3k -- file: announcer.lua -- // Configure below -- -- Enter the name of the announcer here. Set to nil for alternate (***) layout. -- ex. BotName = "Hub-hostess" BotName = "×××" --// Timer related configuration ------ -- The number of minutes between each sent timer message. MessageDelay = 15 -- Use the Timed message feature (0 = no, 1 = yes) UseTimer = 1 -- These values will prevent users from getting flooded with repeated messages over time. -- all numbers refers to number of events that has to have taken place since the last message -- round before the bot sends the messages from start. Either of the two events will trigger a resending. -- (0 = disable) MinChat = 30 -- minimum number of chatlines+announced. MinUserConnect = 40 -- minimum number of new user connections (unannounced+announced). -- Enter the profile name of any profile that should invoke a message, and the message to be sent below. -- If you don't want a message, simply don't add one for that particular profile. :) -- Example: ["profile name"] = "message", -- -- To set a connection/disconnection message for a specific user put a $ before the nickname. -- Example: ["$user"] = "The amazing [user] has entered the hub.", -- -- [user] = the name of the entering user. (this will not work on the time messages) -- [hubname] = name of the hub. -- [usercount] = current number of users. -- [totalshare] = total amount of share. (TB) -- [minshare] = minimum share in hub. (GB) -- [maxusers] = maximum number of users. -- -- To disable connection/disconnection message for a specific user, set the message to @. -- Example: ["$user"] = "@" -- Connecting users. iprofiles = { ["Master"] = "Hub master [user] has entered [hubname].", ["Operator"] = "Operator [user] has entered [hubname].", ["VIP"] = "VIP user [user] has entered [hubname].", ["Reg"] = "Registered user [user] has entered [hubname].", } -- Disconnecting users oprofiles = { ["Master"] = "Hub master [user] has left [hubname].", ["Operator"] = "Operator [user] has left [hubname].", ["VIP"] = "VIP user [user] has left [hubname].", ["Reg"] = "Registered user [user] has left [hubname].", } -- Timed messages, add as many as you want, it will rotate in sequence. -- To read from a file type file: as message. Example: [1] = "file:message.txt", -- The filename is case sensitive, so take care when typing. Put the textfile in the scripts dir. -- The [] replacements works on the contents of the text file too. tmessages = { [1] = "You are in [hubname]. Add us to your favorites, type /fav", [2] = "Users: [usercount]/[maxusers] -×- Total share: [totalshare] TB.", [3] = "Minimum share is: [minshare] GB. 2 Slots minimum.", } -- End of configuration profileNr = { } count = { announced = 0, chat = 0, connected = 0, } --// This function is fired at the serving start function Main() for index,value in iprofiles do if strsub(index,1,1)~="$" then local arrTmp = GetProfileIdx(index) if arrTmp == -1 then SendToOps(BotName, "*** Error! Profile: "..index.." was not found.") else profileNr[arrTmp] = index end end end for index,value in oprofiles do if strsub(index,1,1)~="$" then local arrTmp = GetProfileIdx(index) if arrTmp == -1 then SendToOps(BotName, "*** Error! Profile: "..index.." was not found.") else profileNr[arrTmp] = index end end end if BotName == nil then layout = "*** " else layout = "<"..BotName.."> " end SetTimer(MessageDelay*60000) if UseTimer == 1 then StartTimer() end end --// This function is fired when a new data arrives function DataArrival(curUser, sData) if strsub(sData, 1, 1) == "<" then count.chat = count.chat + 1 end end --// This function is fired when a new user finishes the login function NewUserConnected(curUser) if iprofiles["$"..curUser.sName] then if iprofiles["$"..curUser.sName] ~= "@" then announce(curUser, iprofiles["$"..curUser.sName]) end count.announced = count.announced + 1 else if profileNr[curUser.iProfile] then local tempstr = GetProfileName(curUser.iProfile) announce(curUser, iprofiles[tempstr]) count.announced = count.announced + 1 else count.connected = count.connected + 1 end end end --// This function is fired when an operator enters the hub function OpConnected(curUser) if iprofiles["$"..curUser.sName] then if iprofiles["$"..curUser.sName] ~= "@" then announce(curUser, iprofiles["$"..curUser.sName]) end count.announced = count.announced + 1 else if profileNr[curUser.iProfile] then local tempstr = GetProfileName(curUser.iProfile) announce(curUser, iprofiles[tempstr]) count.announced = count.announced + 1 else count.connected = count.connected + 1 end end end --// This function is fired when an user disconnects function UserDisconnected(curUser) if oprofiles["$"..curUser.sName] then if oprofiles["$"..curUser.sName] ~= "@" then announce(curUser, oprofiles["$"..curUser.sName]) end count.announced = count.announced + 1 else if profileNr[curUser.iProfile] then local tempstr = GetProfileName(curUser.iProfile) announce(curUser, oprofiles[tempstr]) count.announced = count.announced + 1 end end end --// This function is fired when an operator disconnects function OpDisconnected(curUser) if oprofiles["$"..curUser.sName] then if oprofiles["$"..curUser.sName] ~= "@" then announce(curUser, oprofiles["$"..curUser.sName]) end count.announced = count.announced + 1 else if profileNr[curUser.iProfile] then local tempstr = GetProfileName(curUser.iProfile) announce(curUser, oprofiles[tempstr]) count.announced = count.announced + 1 end end end function OnTimer() if timetag == nil then timetag = 0 count.chat = MinChat count.connected = MinUserConnect count.announced = MinChat end timetag = timetag + 1 if timetag == 1 then if MinChat == 0 then tmpchat = -1 else tmpchat = count.chat + count.announced end if MinUserConnect == 0 then tmpconnect = -1 else tmpconnect = count.announced + count.connected end if tmpchat == -1 and MinUserConnect == -1 then count.chat = 0 count.announced = 0 count.connected = 0 end if tmpchat >= MinChat or tmpconnect >= MinUserConnect then count.chat = 0 count.announced = 0 count.connected = 0 else timetag = 0 end end if tmessages[timetag] then message = tmessages[timetag] if strsub(message, 1, 5)=="file:" then local filename = strsub(message, 6, strlen(message)) readfrom(filename) local message = "" while 1 do local line = read() if line == nil then break else message = message..line.."\r\n" end end announce(BotName, message) readfrom() else announce(BotName, message) end else timetag = 0 end end --// Help functions ---------------------------------------------------- function announce(user, string) local arrTmp = gsub(string, "%[usercount%]", frmHub:GetUsersCount()) arrTmp = gsub(arrTmp, "%[maxusers%]", frmHub:GetMaxUsers()) arrTmp = gsub(arrTmp, "%[totalshare%]", frmHub:GetCurrentShareAmount()/1024^4) arrTmp = gsub(arrTmp, "%[minshare%]", frmHub:GetMinShare()/1024) arrTmp = gsub(arrTmp, "%[hubname%]", frmHub:GetHubName()) if type(user) == "table" then arrTmp = gsub(arrTmp, "%[user%]", user.sName) end SendToAll(layout..arrTmp) end