_=[[
######################################################################################
Filename: ptx_vicarious.lua
Released: Jun 21, 2006
Distributed by: http://ro.4242.hu/
Copyright (c) 2006, Hungarista
######################################################################################
Lua 5: The Programming Language
Open-Source Program for HubOwners
======================================================================================
Software by: Lua is a powerful light-weight programming language designed for extending applications.
Lua is also frequently used as a general-purpose, stand-alone language. Lua is free software.
######################################################################################
Many thanks to Szmeby and plop for the great table help, and TTB for the Hub-backup script
]]
bot = SetMan.GetString(21)
function OnStartup()
Core.SendToOps("<"..bot.."> Restart Scripts By ']['rIp?iN??uN")
if loadfile(string.gsub(Core.GetPtokaXPath(),"/","\\").."scripts\\offlines\\offsettings.dat") then
dofile(string.gsub(Core.GetPtokaXPath(),"/","\\").."scripts\\offlines\\offsettings.dat")
else
os.execute("md offlines")
tOfflineOps = {}
end
local file = io.open(string.gsub(Core.GetPtokaXPath(),"/","\\").."scripts\\offlines\\blat.exe","r")
if not file then
Core.SendToOpChat("The email-sender files didn't find in the "..string.gsub(Core.GetPtokaXPath(),"/","\\").."scripts\\offlines folder! Email sending will fail! Please copy blat files into it!")
end
file:close()
end
function OnExit()
local file = io.open(string.gsub(Core.GetPtokaXPath(),"/","\\").."scripts\\offlines\\offsettings.dat","w+")
Serialize(tOfflineOps,"tOfflineOps",file)
file:close()
end
function ChatArrival(curUser,sData)
Core.GetUserAllData(curUser)
if curUser.bOperator then
local _,_,sPrefix,sComd,sParam = string.find(sData,"%b<>%s*(%p)(%S*)%s*(.*)|")
if sPrefix then
local tCmds = {
["offlineme"] = function(curUser)
if sParam == "" then
Core.SendPmToNick(curUser.sNick,bot,"To enable the script to you, use the "..sPrefix..string.lower(sComd).." on , to disable "..sPrefix..string.lower(sComd).." off command.")
elseif sParam == "on" then
if not tOfflineOps[curUser.sNick] then
tOfflineOps[curUser.sNick]={
["settings"]={["emailad"] = "not@setted.yet",["msgs"] = 0,["maxmsgs"] = 30,["away"] = "off"},
["users"] = {}
}
Core.SendPmToNick(curUser.sNick,bot,"The offline messenger script has been successfully enabled to you!")
else
Core.SendPmToNick(curUser.sNick,bot,"The offline messenger script is already enabled to you.")
end
elseif sParam == "off" then
if tOfflineOps[curUser.sNick] ~= nil then
tOfflineOps[curUser.sNick] = nil
Core.SendPmToNick(curUser.sNick,bot,"The offline messenger script has been successfully disabled to you! (all your settings has been deleleted.)")
else
Core.SendPmToNick(curUser.sNick,bot,"You didn't enable the offline messanger script yet.")
end
else
Core.SendPmToNick(curUser.sNick,bot,"Unknown parameter: "..sParam.." Avaible are: on and off.")
end
return true
end,
["offlineemail"] = function(curUser)
if sParam == "" then
Core.SendPmToNick(curUser.sNick,bot,"To set up your e-mail adress use the "..sPrefix..string.lower(sComd).." email@adress.cc command"..
"command, where you have to replace the email@adress.cc to your e-mail adress. Current value: "..tOfflineOps[curUser.sNick]["settings"]["emailad"])
else
if tOfflineOps[curUser.sNick] ~= nil then
if sParam then
if string.find(sParam,"%S+@%S+%.%S+") then
tOfflineOps[curUser.sNick]["settings"]["emailad"] = sParam
Core.SendPmToNick(curUser.sNick,bot,"You have successfully setted up your e-mail adress: "..sParam)
else
Core.SendPmToNick(curUser.sNick,bot,"You wrote an invalid e-mail adress format!")
end
end
else
Core.SendPmToNick(curUser.sNick,bot,"You didn't enable the offline messenger script yet. To turn it on, use the "..sPrefix.."ome on command.")
end
end
return true
end,
["offmaxmsg"] = function(curUser)
if sParam == "" then
Core.SendPmToNick(curUser.sNick,bot,"Maximum number of messages, before scripts sends it in e-mail. To set up, use the "..sPrefix..string.lower(sComd).." <number> command"..
"Where the number is the maximum number of those messages, which will the bot recieve. If reached, script will send it in e-mail. Current value: "..tOfflineOps[curUser.sNick]["settings"]["maxmsgs"])
else
if tOfflineOps[curUser.sNick] ~= nil then
if sParam then
if string.find(sParam,"%d+") then
tOfflineOps[curUser.sNick]["settings"]["maxmsgs"] = sParam
Core.SendPmToNick(curUser.sNick,bot,"You have successfully setted up the maximum number of messages to: "..sParam)
else
Core.SendPmToNick(curUser.sNick,bot,"Parameter can be just number!")
end
end
else
Core.SendPmToNick(curUser.sNick,bot,"You didn't enable the offline messenger script yet. To turn it on, use the "..sPrefix.."ome on command.")
end
end
return true
end,
["offlineaway"] = function(curUser)
if sParam == "" then
Core.SendPmToNick(curUser.sNick,bot,"With this command you can set up the away message, which will send to the user, who send pm to the bot.\r\n"..
"Usage:\r\n"..
sPrefix.."offlineaway off - Disable the away message\r\n"..
sPrefix.."offlineaway message - Enable the away message, the value of 'message' will send to the user")
elseif sParam == "off" then
if tOfflineOps[curUser.sNick] ~= nil then
tOfflineOps[curUser.sNick]["settings"]["away"] = sParam
Core.SendPmToNick(curUser.sNick,bot,"You have successfully disabled the away message.")
else
Core.SendPmToNick(curUser.sNick,bot,"You didn't enable the offline messenger script yet. To turn it on, use the "..sPrefix.."ome on command.")
end
else
if tOfflineOps[curUser.sNick] ~= nil then
tOfflineOps[curUser.sNick]["settings"]["away"] = sParam
Core.SendPmToNick(curUser.sNick,bot,"You have successfully set up your away message: "..sParam)
else
Core.SendPmToNick(curUser.sNick,bot,"You didn't enable the offline messenger script yet. To turn it on, use the "..sPrefix.."ome on command.")
end
end
return true
end,
["offlineread"] = function(curUser)
if tOfflineOps[curUser.sNick] ~= nil then
if tOfflineOps[curUser.sNick]["settings"]["msgs"] ~= 0 then
local file = io.open(Core.GetPtokaXPath().."scripts/offlines/"..curUser.sNick..".txt", "r")
if (file) then
local border = string.rep("-=",80).."-"
local line = string.gsub(file:read("*all"), "\n", "\r\n")file:close()
local msg = "\r\n"..border.."\r\n\t\t\tNEW MESSAGES WHILE YOU WERE OFFLINE: (TOTALLY: "..tOfflineOps[curUser.sNick]["settings"]["msgs"]..")\r\n"..border.."\r\n"..line
local msg = msg.."\r\n"..border.."\r\n\t\t\tYOU CAN DELETE THE MESSAGES WITH THE "..sPrefix.."OFFLINEDELETE OR WITH THE "..sPrefix.."OD COMMAND.\r\n"..border
Core.SendPmToNick(curUser.sNick,bot,msg)
tOfflineOps[curUser.sNick]["settings"]["msgs"] = 0
else
Core.SendPmToNick(curUser.sNick,bot,"You haven't got new messages")
end
else
Core.SendPmToNick(curUser.sNick,bot,"You haven't got new messages")
end
else
Core.SendPmToNick(curUser.sNick,bot,"Before you want to read your messages, please enable this script to you... :D")
end
return true
end,
["offlinedel"] = function(curUser)
os.remove(Core.GetPtokaXPath().."scripts/offlines/"..curUser.sNick..".txt")
tOfflineOps[curUser.sNick]["settings"]["msgs"] = 0
Core.SendPmToNick(curUser.sNick,bot,"All your messages have been deleted!")
return true
end,
["offlinesettings"] = function(curUser)
local border = string.rep("-=",80).."-"
if tOfflineOps[curUser.sNick] == nil then
local msg = "The script is disabled to you, if you are offline, the bot won't login.\r\n"
Core.SendPmToNick(curUser.sNick,bot,"\r\n"..border.."\r\n\t\t\tYOUR CURRENTLY SETTINGS:\r\n"..border.."\r\n"..msg..border)
else
local msg = "The script is enabled to you, if you are offline, a bot will login with your nick.\t(Can modify with the "..sPrefix.."ome command)\r\n"..
"The e-mail adress where the messages will send: "..tOfflineOps[curUser.sNick]["settings"]["emailad"].."\t(Can modify with the "..sPrefix.."oem command)\r\n"..
"The maximum number of messages before e-mail sent: "..tOfflineOps[curUser.sNick]["settings"]["maxmsgs"].."\t(Can modify with the "..sPrefix.."omm command)\r\n"
if tOfflineOps[curUser.sNick]["settings"]["away"] == "off" then
local msg = msg.."You didn't set up your away message yet\t(Can modify with the "..sPrefix.."oa command)\r\n"
Core.SendPmToNick(curUser.sNick,bot,"\r\n"..border.."\r\n\t\t\t\tYOUR CURRENTLY SETTINGS::\r\n"..border.."\r\n"..msg..border)
else
local msg = msg.."Your away message which will send to users: "..tOfflineOps[curUser.sNick]["settings"]["away"].."\t(Can modify with the "..sPrefix.."oa command)\r\n"
Core.SendPmToNick(curUser.sNick,bot,"\r\n"..border.."\r\n\t\t\t\tYOUR CURRENTLY SETTINGS::\r\n"..border.."\r\n"..msg..border)
end
end
return true
end,
["offlinehelp"] = function(curUser)
Core.SendPmToNick(curUser.sNick,bot,"\r\n\t\t\tOffline-messenger script - help\r\n\r\n"..
"All command works in the main, and in private to the bot.\r\n"..
"If the script is enabled to you, while you are offline, a bot will login with your nick, and will recieve the "..
"private messages, then store it in a file. When you log in, the script will inform you, how many messages you got.\r\n"..
"You can read your messages (if there are) with the "..sPrefix.."or command, it will appear here, in private.\r\n"..
"If you read it, easily can delete it with the "..sPrefix.."od command.\r\n"..
"It's possible that bot has the same name, as you have now."..
"Avaible commands are:\r\n"..
sPrefix.."ome <on>/<off> - to enable/disable the script to you\r\n"..
sPrefix.."oem <email@adress.cc> - to set up your e-mail adress where the messages will send\r\n"..
sPrefix.."omm <number> - to set up the the maximum number of messages, which after the e-mail will send\r\n"..
sPrefix.."oa <message>/<off> - to set up your away message, or disable it\r\n"..
sPrefix.."os - to list your currently settings\r\n"..
"All command without parameter will show you more detail.\r\n\r\n"..
"Made by Hungarista - All rights reserved :)")
return true
end,
}
tCmds["ome"] = tCmds["offlineme"] tCmds["oem"] = tCmds["offlineemail"] tCmds["omm"] = tCmds["offmaxmsg"]
tCmds["oa"] = tCmds["offlineaway"] tCmds["or"] = tCmds["offlineread"] tCmds["od"] = tCmds["offlinedel"]
tCmds["os"] = tCmds["offlinesettings"] tCmds["oh"] = tCmds["offlinehelp"]
if tCmds[string.lower(sComd)] then
return tCmds[string.lower(sComd)](curUser)
end
end
end
end
function ToArrival(curUser,sData)
Core.GetUserAllData(curUser)
local _,_, nickto, msg = string.find(sData, "^%$To:%s(%S+)%sFrom:%s%S+%s%$%b<>%s(.+)")
local msg = string.sub(msg,1,-2)
modnickto = string.sub(nickto,1,-2)
if tOfflineOps[modnickto] then
if tOfflineOps[modnickto]["settings"]["away"] ~= "off" then
if tOfflineOps[modnickto]["users"] == nil then tOfflineOps[modnickto]["users"] = {} end
if not tOfflineOps[modnickto]["users"][curUser.sNick] then
tOfflineOps[modnickto]["users"][curUser.sNick] = 1
Core.SendPmToNick(curUser.sNick,nickto,tOfflineOps[modnickto]["settings"]["away"])
end
end
SaveIntoFileMsg(modnickto,curUser,msg)
tOfflineOps[modnickto]["settings"]["msgs"] = tOfflineOps[modnickto]["settings"]["msgs"] + 1
end
if curUser.bOperator then
if nickto == bot then
ChatArrival(curUser,sData)
end
end
end
function OpConnected(curUser)
Core.GetUserAllData(curUser)
if tOfflineOps[curUser.sNick] then
tOfflineOps[curUser.sNick]["users"] = nil
Core.UnregBot(curUser.sNick..string.char(160))
if tOfflineOps[curUser.sNick]["settings"]["msgs"] == "6" then
Core.SendToNick(curUser.sNick,"<"..bot.."> ")
else
Core.SendToNick(curUser.sNick,"<"..bot.."> ")
end
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Turn off$<%[mynick]> !ome off||")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\List settings$<%[mynick]> !os||")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Set e-mail adress$<%[mynick]> !oem %[line:E-mail adress:]||")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Set max messages$<%[mynick]> !omm %[line:Number of messages]||")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Set away message$<%[mynick]> !oa %[line:Message or off:]||")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Some help$<%[mynick]> !oh||")
else
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Turn on$<%[mynick]> !ome on||")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3")
Core.SendToNick(curUser.sNick,"$UserCommand 0 3 "..SetMan.GetString(0).."\\Offline messenger\\Some help$<%[mynick]> !oh||")
end
end
function OpDisconnected(curUser)
Core.GetUserAllData(curUser)
if tOfflineOps[curUser.sNick] ~= nil then
local desc = (curUser.sDescription or "")..(curUser.sTag or "")
local email = curUser.sEmail or ""
Core.RegBot(curUser.sNick..string.char(160),desc,email,true)
end
end
---------------------------------------------------
-- KIEGֹSZֽTױ FGGVֹNYEK --
---------------------------------------------------
function SaveIntoFileMsg(nickto,curUser,msg)
local file = io.open(Core.GetPtokaXPath().."scripts/offlines/"..nickto..".txt", "a")
if (file) then
local DateAndTime = os.date("%Y.%m.%d - %H:%M:%S")
file:write("["..DateAndTime.."] <"..curUser.sNick.."> "..msg.."\r\n")
end
file:close()
if not string.find((tonumber(tOfflineOps[nickto]["settings"]["msgs"]) / tonumber(tOfflineOps[nickto]["settings"]["maxmsgs"])),"%.") and tonumber(tOfflineOps[nickto]["settings"]["msgs"]) ~= 0 then
GenerateEmail(nickto)
end
end
function GenerateEmail(nickto)
local SMTPserver = "mail.axelero.hu"
local auth = false
local MailTo = tOfflineOps[nickto]["settings"]["emailad"]
local MailFrom = "adress@freemail.hu"
local LoginNick = "adress"
local LoginPass = ""
local Location = string.gsub(Core.GetPtokaXPath(),"/","\\")
local msgfile = io.open(Location.."scripts\\header.txt","w+")
msgfile:write("Hi "..nickto.."!\r\n\r\n"..
" On the "..SetMan.GetString(0).." hub you enabled the offline messenger script. While you were offline,"..
" your messages reached the maximum number, what you setted ("..tOfflineOps[nickto]["settings"]["maxmsgs"].."),"..
" so it has been sent to you by e-mail. Your messages have been attached to this e-mail (message.txt). When you"..
" connect to the hub, you can read them again, or delete with the !od command.\r\n\r\n"..
" \t\t\tGreetings from the offline messenger script of the "..SetMan.GetString(0).." hub ;)")
msgfile:close()
os.execute("copy "..Location.."scripts\\offlines\\"..nickto..".txt "..Location.."scripts\\message.txt")
if auth then
local file = io.open("bmail.bat","w+")
file:write("call "..Location.."scripts\\offlines\\blat.exe -install "..SMTPserver.." "..MailFrom.." [-5 [- [- ["..LoginNick.." ["..LoginPass.." ]]]]]\r\n"..
Location.."scripts\\offlines\\blat.exe "..Location.."scripts\\header.txt -to "..MailTo.." -f "..MailFrom.." -u "..LoginNick.." -pw "..LoginPass.." -s \"Offline messenger script "..os.date("%a %d %b %Y @ %H:%M").."\" -server "..SMTPserver.." -debug -log "..Location.."scripts\\offlines\\mail.log -timestamp -attach "..Location.."scripts\\message.txt\r\n"..
"del "..Location.."scripts\\message.txt\r\n"..
"del "..Location.."scripts\\header.txt\r\n"..
"del "..Location.."scripts\\bmail.bat")
file:close()
os.execute(Location.."scripts\\bmail.bat")
else
local f = io.open("bmail.bat", "w+")
f:write("call "..Location.."scripts\\offlines\\blat.exe -install "..SMTPserver.." "..MailFrom.." [-5 [- [- [- [- ]]]]]\r\n"..
Location.."scripts\\offlines\\blat.exe "..Location.."scripts\\header.txt -to "..MailTo.." -f "..MailFrom.." -s \"Offline messenger script "..os.date("%a %d %b %Y @ %H:%M").."\" -server "..SMTPserver.." -debug -log "..Location.."scripts\\offlines\\mail.log -timestamp -attach "..Location.."scripts\\message.txt\r\n"..
"del "..Location.."scripts\\message.txt\r\n"..
"del "..Location.."scripts\\header.txt\r\n"..
"del "..Location.."scripts\\bmail.bat")
f:close()
os.execute(Location.."scripts\\bmail.bat")
end
end
function OnError(errormsg)
Core.SendToOpChat("An error has occured in the offline messenger script: "..errormsg)
end
function Serialize(tTable,sTableName,hFile,sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n");
for key,value in pairs(tTable) do
if (type(value) ~= "function") then
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Serialize(value,sKey,hFile,sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write(sTab.."\t"..sKey.." = "..sValue);
end
hFile:write(",\n");
end
end
hFile:write(sTab.."}");
end
i habe this error
[09:33:06] <?(?][?][aster?Chat]?)?> The email-sender files didn't find in the C:\Archivos de programa\DiXBoT v2.0 Build 2740\scripts\offlines folder! Email sending will fail! Please copy blat files into it!
[09:33:06] <?(?][?][aster?Chat]?)?> An error has occured in the offline messenger script: offline msg script.lua:31: attempt to index local 'file' (a nil value)
[09:33:12] <?(?][?][aster?Chat]?)?> The email-sender files didn't find in the C:\Archivos de programa\DiXBoT v2.0 Build 2740\scripts\offlines folder! Email sending will fail! Please copy blat files into it!
[09:33:12] <?(?][?][aster?Chat]?)?> An error has occured in the offline messenger script: offline msg script.lua:31: attempt to index local 'file' (a nil value)
This is not a part of DiXBoT.
The error posted by atonal is from the script above..
if not file then
Core.SendToOpChat("The email-sender files didn't find in the "..string.gsub(Core.GetPtokaXPath(),"/","\\").."scripts\\offlines folder! Email sending will fail! Please copy blat files into it!")
end
/Snooze
Sirry i make mistake = atonal25
lol its not away msg its offline bot if u dont see
u can convert him plz?
??
Quote from: TrIp-iN-SuN on 17 April, 2008, 16:07:38
lol its not away msg its offline bot if u dont see
It still looks like this is what you need:
AwayMsg 1.0 LUA 5.1x [Strict] [API 2]
By Mutor 04/16/08
An offline message script for the new API
- PM's user on connect with saved message
- Command permission per profile
- Provides context menu command
- Messages saved to file for hub/script restarts
- Pruning feature with option to disable
- Option for users to toggle offline messages on/off