PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: AMediaMan on 12 September, 2004, 00:55:14

Title: Ada trigger bot help
Post by: AMediaMan on 12 September, 2004, 00:55:14
Hi everyone been awhile i know :)

so lets get things going hahaha, i need help with the Ada trigger bot. Here is the script

-- TrickerBot2.lua, created by Ptaczek Dec-24, 2002
-- Just see how to implement the NMDC TriggerBot in LUA :)
-- changes
-- Feb-24, 2003, v2.0 Modification for DataArrival return value.
-- Tiny changes by VidFamne with lot of help by Piglja
-- VidFamne added Pigljas time-function, and some more trigs
-- A bug-fix by VidFamne, hopefully. And added some more triggs ;)
-- A new bug-fix ( for the "!me-command" ) by VidFamne, added ( 09.04.2003 ).
-- Added MatrixX On/Off function. Just type +quiet in mainchat to stop the Bot,
-- and +talk to start the Bot again. By VidFamne ( 05.05.2003 )
-- Bug-fix by [AF]Mike

botname = "Funboy"

trigall=1

trigs = {
             
["lol"]={
  "Yeah, [CURUSER] that was funny,  Hahahaha.",
  "Hmm, ok that was funny, I think :)",
  "what! [CURUSER]  why are you laughing?",
  "You shake when you laugh, like a bowl full of jelly",
  "hilarious!",
  "hehehehe",
  "hohohohoh"  
                              },

hehe={
  "Yeah, [CURUSER] that was funny,  Hahahaha.",
  "Hmm, ok that was funny, I think :)",
  "what! [CURUSER]  why are you laughing?",
  "You shake when you laugh, like a bowl full of jelly",
  "hilarious!",
  "hehehehe",
  "hohohohoh"
                              },

haha={
  "Yeah, [CURUSER] that was funny,  Hahahaha.",
  "Hmm, ok that was funny, I think :)",
  "what! [CURUSER]  why are you laughing?",
  "You shake when you laugh, like a bowl full of jelly",
  "hilarious!",
  "hehehehe",
  "hohohohoh"
                              },
                             
rofl={
  "Yeah, [CURUSER] that was funny,  Hahahaha.",
  "Hmm, ok that was funny, I think :)",
  "what! [CURUSER]  why are you laughing?",
  "You shake when you laugh, like a bowl full of jelly",
  "hilarious!",
  "hehehehe",
  "hohohohoh"
                              },
                             
lmao={
  "Yeah, [CURUSER] that was funny,  Hahahaha.",
  "Hmm, ok that was funny, I think :)",
  "what! [CURUSER]  why are you laughing?",
  "You shake when you laugh, like a bowl full of jelly",
  "hilarious!",
  "hehehehe",
  "hohohohoh"
                              },

bye={
    "See ya, [CURUSER]",
    "Bye, [CURUSER]   .....*sniff*",
    "Hey,  [CURUSER] get your ass back here. Hehe just kidding, if U have to go U have to go, Bye",
    "*Snif* we will miss you, [CURUSER]!",
    "*Waves bye*",
    "Leaving already?!",
    "Got better things to do, huh?",
    "Go on...leave!"
                              },

cya={
    "See ya, [CURUSER]",
    "Bye, [CURUSER]   .....*sniff*",
    "Hey,  [CURUSER] get your ass back here. Hehe just kidding, if U have to go U have to go, Bye",
    "*snif* we will miss you, [CURUSER]!",
    "*waves bye*",
    "Leaving already?!",
    "Got better things to do, huh?",
    "Go on...leave!"
                                },

["cu"]={
    "See ya, [CURUSER]",
    "Bye, [CURUSER]   .....*sniff*",
    "Hey,  [CURUSER] get your ass back here. Hehe just kidding, if U have to go U have to go, Bye",
    "*Snif* we will miss you, [CURUSER]!",
    "*Waves bye*",
    "Leaving already?!",
    "Got better things to do, huh?",
    "Go on...leave!"
                            },

fuck={
    "Watch IT [CURUSER]!! One more line of code and i could kick your ass!",
    "I hate it when you talk like that!",
    "Don't ever insult me again",
    "That's not a very nice way to talk !",
    "Keep it up and I will kick you!",
    "Say that again and I am going to clobber you!"
                            },

fucker={
    "Watch IT [CURUSER]!! One more line of code and i could kick your ass!",
    "I hate it when you talk like that!",
    "Don't ever insult me again",
    "That's not a very nice way to talk !",
    "Keep it up and I will kick you!",
    "Say that again and I am going to clobber you!"
                            },

["shut up"]={
      "Make me!",
      "Ooh! I'm wounded!",
      "I'll shut up when I damn well please",
      "blah blah blah!",
      "Why should I?"
                            },

stfu={
      "Make me!",
      "Ooh! I'm wounded!",
      "I'll shut up when I damn well please",
      "blah blah blah!",
      "Why should I?"
                            },

["hi"]={
      "Hello [CURUSER]",
      "Hey  [CURUSER]",
      "Wassup [CURUSER]",
      "Hi [CURUSER]",
      "Hey [CURUSER], what's going on?",
      "Howdy [CURUSER]!",
      "Greetings,  [CURUSER]",
      "[CURUSER], do I know you?"
                        },

hello={
      "Hello [CURUSER]",
      "Hey  [CURUSER]",
      "Wassup [CURUSER]",
      "Hi [CURUSER]",
      "Hey [CURUSER], what's going on?",
      "Howdy [CURUSER]!",
      "Greetings,  [CURUSER]",
      "[CURUSER], do I know you?"
                        },

hey={
      "Hello [CURUSER]",
      "Hey  [CURUSER]",
      "Wassup [CURUSER]",
      "Hi [CURUSER]",
      "Hey [CURUSER], what's going on?",
      "Howdy [CURUSER]!",
      "Greetings,  [CURUSER]",
      "[CURUSER], do I know you?"
                        },

drunk={
"me dRunk? -*- hik -*-",
"pftftt paff the boffle bartender   pfffttttttt",
"I just drank a little...",
"I am not drunk!!",
"I am  not dddddddddddddrunk.....",
"drunk?",
"pfftt!",
"pour me another",
"*spew*",
"oohhh my head",
"I think I'm gonna hurl",
"*BLAH*",
"*BURP*",
"me not drunk *HICK*"
                            },

["bot"]={
"Bots suck!",
"Direct Connect bots are lame...",
"A bot?",
"Me? I don't think so...",
"Don't lie!",
"piece of shit! I 've been found out! -NOT-",
"I am quite human...",
"bite me!",
"eat shit!  I am not a bot!",
"a bot?",
"What the shit is a bot?",
"You don't think my name is 'Bot' do you?",
"Are you trying to say that I am a machine?",
"ME? HAHA",
"I am a real person!",
"I am not a bot, I am a real human!",
"I may be dumb, but I am not a bot!",
"I may be really confused, but I am no robot!",
"I assure you I am just as real as you!",
"I know you are, but what am I?",
"am not!",
"<- - - real live person",
"Kill the bots!",
"WHO is a bot???",
"a bot? where?",
"a bot? here?",
"I doubt if there are any bots here!",
"Where do you get such a crazy idea!",
"I am NOT a bot",
"I am all too real, sorry!",
"I am a fleshy human being!",
"Do you make it a habit of accusing others, [CURUSER]?"
                                },

drug={
"drugz?",
"illegal substances?",
"narcotics?",
"sniiiiiifffffff",
"Me drugs? never!",
"who is selling drugs?",
"aren't drugs legal in Amsterdam?",
"drugs are too expensive",
"drugs are too dangerous",
"drugs inhibit my abily ot tiiiippe.",
"purple haze, all around my brain...",
"go to drugs R us",
"drugs are bad",
"just say no!",
"just say maybe!",
"just say how much!",
"I buy my crack from the mexicans!",
"I hear that the telephone company is a big doper!",
"I think all the drugs are smuggled in from the planet 'Uranus'",
"whehhwewe! pretty elephants!",
"*snif* ahh!"
                              },                    

drink={
"gulp, gulp, gulp",
"*takes big drink*",
"Bartender! pour me another!",
"hik!",
"I am thirsty...",
"pass the bottle",
"*takes a shot*",
"I need another cool one",
"this bud's for me! *gulp*",
"I can drink 16 six packs!",
"All American beer sucks!",
"Dutch beer is GEWD!",
"aye... I'll drink any man under the table!",
"*reaches for another beer*",
"*burp*",
"I need some more budweiser",
"somebody pour me a big glass of Guinness Stout.",
"anyone ever try a wild turkey?",
"I love beer!",
"I love vodka!",
"I took 14 shots of mad dog once!",
"itth myth speetthch slurrererrred????",
"I think alll mi beer is iampring mi typppin abillty?!?",
"someone get me a beer!",
"beer is awesome!",
"humans can not live by beer alone! But I'd like to try!",
"I think you should stop drinking"
                              },

sorry={
      "don't worry about it",
      "that's ok ",
      "ok",
      "that's allright",
      "fine",
      "as long as your sorry...",
      "allright",
      "I feel you didn't really mean that...",
      "you don't sound sincere",
      "are you really sorry?",
      "forget it",
      "no sweat",
      "ok"
                          },

wassup={
      "hunting crocodiles",
      "nothing at the moment",
      "eating",
      "eating pizza :)",
      "changing the tires on my dodge",
      "juggling chainsaws",
      "drinking beer",
      "smoking up a storm",
      "belly-dancing",
      "hacking microsoft.com",
      "trying to keep awake!",
      "watching television",
      "I am doing homework",
      "what do you think!",
      "building a spice rack",
      "taking a shower",
      "drinking myself to death",
      "drinking myself to oblivian",
      "making origami swans",
      "feeding my ducks",
      "learning latin",
      "programming",
      "play the basoon",
      "program in Assembly",
      "program in C++"
                        },
                 
["are you"]={
"does it matter if I am ?",
"what difference does it make whether or not I am",
"of course not, don't be silly",
"Whether I'm or not is my secret",
"why do you want to know?",
"why are you so nosy?",
"perhaps I am ",
"none of your business",
"I think you are ",
"does it matter if I am or not?",
"why do you ask?",
"I might be",
"No, I am not ",
"of course",
"never have been",
"why, are you?"
                            },

bitch={
"Who are you calling a bitch??",
"Oh, I'm upset",
"VidFamne is a bitch!",
"K?lle is always trying to make me his bitch",
"I can be a bitch!",
"Hey [CURUSER], that is no way to talk!",
"Do you think foul language impresses me?",
"A bitch is a female dog"
                              },
                   
yeah={
"yes",
"yep",
"uh huh",
"100%",
"bang on!",
"you bet",
"uh-hu",
"yes",
"of course!",
"you-betcha",
"affirmative",
"10-4 good buddy!",
"correct",
"yeah",
"that's right!",
"you got it!",
"sure",
"precisely right",
"that sounds right",
"exactly!",
"you know it!",
"yeppers"
                            },
                                     
slot={
"Yeah i gotta slot for ya",
      "As if you need another one of those",
      "Pull your finger out of your ass and youd have a free one",
      "A slot...a slot omg not again"        
                            }    
         
}


function Main()
frmHub:RegBot(botname)
end

function DataArrival(curUser, data)

status=strsub(data,1,strlen(data)-1)
-- parse the command
s,e,cmd = strfind( status, "%b<>%s+(%S+)" )

if (cmd=="+quiet") then
trigall=0
SendToAll(botname, " Hmf, Okidoki I will be quiet :(( ")
return 1
elseif (cmd=="+talk") then
trigall=1
SendToAll(botname, " Okay, I will talk to you again :-)")
return 1
end

       
Title: The rest lol
Post by: AMediaMan on 12 September, 2004, 00:55:48
if( strsub(data, 1, 1) == "<" ) then
-- get the msg only using regular expression
s,e,msg = strfind(data, "%b<>([%a ]+)")                                        
-- look in the table
                if trigall==1 then
for key, value in trigs do
                for key2, value2 in value do
                     
if( strfind( strlower(msg), key) ) then
              else break  
end

        if( strfind( strlower(msg), "!me") ) then
                t="**"..curUser.sName
                data=gsub (msg, "!me", t, 1 )
end

SendToAll( data ) -- send the original data
                   
          SetTimer(1800)
                StartTimer()
answer, x = gsub(value[random(1,getn(value))], "%b[]", curUser.sName)

return 1; -- tell the hub we have processed the data
end
end  
end
end

function OnTimer()
SendToAll( botname, answer ) -- send bot's answer
StopTimer()
end
end


Now for my question lol

the script works great without a problem but what i would like is........ for one of the triggers it uses to say a random user not the user who typed it .You know what i mean right lol
i dont want [CURUSER] maybe [RANDOMUSER] so it will pick anyone from the user list at random

I hope this is possible I thank you all ahead of time cause i know this might be a challenge for some one hahaha thnx again.

AMediaMan



PS sorry if this has been asked i have looked everywhere to no avail >:o)
Title:
Post by: bastya_elvtars on 12 September, 2004, 01:10:02
please post it as code, i cannot fix it this way.
Title: hmmmmmm
Post by: AMediaMan on 12 September, 2004, 01:17:29
im not sure how sorry


i copied and pasted it here and thats how it came out



AMediaMan
Title:
Post by: bastya_elvtars on 12 September, 2004, 01:49:35

-- your code here


thats all :)

looks better, engages less space and makes scripters' life easier :P

its used starting with [CODE , ending with [/code
between these your code should be placed
just add the pair of that bracket: ] to the end of the words [code and [/code
Title:
Post by: AMediaMan on 12 September, 2004, 02:10:38
ok i give up

ive posted several scripts before and never had a problem lol maybe im just tired tonite.



AMediaMan
Title:
Post by: ??????Hawk?????? on 12 September, 2004, 04:30:04
hi m8  ...


edit your post and but the code switches..


[CODE ]

Your script here
...
......
.....
...

[/CODE ]




dont put a space after  CODE
Title:
Post by: bastya_elvtars on 12 September, 2004, 04:38:46
yea, i wrote the same but this can be understood better.
Title: sorry about that
Post by: AMediaMan on 12 September, 2004, 04:45:31
Thnx ??????Hawk??????
 
that helped and i did edit my posts ;) The above script is mostly the triggers so here is the actual main part of the script .
function Main()
frmHub:RegBot(botname)
end

function DataArrival(curUser, data)

status=strsub(data,1,strlen(data)-1)
-- parse the command
s,e,cmd = strfind( status, "%b<>%s+(%S+)" )

if (cmd=="+quiet") then
trigall=0
SendToAll(botname, " Hmf, Okidoki I will be quiet :(( ")
return 1
elseif (cmd=="+talk") then
trigall=1
SendToAll(botname, " Okay, I will talk to you again :-)")
return 1
end

       
if( strsub(data, 1, 1) == "<" ) then
-- get the msg only using regular expression
s,e,msg = strfind(data, "%b<>([%a ]+)")                                        
-- look in the table
                if trigall==1 then
for key, value in trigs do
                for key2, value2 in value do
                     
if( strfind( strlower(msg), key) ) then
              else break  
end

        if( strfind( strlower(msg), "!me") ) then
                t="**"..curUser.sName
                data=gsub (msg, "!me", t, 1 )
end

SendToAll( data ) -- send the original data
                   
          SetTimer(1800)
                StartTimer()
answer, x = gsub(value[random(1,getn(value))], "%b[]", curUser.sName)

return 1; -- tell the hub we have processed the data
end
end  
end
end

function OnTimer()
SendToAll( botname, answer ) -- send bot's answer
StopTimer()
end
end
Title:
Post by: BottledHate on 16 September, 2004, 07:32:17
sure...

cleaned up the bot a lil as well....

but add [RNDUSER] into the trig table where u want...

the random name is generated form a list of online users. the list is made from people joining the hub. so at first the list may be small.

CODE REMOVED

edit: changed more stuff. made it so the !me command can be used with any punctuation prefix. also fixed the strlower that was slowing down the script.

-BH

edit: code removed.. grab the code from three posts down.... :D
Title:
Post by: AMediaMan on 16 September, 2004, 13:24:02
Wow cool BottledHate, i did notice the script was kinda slow, I just didnt think much of it.


Im gonna test it here soon, but its time for work. I will post my response later. Thnx again BottledHate for all the help.




AMediaMan


EDIT -       hahaha ok i had to try it lol but here is an error i get ...Syntax Error: bad argument #1 to `random' (interval is empty)... dont really have time to check it out.
Title:
Post by: BottledHate on 17 September, 2004, 00:28:53
yep.... thats cause the list of random names is empty
 when the script is first run... as i mentioned, names are
added to the list of random users as users join the
hub... and their name is removed when they leave.

once u start the script, if you reconnect to your with
your client before trying to use the trigbot, you will not
get that error.  Currently there is no other method i'm
aware of to make a list of ONLINE users.  The list could
initially be populated with the hub's reg'd names, but
those would be offline and online users...

anyone else know a good reliable method to make a list
 of online users??


-BH
Title:
Post by: AMediaMan on 17 September, 2004, 01:55:59
Ok i will work with it and see lol get back to ya soon.


Thnx, AMediaMan
Title:
Post by: BottledHate on 17 September, 2004, 03:20:56
added:
+random response time 2 - 6 seconds...
+can respond to more than 1 trig (previously.. if you used a trig, and someone else did right after you but before the bots post.. it would be for their trig, not yours.)
+added another line to help populate the random users list faster.


botname = "Funboy"
trigall=1
function Main()
   frmHub:RegBot(botname)
end

onlineUsers = {}
sAnswer={}
sTrig = nil
function NewUserConnected(user)
   onlineUsers[user.sName] = 1
end
function OpConnected(user)
   onlineUsers[user.sName] = 1
end
function UserDisconnected(user)
   onlineUsers[user.sName] = nil
end
function OpDisconnected(user)
   onlineUsers[user.sName] = nil
end
function randomName()
   local n = 0
   for k,v in onlineUsers do n=n+1 end
   n = random( n )
   for k,v in onlineUsers do
      if n == 1 then
         k = k or ""
         return k
      end
      n = n - 1
   end
end
function DataArrival(curUser, data)
   if( strsub(data, 1, 1) == "<" ) then
      status=strsub(data,1,strlen(data)-1)
      if not onlineUsers[curUser.sName] then onlineUsers[curUser.sName] = 1 end --//trying to populate the random list faster.
      -- parse the command
      s,e,cmd = strfind( status, "%b<>%s+(%S+)" )
      if (cmd=="+quiet") then
         trigall=0
         SendToAll(botname, " Hmf, Okidoki I will be quiet :(( ")
         return 1
      elseif (cmd=="+talk") then
         trigall=1
         SendToAll(botname, " Okay, I will talk to you again :-)")
         return 1
      end
      -- get the msg only using regular expression
      s,e,msg = strfind(status, "%b<>%s+(.+)")                                        
      -- look in the table
      if strfind(msg, "^%pme .+") then
         t="**"..curUser.sName
         data=gsub (msg, "%pme", t, 1 )
         SendToAll( data )
         return 1
      end
      msg = strlower(msg)
      if trigall==1 then
         for key, value in trigs do
            if(strfind(msg, key) ) then
               SendToAll( data )
               SetTimer(1000)
               StartTimer()
               answer = gsub(trigs[key][random(1,getn(value))], "%[CURUSER%]", curUser.sName)
               answer = gsub(answer, "(%[RNDUSER%])", randomName())
               if sTrig == nil then sTrig = {} end
               sTrig[clock() + random(1,6)] = {[1] = answer}
               return 1
            end
         end
      end
   end
end
function OnTimer()
   if sTrig ~= nil then
      for k,v in sTrig do
         if k < clock() then
            SendToAll( botname, v[1])
            sTrig[k] = nil
         end
     end
      if sTrig == nil then StopTimer() end
  end
end

-BH

edit: only had the data arrival posted at first...
Title:
Post by: AMediaMan on 17 September, 2004, 11:41:13
Ok BottledHate im getting this error now


Syntax Error: expected;
  last token read: `end' at line 488 in file `H:\Pirates Hub\scripts\funboy.lua'


Any ideas ?  :))

AMediaMan
Title:
Post by: BottledHate on 17 September, 2004, 14:23:21
hmmmmmm i'm not getting that error.

what version of ptokax are you running?



-BH
Title:
Post by: AMediaMan on 18 September, 2004, 01:05:22
Im using TD 4.99




AMediaMan
Title:
Post by: BottledHate on 18 September, 2004, 01:09:21
i'm running the same.. and i still don't get that error...

that error is usually caused when an extra 'end' is there
 that doesn't need to be.  have you added, or\removed
anything?


-BH
Title:
Post by: bastya_elvtars on 18 September, 2004, 01:34:46
QuoteOriginally posted by BottledHate
i'm running the same.. and i still don't get that error...

that error is usually caused when an extra 'end' is there
 that doesn't need to be.  have you added, or\removed
anything?


-BH

he must have, since above script is definitely error-free
Title:
Post by: BottledHate on 18 September, 2004, 02:25:40
QuoteOriginally posted by bastya_elvtars
QuoteOriginally posted by BottledHate
i'm running the same.. and i still don't get that error...

that error is usually caused when an extra 'end' is there
 that doesn't need to be.  have you added, or\removed
anything?


-BH

he must have, since above script is definitely error-free


thanks for the double check bastya!


-BH
Title:
Post by: AMediaMan on 18 September, 2004, 02:30:39
Nope didnt add anything.

i might have copied it wrong or something.
i will try again :)


AMediaMan





EDIT :  Ok that must have been the problem cause it seems to work fine now :) thnx for all the help
Title:
Post by: BottledHate on 18 September, 2004, 02:37:01
ok.. good to hear :D  let me know if you have any other changes or whatever you would like done :)


-BH
Title:
Post by: AMediaMan on 19 September, 2004, 20:00:23
Hey BottledHate not to complain any but the bot seems rather slow with its responses. Not sure if it has anything to do with my other scripts or not but I just wanted let you know. By slow im talking like maybe 10 or 15 secs. Before if i remember correctly it was much faster. Just some input for ya lol, other than that it seems to work great thnx again for letting me trouble you hahahaha.




AMediaMan
Title:
Post by: BottledHate on 19 September, 2004, 20:25:01
interesting.. it responds within 1 - 6 seconds for me...

i wonder what the problem is... can anyone else test this out and see if they have a similar problem?

-BH
Title:
Post by: AMediaMan on 20 September, 2004, 05:20:48
Hey Mutor, thats all set thnx. The script works fine for me as well it just seems very slow.


BottledHate, i am curently running it alone with absolutly nothing else and there really wasnt any improvement, still seems slow. I am still using TD 4 not sure if that has anything to do with it >:o)



AMediaMan
Title:
Post by: BottledHate on 20 September, 2004, 05:57:47
QuoteOriginally posted by AMediaMan
Hey Mutor, thats all set thnx. The script works fine for me as well it just seems very slow.


BottledHate, i am curently running it alone with absolutly nothing else and there really wasnt any improvement, still seems slow. I am still using TD 4 not sure if that has anything to do with it >:o)



AMediaMan

would it be possible for you to zip up the script and put it somewhere i can get at it??? so i can test more with exactly what u have running....

-BH
Title:
Post by: AMediaMan on 23 September, 2004, 23:25:52
Hey BottledHate heres a request  :D , Can this bot be made so it is more word for word ? What i mean is one of the triggers is Hi and if some one types the word think which includes the word hi, lol the bot responds still. It would be nice if it didnt do that. Not sure this is possible. But it would be much nicer  :]



Thnx, AMediaMan
Title:
Post by: BottledHate on 24 September, 2004, 00:50:57
this can be done... i'll work on it tonight.. :D


-BH
Title:
Post by: AMediaMan on 24 September, 2004, 04:14:16
TY BottledHate  :))






AMediaMan
Title:
Post by: BottledHate on 24 September, 2004, 07:45:58
well shit... it's a bit late now, and i sent more time than i thought i would on that word replace script... which is ok! because it will ultimatly help with your request for this one... :D  i'll try and have it done by tomorrow night.


-BH
Title:
Post by: AMediaMan on 24 September, 2004, 22:56:38
Hahahahaha no problem BottledHate. No rush at all over here, take your time and when your done your done lol.








AMediaMan
Title:
Post by: BottledHate on 25 September, 2004, 06:42:37
ok.. here it is...

added the abilty to make trigs absolute. by putting a "*" in front of the trig (see sample table) nothing else can be around it....


--//sample table
trigs = {
   ["*hi"]={
      "Hello [CURUSER]",
      "Hey  [CURUSER]",
      "Wassup [CURUSER]",
      "Hi [CURUSER]",
      "Hey [CURUSER], what's going on? [RNDUSER] was looking for you...",  --//RNDUSER
      "Howdy [CURUSER]!",
      "Greetings,  [CURUSER]",
      "[CURUSER], do I know you?"
   },
   ["hello"]={
      "Hello [CURUSER]",
      "Hey  [CURUSER]",
      "Wassup [CURUSER]",
      "Hi [CURUSER]",
      "Hey [CURUSER], what's going on? [RNDUSER] was looking for you, and it didn't sound good.",  --//RNDUSER
      "Howdy [CURUSER]!",
      "Greetings,  [CURUSER]",
      "[CURUSER], do I know you?"
   },
}


--//edit this junk
botname = "Funboy" --//set the reply name
OneRandomName ="BottledHate" --//put a random name here.. (anything) to populate the random table, and avoid errors.

--//ok stop,
-----------------------
function Main()
   frmHub:RegBot(botname)
end
trigall=1  
onlineUsers = {[OneRandomName] = 1}
sAnswer={}
sTrig = nil
function NewUserConnected(user)
   onlineUsers[user.sName] = 1
end
function OpConnected(user)
   onlineUsers[user.sName] = 1
end
function UserDisconnected(user)
   onlineUsers[user.sName] = nil
end
function OpDisconnected(user)
   onlineUsers[user.sName] = nil
end
function randomName()
   local n = 0
   for k,v in onlineUsers do n=n+1 end
   n = random( n )
   for k,v in onlineUsers do
      if n == 1 then
         k = k or ""
         return k
      end
      n = n - 1
   end
end
function DataArrival(curUser, data)
   if( strsub(data, 1, 1) == "<" ) then
      status=strsub(data,1,strlen(data)-1)
      if not onlineUsers[curUser.sName] then onlineUsers[curUser.sName] = 1 end --//trying to populate the random list faster.
      -- parse the command
      s,e,cmd = strfind( status, "%b<>%s+(%S+)" )
      if (cmd=="+quiet") then
         trigall=0
         SendToAll(botname, " Hmf, Okidoki I will be quiet :(( ")
         return 1
      elseif (cmd=="+talk") then
         trigall=1
         SendToAll(botname, " Okay, I will talk to you again :-)")
         return 1
      end
      -- get the msg only using regular expression
      s,e,msg = strfind(status, "%b<>%s+(.+)")                                        
      -- look in the table
      if strfind(msg, "^%pme .+") then
         t="**"..curUser.sName
         data=gsub (msg, "%pme", t, 1 )
         SendToAll( data )
         return 1
      end
      msg = strlower(msg)
      if trigall==1 then
         findTriggers(msg, curUser)
      end
   end
end
function findTriggers(d,u)
   for key, value in trigs do
      if strsub(key,1,1) == "*" then
         trigFound = nil
         x = gsub(key,"*","")
         local m = gsub(d,"(%S+)",
         function (w)
            if w == x then trigFound =  1 end
         end)
         if trigFound then
            SetTimer(1000)
            StartTimer()
            answer = gsub(trigs[key][random(1,getn(value))], "%[CURUSER%]", u.sName)
            answer = gsub(answer, "(%[RNDUSER%])", randomName())
            if sTrig == nil then sTrig = {} end
            sTrig[clock() + random(1,6)] = {[1] = answer}            
            break
         end
      else
         if(strfind(msg, key) ) then
            SetTimer(1000)
            StartTimer()
            answer = gsub(trigs[key][random(1,getn(value))], "%[CURUSER%]", u.sName)
            answer = gsub(answer, "(%[RNDUSER%])", randomName())
            if sTrig == nil then sTrig = {} end
            sTrig[clock() + random(1,6)] = {[1] = answer}
            break
         end
      end
   end
end
function OnTimer()
   if sTrig ~= nil then
      for k,v in sTrig do
         if k < clock() then
            SendToAll( botname, v[1])
            sTrig[k] = nil
         end
     end
      if sTrig == nil then StopTimer() end
  end
end


-BH
Title:
Post by: AMediaMan on 26 September, 2004, 01:22:27
Nicely done  :))  Much better to work with thank you much.






Thnx Again, AMediaMan
Title:
Post by: BottledHate on 26 September, 2004, 03:55:43
QuoteOriginally posted by AMediaMan
Nicely done  :))  Much better to work with thank you much.


Thnx Again, AMediaMan

happy i could help. :) as always, if you have any other requests, don't hesitate to ask.. :D

-BH
Title:
Post by: AMediaMan on 27 September, 2004, 02:45:04
ok ok lol how about this BottledHate.
can you make it so that the bot doesnt use the CURUSER as a RANDUSER ?

(example)say i type thats cool..........
and the bot says Hey RNDUSER, CURUSER thinks he is cool....
can you make it so the bot doesnt use my name for both the RNDUSER and the CURUSER ? That way the response doesnt look like this ..........Hey AMediaMan, AMediaMan thinks he is cool.

Just another thought  :D  



Thnx, AMediaMan