PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: dragos_sto on 22 September, 2006, 01:48:11

Title: offline messege
Post by: dragos_sto on 22 September, 2006, 01:48:11
it a old script convert to lua 5.1


P.S. it working , but can be make improvements
Title: Re: offline messege
Post by: zvamp on 27 September, 2006, 17:42:59
Really nice script!!

Please translate the sentences into english =)
Title: Re: offline messege
Post by: dragos_sto on 28 September, 2006, 12:19:01
sorry i neglected
i whil translate and modify the first post :D
Title: Re: offline messege
Post by: Zeel on 11 October, 2006, 21:07:06
Can you post the full script here on the thread?  I download it from you but when i open it, it is all scrambled up and not organized at all.  Thanks!
Title: Re: offline messege
Post by: dodgeviper on 25 November, 2006, 08:55:29
hey what language is it???translate this man
Title: Re: offline messege
Post by: Josecar on 11 January, 2007, 21:47:14
The messages are in romanian.
The script is good, simple and effective.
The messages are very simple. I can translate that if there is somebody interested yet.

Greetings.
Josecar
Title: Re: offline messege
Post by: dragos_sto on 17 May, 2007, 08:59:32
Quote from: Zeel on 11 October, 2006, 21:07:06
Can you post the full script here on the thread?  I download it from you but when i open it, it is all scrambled up and not organized at all.  Thanks!

i use to edit lua files
whit blua or notepad++
when open whit notepad from microsoft you have right i look to be scrambled but it not :)

sorry for answer soo late
modify first post and add english version and i whil post he script hear

Code (lua) Select
-- offlinemsg.lua, created by amutex 11.01.2003
-- thx to nathanos for the fine pm-parsing
-- bits and pieces added and deleted by bolamix over time, kudos to all scripters who helped!
-- attempted conversion to lua5 by bolamix Feb. 27 2005
-- successful conversion to lua5 by Jelf March 9 2005
-- accept command in main and ,or PM by dragos_sto september 2006
-- usage: send a PM to the bot with <command> <username> <message>
-- or main chat <command> <username> <message>
-- for englise uncomment the line whit --en in tale and comment the file whit --ro

path = "messages" -- name of the folder where the message files will be stored
ext = ".msg" -- extension for the message files
command = "+note"
tipe = 2 -- 0 accept command in main ; 1 accept command in PM ; 2 accept command in both
botname = frmHub:GetHubBotName() -- or use whatever botname you want then uncomment the following 3 lines
--function main
-- frmHub:RegBot( botname )#Offline_Message
--end

os.execute("mkdir ".."\""..string.gsub(path, "/", "\\").."\"")

function ToArrival(user, data)
if (tipe == 1) or (tipe == 2) then
local _,_,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == botname) then
local _,_,_,_,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (string.lower(cmd) == string.lower(command)) then
local _,_,_,_,_,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.*)")
if arg then
arg = string.lower(arg)
if arg2 == "" or arg2 == nil then
arg2 = "Te saluta "..arg..", dar a uitat sa scrie un mesaj" --ro
-- arg2 = "It Say Hy "..arg..", but forget to writw the message" --en
end
if GetItemByName(arg) == nil then
local f,_ = io.open(path.."/"..arg..ext,"a+")
if f then
f:write(""..user.sName.." tia trimis acest mesaj la ora "..GetDate().." in data de "..GetTime().." : "..arg2.." bkspck") --ro
-- f:write(""..user.sName.." It send you this message at "..GetDate().." hour and in this date "..GetTime().." : "..arg2.." bkspck") --en
user:SendPM(botname,"Mesaj Stocat."..arg2.." Va fi trimis lui "..arg.." cu prima ocazie cand va fi vazut pe aici.") --ro
-- user:SendPM(botname,"Message save."..arg2.." Whil be sent to "..arg.." first time when join the hub.") --en
f:close()
end
else
user:SendPM(botname," Mesajul Nu a fost Trimis. Userul "..arg.." este online.") --ro
-- user:SendPM(botname," The message whos not sent. User "..arg.." it online.") --en
end
else
user:SendPM(botname,"Ai uitat sa specifici un Nick si Mesaj") --ro
-- user:SendPM(botname,"You forget to write the nick and the message") --en
end
return 1
end
end
end
end

function ChatArrival(user, data)
if (tipe == 0) or (tipe == 2) then
if (string.sub(data,1,1) == "<") then
local data1=string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data1,"%b<>%s+(%S+)")
if (string.lower(cmd) == string.lower(command)) then
local _,_,_,arg,arg2 = string.find(data1,"%b<>%s+(%S+)%s+(%S+)%s+(.*)")
if arg then
arg = string.lower(arg)
if arg2 == "" or arg2 == nil then
arg2 = "Te salut "..arg..", dar am uitat sa scrie un mesaj" --ro
-- arg2 = "It Say Hy "..arg..", but forget to writw the message" --en
end
if GetItemByName(arg) == nil then
local f,e = io.open(path.."/"..arg..ext,"a+")
if f then
f:write(""..user.sName.." tia trimis acest mesaj in data de "..GetDate().." la ora "..GetTime().." : "..arg2.." bkspck") --ro
-- f:write(""..user.sName.." It send you this message at "..GetDate().." hour and in this date "..GetTime().." : "..arg2.." bkspck") --en
SendToNick(user.sName, "<"..botname.."> Mesaj Stocat. "..arg2.." va fi trimis lui "..arg.." cu prima ocazie cand va fi vazut pe aici.") --ro
-- SendToNick(user.sName, "<"..botname.."> Message save."..arg2.." Whil be sent to "..arg.." first time when join the hub.") --en
f:close()
end
else
SendToNick(user.sName, "<"..botname.."> Mesajul Nu a fost Trimis. Userul "..arg.." este online.") --ro
-- SendToNick(user.sName, "<"..botname.."> The message whos not sent. User "..arg.." it online.") --en
end
else
SendToNick(user.sName, "<"..botname.."> Ai uitat sa specifici un Nick si Mesaj") --ro
-- SendToNick(user.sName, "<"..botname.."> You forget to write the nick and the message") --en
end
return 1
end
end
end
end

function NewUserConnected(curUser)
local CusNa = string.lower(curUser.sName)
local handle = io.open(path.."/"..CusNa ..ext,"r")
if (handle ~= nil) then
local line = handle:read()
line = string.gsub(line, "bkspck", "\r\n")
SendToNick(curUser.sName, "<"..botname.."> Aveti mesaje offline :\r\n"..line) --ro
-- SendToNick(curUser.sName, "<"..botname.."> You have offline message :\r\n"..line) --en
curUser:SendPM(botname, "Aveti mesaje offline :\r\n"..line) --ro
-- curUser:SendPM(botname, "You have offline message :\r\n"..line) --en
handle:close()
os.remove(path.."/"..CusNa..ext)
else
end
end

OpConnected = NewUserConnected

function GetTime()
local Time = os.date("%H")..":"..os.date("%M")
return Time
end

function GetDate()
local Date = os.date("%d").." - "..os.date("%B").." - "..os.date("%Y")
return Date
end