PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: QuikThinker on 07 June, 2004, 20:29:34

Title: Need a quik short script
Post by: QuikThinker on 07 June, 2004, 20:29:34
Hey guys,
Need a quik script so when sum1 types +help it triggers the bot 2 say "-------> !userhelp"

Thanx in advance,
Quik.
Title:
Post by: Herodes on 07 June, 2004, 22:37:51
Sorry Double Posting by mistake .. :(
Title:
Post by: Herodes on 07 June, 2004, 22:40:28
--- Quick Short UserHelp not Help
--- Quick request from QuickThinker
--- b Herodes
botname = "Please-Use"

function DataArrival(user, sdata) --- On Data Arrival
if ( strfind(sdata, 1, 1) == "<" ) then --- if in Main Chat
local sdata = strsub(sdata, 1, (strlen(sdata)-1)) --- Take out the pipe  ( pipe is the character : " | "  )
local s,e,cmd = strsub(sdata, "%b<>%s+(%S+)") --- find the message/cmd
if (cmd ~= nil and cmd == "+help") then   --- if the message isn't nil and the message is our cmd then
user:SendData(botname, "-u-s-e--c-m-d-> !userhelp") --- Send (private) msg to the Main Chat of the user  
end --- end the find if cmd part ...
end --- end the if main chat msg part ...
end --- end the Data Arrivals function ...

I think it should be done like this ... although I am still learning
...  and mistake is very probable as DataArrival is a critical part of every script
.... and strsub, strfind etc. are very delicate ...
So, if someone wants to correct ...  By All Means .... :D
Title:
Post by: QuikThinker on 07 June, 2004, 23:40:01
Just tested it mate & it dun seem 2 work :(
Title:
Post by: VidFamne on 07 June, 2004, 23:48:26
Think its a typo there; should be strfind instead of strsub
in there;local s,e,cmd = strfind(sdata, "%b<>%s+(%S+)")
Title:
Post by: QuikThinker on 08 June, 2004, 00:03:06
lol nope, that dun work either! And if im right, this script will PM the user?
All I need is just a VERY basic triggerbot kinda thing that just says "-----> !userhelp" in main chat window when sum1 types "+help"

Sum1 must be able 2 do this? lol

Quik.
Title:
Post by: G?M on 08 June, 2004, 00:42:56
QuoteOriginally posted by QuikThinker
lol nope, that dun work either! And if im right, this script will PM the user?
All I need is just a VERY basic triggerbot kinda thing that just says "-----> !userhelp" in main chat window when sum1 types "+help"

Sum1 must be able 2 do this? lol

Quik.

user:SendData does NOT send a PM to whoever types it, it will show up in the MAIN chat window, but only the person who typed +help will be able to see the message.

If you want it to be seen by everyone replace user:SendData with SendToAll
Title:
Post by: QuikThinker on 08 June, 2004, 00:45:25
OK thats cool but it STILL doesnt work :s
Title:
Post by: G?M on 08 June, 2004, 01:08:47
Bot = "whateveryouwant"
prefix = "+"

function Main()
--frmHub:RegBot(Bot) remove the --'s to make the bot show in main
end


function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if cmd == prefix.."help" then
            -- this will be sent to ALL users change it to user:SendData to send it
            -- privately in MAIN chat
SendToAll(Bot,"Please type !userhelp "..user.sName.." for the help menu")
end
end
end

try this one ;)
Title:
Post by: VidFamne on 08 June, 2004, 01:24:43
Sorry for deleted my previous post but the code was not
function properly. Hope this will;function DataArrival(curUser,sData)
if strsub(sData,strlen(curUser.sName)+4,strlen(curUser.sName)+9)=="+help|" then
SendToAll("HelpBot","Please use the command --> !userhelp")
end
end
Title:
Post by: QuikThinker on 08 June, 2004, 01:54:00
Gismo top man! Absolutely perfect!
Thanx 4 tryin also Herodes, appreciated.

Quik.
Title:
Post by: Herodes on 08 June, 2004, 02:20:41
Just for comparison,
And for all apart the Pm part is the same ...
Always with the explanatory part ..
It's is helpfull to know what is going on inside the small scripts ...
giving clues to ppl always help ...
I just  looked at the progression of the thread .. I was coming to post mine...
so there it is .. (basically the same DataArrival and cmd picking but no prefix var in mine) ...
--- Quick Short UserHelp not Help
--- Quick request from QuickThinker
--- b Herodes
botname = "Please-Use"

function Main() ------------------------------if PMing a user then  its is neccessary to register  
frmHub:UnregBot(botname)-------------- the Bot because I 'm prety sure that
frmHub:RegBot(botname)----------------- most of the users have set DC++ not to receive pms from offline user. . :)
end--------------------------------------------- end Main() function

function DataArrival(user, sdata)
if ( strsub(sdata, 1, 1) == "<" ) then ------------------------------------------------------------------------1 When data arrives in Main Chat...
sdata = strsub(sdata, 1, (strlen(sdata)-1)) ------------------------------------------------------2 remove their last character (pipe = " | ")
------------------------------------------------------------------------------------------------------------------ ? /= the cmd(' (%S+) ') comes after spaces ( ' %s+ ' )
s,e,cmd = strfind(sdata, "%b<>%s+(%S+)") -------------------------------------------------- 3 = that come after a pattern
------------------------------------------------------------------------------------------------------------------ ? \= that resembles the nick ( ' %b<> ' )
if cmd ~= nil then ----------------------------------------------------------------------------------4 if the message isn't nil and
if cmd == "+help" then -----------------------------------------------------------------5 the message is our cmd then
user:SendPM(botname, "-u-s-e--c-m-d-> !userhelp") --------------------6 Send (private) msg to the Main Chat of the user  
end ----------------------------------------------------------------------------------------7 end the find if cmd part ...
end ---------------------------------------------------------------------------------------------------8 end the find if cmd not nil part ...
end --------------------------------------------------------------------------------------------------------------9 end the if main chat msg part ...
end -------------------------------------------------------------------------------------------------------------10 end the Data Arrivals function ...

I was looking here (http://board.univ-angers.fr/thread.php?threadid=763&boardid=4&styleid=1) and here (http://lua-users.org/wiki/PatternsTutorial) for help on this ...
Thanks to you alsom your post triggered a will to learn pattern matching the good way ;)