Request Bot modifications
 

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

Request Bot modifications

Started by Whipshock, 11 November, 2003, 22:56:26

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Whipshock

hello i have a request script here... and i would like

- to have it private message newly connecting users with the LAST 5 requests that were added to the list

- to know how i can change the script to accept commands sent to the main chat, rather than only private message

if someone could help me rework the code and outline what i need to change i would be extremely grateful!
thanks in advance :)

--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "RequestBot?"
bot_email = "" 
bot_speed = "Who knows?" 
bot_descr = "Request Bot" 
bot_share_size = 0
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email


function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.. 
"$"..bot_share_size.."$"

end

function NewUserConnected(curUser) 
curUser:SendData( my_info_string )
end 

function OpConnected(curUser) 
curUser:SendData( my_info_string ) 
end

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

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

function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="!newrequest") then
arg= GetArgs(data)
SendToAll("***New Request Available: "..arg.." (submitted by: "..user.sName..")")
local handle=openfile("request.dat","a")
write(handle,"("..user.sName..") added :"..arg.."?")
user:SendPM(botname,"New request has been added!")
closefile(handle)
end

if (cmd=="!view") then
handle2=openfile("request.dat","r")
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
user:SendPM(botname,linearray[i])
end
closefile(handle2)
end

end
end
end
end


kepp

--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "RequestBot?"
bot_email = "" 
bot_speed = "Who knows?" 
bot_descr = "Request Bot" 
bot_share_size = 0
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email


function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.. 
"$"..bot_share_size.."$"

end

function NewUserConnected(curUser) 
curUser:SendData( my_info_string )
end 

function OpConnected(curUser) 
curUser:SendData( my_info_string ) 
end

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

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

function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") or strsub(data,1,1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="!newrequest") then
arg= GetArgs(data)
SendToAll("***New Request Available: "..arg.." (submitted by: "..user.sName..")")
local handle=openfile("request.dat","a")
write(handle,"("..user.sName..") added :"..arg.."?")
user:SendPM(botname,"New request has been added!")
closefile(handle)
end

elseif (cmd=="!view") then
handle2=openfile("request.dat","r")
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
user:SendPM(botname,linearray[i])
end
closefile(handle2)
end

end
end
end
end
Guarding    

Whipshock

kepp >> um.. did you not change anything lol or can i just not see it?

Whipshock

can anyone help me with what im trying to do here?

accept triggers from main chat and/or PM's
and show the last 5 requests only, rather than all ?

kepp

#4
if strsub(data,1,4) == "$To:") or strsub(data,1,1) == "<")

I don't know if it works but you should be able to send it in mainchat now aswell
Guarding    

plop

QuoteOriginally posted by Whipshock
can anyone help me with what im trying to do here?

accept triggers from main chat and/or PM's
and show the last 5 requests only, rather than all ?
try this 1, haven't tested it so i hope it works.
should do all you requested.
--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//added support for commands send in mainchat (hope it works, not tested) by plop
--//should show the last 5 requests on entry (yes not tested) by plop
--//fixed error if no arguments are given on !newrequest by plop
--//Version 3.1

botname = "RequestBot?"
bot_email = "" 
bot_speed = "Who knows?" 
bot_descr = "Request Bot" 
bot_share_size = 0
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email


function Main()
   frmHub:RegBot(botname)
   my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.. "$"..bot_share_size.."$"
end

function NewUserConnected(curUser) 
   curUser:SendData( my_info_string )
   Welcome(curUser)
end 

function OpConnected(curUser) 
   curUser:SendData( my_info_string ) 
   Welcome(curUser)
end

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

function DataArrival(user, data)
   if(strsub(data, 1, 4) == "$To:") then
      data=strsub(data,1,strlen(data)-1)
      s,e,whoTo = strfind(data,"$To:%s+(%S+)")
      if (whoTo == botname) then
         s,e,data = strfind(data, "$(%b<>.+)") -- converting PM data 2 be the same as mainchat 
         Commands(curUser, data)
      end
   elseif strsub(data,1,1) == "<" then
      data=strsub(data,1,strlen(data)-1)
      Commands(curUser, data)
   end
end

function Commands(curUser, data)
   s,e,cmd = strfind(data,"%b<>%s+(%S+)")
   if (cmd=="!newrequest") then
      s,e,arg = strfind(data, "%b<>%s+%S+%s+(.+)")
      if arg ~= nil then
         SendToAll("***New Request Available: "..arg.." (submitted by: "..curUser.sName..")")
         local handle=openfile("request.dat","a")
         write(handle,"("..curUser.sName..") added :"..arg.."?")
         curUser:SendPM(botname,"New request has been added!")
         closefile(handle)
      else
         curUser:SendPM(botname,"How can i add a new request if you don't tell me what you want?")
      end
   elseif (cmd=="!view") then
      handle2=openfile("request.dat","r")
      if handle2~=nil then
         line = read(handle2,"*a")
         line=strsub(line,1,strlen(line)-1)
         linearray=tokenize(line,"?")
         for i=1,linearray.n do
            curUser:SendPM(botname,linearray[i])
         end
         closefile(handle2)
      end
   end
end

function Welcome(curUser)
   handle2=openfile("request.dat","r")
   if handle2~=nil then
      line = read(handle2,"*a")
      line=strsub(line,1,strlen(line)-1)
      linearray=tokenize(line,"?")
      for i=(linearray.n-5),linearray.n do
         curUser:SendPM(botname,linearray[i])
      end
      closefile(handle2)
   end
end
you were close kepp, just pm lines are different then mainchat.
what i done is alter the pm data 2 be the same as mainchat (that line has a comment).
had 2 change the rest a little bit so i could use the main chat way.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

kepp

Oh i see!! :)

I learn something new everyday!

I think it's time for tables :)

By the way plop, if you're not to busy, can you check out
My "Project" when im about done?
Just to comment my misstakes
Guarding    

plop

QuoteOriginally posted by kepp
Oh i see!! :)
I learn something new everyday!
I think it's time for tables :)
By the way plop, if you're not to busy, can you check out
My "Project" when im about done?
Just to comment my misstakes
done + a new excersize.
not tables, something else 1st.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

DarkElf

Hi, i have this RequestBoard....it run with 0.3.3.0 but he has a problem for !view command..


--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname "[?]YuNa?"
bot_email "elfo0scuro@hotmail.com" 
bot_speed "GanjaLan(ThC)" 
bot_descr "Type #request In PM To Me." 
bot_share_size 420.01 1024 *1024 *1024
my_info_string 
"$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar).."$"..bot_email
TimeSpanInMinutes 
120 --//You May Change This

function Main()
frmHub:RegBot(botname)
my_info_string "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar).."$"..bot_email.. 
"$"..bot_share_size.."$"
SetTimer(TimeSpanInMinutes*33000
StartTimer() 
end

function NewUserConnected(curUser
curUser:SendDatamy_info_string 
end 

function OpConnected(curUser
curUser:SendDatamy_info_string 
end

function OnTimer() 

--
//Note that a "|" denotes a break in the line

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HI THERE!!!!, I'm The Request_Board.")
SendToAll("    Do You Need A Specific File???")
SendToAll("    REQUEST IT!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  To Request A File, Simply Send #request As A Private Message")
SendToAll("  To [?]YuNa?.  Please Be As Specific As You Can.")
SendToAll("  Remember To Check Back To See If Someone Has Obtained Your File.")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

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

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

function DataArrival(userdata)
if(
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=="#request"then
user
:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname,"    This is the Request_Board!")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Type #request To View This Help Menu.")
user:SendPM(botname," Type !request <file> To Request A File.")
user:SendPM(botname," Type !view To View The Posted Requests/Updates.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Please Be As Specific As You Can.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
end

if (cmd=="!request"then
SendToAll
("***New Request Added***")
argGetArgs(data)
local handle=openfile("request.dat","a")
write(handle,"("..user.sName..") requested :"..arg.."?")
user:SendPM(botname,"Request entry saved ....")
closefile(handle)
end

if (cmd=="!view"then
handle2
=openfile("request.dat","r")
if (
handle2==nilthen
else
line read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for 
i=1,linearray.do
user:SendPM(botname,linearray[i])
end
closefile
(handle2)
end

end
end
end
end


I have a blank request.dat file, but ptokax say:

Syntax error: `for' limit must be a number
stack traceback:
   1:  function `DataArrival' at line 93 [file `....dbg\0.330.b15.18.dbg\scripts\RequestBot3.0.lua']
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

DarkElf

Anyone can help me??? :(
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

kepp

Did you make that file yourself?
Because the script will make one for you...
Guarding    

Janyn

hi
#11
DarkElf

that works fine i PtokaX DC Hub 0.3.2.4 IceCube III Fix3

// Janyn   :))

DarkElf

Kepp:

--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0


I have only canghed the name,e-mail etc..

Janyn:
LOL!!! i have 0.3.3.0 beta
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

kepp

May i suggest that you use elseif?
Guarding    

kepp

--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "[?]YuNa?"
bot_email = "elfo0scuro@hotmail.com" 
bot_speed = "GanjaLan(ThC)" 
bot_descr = "Type #request In PM To Me." 
bot_share_size = 420.01 * 1024 *1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email
TimeSpanInMinutes = 120 --//You May Change This

function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.. 
"$"..bot_share_size.."$"
SetTimer(TimeSpanInMinutes*33000) 
StartTimer() 
end

function NewUserConnected(curUser) 
curUser:SendData( my_info_string ) 
end 

function OpConnected(curUser) 
curUser:SendData( my_info_string ) 
end

function OnTimer() 

--//Note that a "|" denotes a break in the line

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HI THERE!!!!, I'm The Request_Board.")
SendToAll("    Do You Need A Specific File???")
SendToAll("    REQUEST IT!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  To Request A File, Simply Send #request As A Private Message")
SendToAll("  To [?]YuNa?.  Please Be As Specific As You Can.")
SendToAll("  Remember To Check Back To See If Someone Has Obtained Your File.")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

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

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

function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="#request") then
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname,"    This is the Request_Board!")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Type #request To View This Help Menu.")
user:SendPM(botname," Type !request  To Request A File.")
user:SendPM(botname," Type !view To View The Posted Requests/Updates.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Please Be As Specific As You Can.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")


elseif (cmd=="!request") then
SendToAll("***New Request Added***")
arg= GetArgs(data)
local handle=openfile("request.dat","a")
write(handle,"("..user.sName..") requested :"..arg.."?")
user:SendPM(botname,"Request entry saved ....")
closefile(handle)


elseif (cmd=="!view") then
handle2=openfile("request.dat","r")
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
user:SendPM(botname,linearray[i])
end
closefile(handle2)
end

end
end
end
end
Guarding    

DarkElf

no, i have this bot in my hd, i have only change the name,e-mail,desc,tag and share
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

Whipshock

ahh thanks guys you are soo helpful!

SMF spam blocked by CleanTalk