mm for all users including offline
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

mm for all users including offline

Started by bsalsa, 27 January, 2004, 15:35:12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bsalsa

i need a script for all users include offline user with 2 major function :1 MM to all user (including offline)
2 a spesific massege for a spesific off line user.
thanks for supporting

pHaTTy

QuoteOriginally posted by bsalsa
i need a script for all users include offline user with 2 major function :1 MM to all user (including offline)
2 a spesific massege for a spesific off line user.
thanks for supporting

so i presume you mean only registered users offline?
Resistance is futile!

bsalsa

yes
1 function is :
i want to send a massege to a registered user that is currently offline,
and 1 more function: to massmassage all registered including  users that are offline
thanks

xjr13sp

bsalsa said:
Quotei want to send a massege to a registered user that is currently offline
I think it is what you are looking for.....

sBotName
	
"MyOwnBot"


function Main() 
   --
frmHub:RegBot(sBotName
end 

function tokenize (inString,token
   
_WORDS = {} 
   
local matcher "([^?"..token.."]+)" 
   
gsub(inStringmatcher, function (wtinsert(_WORDS,wend
   return 
_WORDS 
end 

function Get2Args(data)
   
s,e,whoTo,from,cmd,arg,arg2strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
   return 
arg,arg2
end 

function DataArrival(userdata)
   if(
strsub(data11) == "<"then
      s
,e,msg strfind(data"%b<>%s+(.+)")
         if (
strsub(msg15) == "!memo"then 
            SendToNick
(user.sName"<"..sBotName.."> You must send this command in PM to "..sBotName)
         
end

   
elseif(strsub(data14) == "$To:"then 
      data
=strsub(data,1,strlen(data)-1
      
s,e,whoTo strfind(data,"$To:%s+(%S+)"

         if (
whoTo == sBotNamethen 
            s
,e,whoTo,from,cmd strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)"

            if (
cmd=="!memo"then 
               arg
,arg2 Get2Args(data)
               
local handle=openfile("messages/"..arg..".msg","a"
               
write(handle,""..user.sName.." : "..arg2.."?")
               
mess="Message sent to "
               
SendPmToNick(fromsBotName" "..mess.." "..arg.." : "..arg2)
               
closefile(handle)
            
end 
         end 
   end 
end 

function NewUserConnected(curUser
   
handle2=openfile("messages/"..curUser.sName..".msg","r")
   
sMsgText="Message from"
      
if (handle2==nilthen 
         
else 
            
line read(handle2,"*a"
            
line=strsub(line,1,strlen(line)-1
            
linearray=tokenize(line,"?"
            for 
i=1,linearray.do
            
curUser:SendPM(sBotName,sMsgText.." "..linearray[i])
         
end 

      closefile
(handle2
      
end 
   a
,b=remove("messages/"..curUser.sName..".msg"
end 

OpConnected 
NewUserConnected


This script sends a message to a user which is not online. The user don't have to be a REG one...

bsalsa

sory but not working
i saved the script s awaybot and by your instructions i need to send a pm to the bot but i it does not show itself.
what did i do wrong?
thanks

kepp

sBotName    = "MyOwnBot"


function Main() 
   frmHub:RegBot(sBotName) 
end 

function tokenize (inString,token) 
   _WORDS = {} 
   local matcher = "([^?"..token.."]+)" 
   gsub(inString, matcher, function (w) tinsert(_WORDS,w) end) 
   return _WORDS 
end 

function Get2Args(data)
   s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
   return arg,arg2
end 

function DataArrival(user, data)
   if(strsub(data, 1, 1) == "<") then
      s,e,msg = strfind(data, "%b<>%s+(.+)")
         if (strsub(msg, 1, 5) == "!memo") then 
            SendToNick(user.sName, "<"..sBotName.."> You must send this command in PM to "..sBotName)
         end

   elseif(strsub(data, 1, 4) == "$To:") then 
      data=strsub(data,1,strlen(data)-1) 
      s,e,whoTo = strfind(data,"$To:%s+(%S+)") 

         if (whoTo == sBotName) then 
            s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)") 

            if (cmd=="!memo") then 
               arg,arg2 = Get2Args(data)
               local handle=openfile("messages/"..arg..".msg","a") 
               write(handle,""..user.sName.." : "..arg2.."?")
               mess="Message sent to "
               SendPmToNick(from, sBotName, " "..mess.." "..arg.." : "..arg2)
               closefile(handle)
            end 
         end 
   end 
end 

function NewUserConnected(curUser) 
   handle2=openfile("messages/"..curUser.sName..".msg","r")
   sMsgText="Message from"
      if (handle2==nil) then 
         else 
            line = read(handle2,"*a") 
            line=strsub(line,1,strlen(line)-1) 
            linearray=tokenize(line,"?") 
            for i=1,linearray.n do
            curUser:SendPM(sBotName,sMsgText.." "..linearray[i])
         end 

      closefile(handle2) 
      end 
   a,b=remove("messages/"..curUser.sName..".msg") 
end 

OpConnected = NewUserConnected
Guarding    

xjr13sp

LOL
sorry..... the RegBot was not valid in the function Main ( --frmHub:RegBot(sBotName) )

bsalsa

now its better ( it has no errors + its uploaded
but it do not do its job  ( or maybe i do mistake in the format of the command ..
please be kind to complete the task
regards

kepp

Guarding    

bsalsa

it does not send an off line message

xjr13sp

Sorry.... the command line is !memo . Please don't type the <> characters  :]

bsalsa

i am sorry but  it stil dont work

tezlo

!msg
messages = dofile("messages.dat") or {}

function NewUserConnected(user)
	local tmp = messages[user.sName]
	if tmp then
		local n = getn(tmp)
		user:SendData(">> "..n.." messages for you..")
		for i = 1, getn(tmp) do
			user:SendData(">> "..tmp[i][1]..": "..tmp[i][2])
		end
		messages[user.sName] = nil
		savemessages()
	end
end

OpConnected = NewUserConnected

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" then
		local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s?(.*)|$")
		if s then
			cmd = strlower(cmd)
			if cmd == "msg" then
				local s, e, nick, msg = strfind(args, "(%S+)%s?(.*)")
				if s then
					local tmp = GetItemByName(nick)
					if tmp then
						tmp:SendData(">> "..user.sName..": "..msg)
						user:SendData(">> "..nick.." is online he/she got your message")
					else
						messages[nick] = messages[nick] or {}
						tinsert(messages[nick], { user.sName, msg })
						user:SendData(">> message saved")
						savemessages()
					end
				else
					user:SendData(">> syntax: !msg  ")
				end; return 1
			end
		end
	end
end

function savemessages()
	local f = openfile("messages.dat", "w+")
	assert(f, "messages.dat")
	write(f, "return {\n")
	for nick, table in messages do
		write(f, "\t"..format("[%q]", nick).." = {\n")
		for i = 1, getn(table) do write(f, "\t\t{ "..format("%q", table[i][1])..", "..format("%q", table[i][2]).."},\n") end
		write(f, "\t},\n")
	end write(f, "}") closefile(f)
end

bsalsa

even nre script dont work
i registereg the function as

sBotName    = "offline"


function Main()
   frmHub:RegBot(sBotName)
end

 icreated a messages.dat file (empty) in the script folder
i used command format :!msg   to the offlise script (as a pm)
and no offline massege appiers
and no online massege also :)   and by the way i need it to be as a pm.
i see it beucome a chalenge...
thanks for all the help

xjr13sp

Quoteit does not send an off line message
Did you create a subfolder "messages" (...Ptokax\scripts\messages)?
Test with it... it works fine for me.

bsalsa

i created :scripts/messages
and it dont work
what do i do wrong?

xjr13sp

#16
I'm confused.... it works well on my PC  ?(

Try this one, it's the same script but it's the original one (maybe I have made an error when cpoying the first one...)

-------------------------------
-- 
D?claration des variables --
-------------------------------
botname
	
	
"-=Ninie=-"
sBotName
	
"Ninie"
-----------------------------------
-- 
Fin d?claration des variables --
-----------------------------------

function 
Main() 
   
frmHub:RegBot(botname
end 

function tokenize (inString,token
   
_WORDS = {} 
   
local matcher "([^?"..token.."]+)" 
   
gsub(inStringmatcher, function (wtinsert(_WORDS,wend
   return 
_WORDS 
end 

function Get2Args(data)
   
s,e,whoTo,from,cmd,arg,arg2strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
   return 
arg,arg2
end 

function DataArrival(userdata)
   if(
strsub(data11) == "<"then
      s
,e,msg strfind(data"%b<>%s+(.+)")
         if (
strsub(msg15) == "!memo"then 
            SendToNick
(user.sName"<"..sBotName.."> Cette commande est ? envoyer en PV ? ninie. A moins que tu veuilles que tout le monde voit ton message perso ??? Rassures-toi, personne n'a vu celui-ci ;-))")
         
end

   
elseif(strsub(data14) == "$To:"then 
      data
=strsub(data,1,strlen(data)-1
      
s,e,whoTo strfind(data,"$To:%s+(%S+)"

         if (
whoTo == botnamethen 
            s
,e,whoTo,from,cmd strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)"

            if (
cmd=="!memo"then 
               arg
,arg2 Get2Args(data)
               
local handle=openfile("messages/"..arg..".msg","a"
               
write(handle,""..user.sName.." : "..arg2.."?")
               
mess="Message laiss? pour "
               
SendPmToNick(frombotname" "..mess.." "..arg.." : "..arg2)
               
closefile(handle)
            
end 
         end 
   end 
end 

function NewUserConnected(curUser
   
handle2=openfile("messages/"..curUser.sName..".msg","r")
   
sMsgText="Message de la part de"
      
if (handle2==nilthen 
         
else 
            
line read(handle2,"*a"
            
line=strsub(line,1,strlen(line)-1
            
linearray=tokenize(line,"?"
            for 
i=1,linearray.do
            
curUser:SendPM(botname,sMsgText.." "..linearray[i])
            --
SendPmToNick(frombotname,"Le user suivant a lu le message que tu lui avait laiss? ==> "..linearray[i])
         
end 

      closefile
(handle2
      
end 
   a
,b=remove("messages/"..curUser.sName..".msg"
end 

function OpConnected(curUser
   
handle2=openfile("messages/"..curUser.sName..".msg","r"
   
sMsgText="Message de la part de"
      
if (handle2==nilthen 
         
else 
            
line read(handle2,"*a"
            
line=strsub(line,1,strlen(line)-1
            
linearray=tokenize(line,"?"
            for 
i=1,linearray.do
            
curUser:SendPM(botname,sMsgText.." "..linearray[i])
            --
SendPmToNick(frombotname,"Le user suivant a lu le message que tu lui avait laiss? ==> "..linearray[i])
         
end 

      closefile
(handle2
   
end 
   a
,b=remove("messages/"..curUser.sName..".msg"
end


You still have to create the "messages" subfolder. and the command is still !memo  and in PM from the Bot (botname)
And check if you have some errors in ptokax, and copy them here please...

bsalsa

syntax errors in the last 1

tezlo

you dont need to reg the bot and you dont need to make an empty file
the command doesnt show in mainchat so theres no need to write it in pm
youre doing your best to make it a challenge for yourself :)

bsalsa

about that you are totaly right!!!
and i am sorry !
but all works for pnline user  but not for offline user
when an offline user connects he get no messaglook on whar i got :

[17:59:01] >> [IL]Eran is online he/she got your message
[17:59:28] *** Parts: [IL]Eran
[17:59:58] >> message saved


all is ok but when this user connects he do not get the messege. by the way it do not delete the old messeges.(and if it possible i want the massege as a pm)


and i used your script :



messages = dofile("messages.dat") or {}

function NewUserConnected(user)
   local tmp = messages[user.sName]
   if tmp then
      local n = getn(tmp)
      user:SendData(">> "..n.." messages for you..")
      for i = 1, getn(tmp) do
         user:SendData(">> "..tmp[1]..": "..tmp[2])
      end
      messages[user.sName] = nil
      savemessages()
   end
end

OpConnected = NewUserConnected

function DataArrival(user, data)
   if strsub(data, 1, 1) == "<" then
      local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s?(.*)|$")
      if s then
         cmd = strlower(cmd)
         if cmd == "msg" then
            local s, e, nick, msg = strfind(args, "(%S+)%s?(.*)")
            if s then
               local tmp = GetItemByName(nick)
               if tmp then
                  tmp:SendData(">> "..user.sName..": "..msg)
                  user:SendData(">> "..nick.." is online he/she got your message")
               else
                  messages[nick] = messages[nick] or {}
                  tinsert(messages[nick], { user.sName, msg })
                  user:SendData(">> message saved")
                  savemessages()
               end
            else
               user:SendData(">> syntax: !msg ")
            end; return 1
         end
      end
   end
end

function savemessages()
   local f = openfile("messages.dat", "w+")
   assert(f, "messages.dat")
   write(f, "return {\n")
   for nick, table in messages do
      write(f, "\t"..format("[%q]", nick).." = {\n")
      for i = 1, getn(table) do write(f, "\t\t{ "..format("%q", table[1])..", "..format("%q", table[2]).."},\n") end
      write(f, "\t},\n")
   end write(f, "}") closefile(f)
end

bsalsa

My typing ... i am sory again.
now i will write in english :)
"but all works for online user but not for offline user .
when an offline user connects ,he get no message.
look on whar i got : "

xjr13sp

?(
I don't know what to say... it works very well for me.
Are you using dc++ or like? Maybe your PMs are listen in the main chat? Because this script sends PM in a PM window by default....
Check if you have a ".msg " file created in your "messages " folder. This file must have the name of the user (username  .msg) and it's a txt file format (you can edit it into UltraEdit).
And check if you have error messages in your Ptokax Debug Window, and if yes, please paste them here.

snek_one

excuse me, a bit off topic maybe..

but why are you using php tags around the script?
just for syntax high-lighting or are you actually running this stuff on a webserver?

[ sorry: major noob to this.. ]

bsalsa

there is no ptokax errors but on the other hand there is no file like : usernsme.msg and there is n folder  in the name of :messages
should i creat 1 ? where ?
thanks

xjr13sp

Quoteshould i creat 1 ? where ?
Yes you have to create a new subfolder called "messages" in the Script folder (...\Ptokax\Scripts\messages)

SMF spam blocked by CleanTalk