PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Noclip on 22 January, 2004, 21:04:58

Title: need some help
Post by: Noclip on 22 January, 2004, 21:04:58
if someone could help me with this bot ....
i cant figure out how i can make it to stop responce to question mark....i removed the only line that had it ...but didint help  :D


sVer       = "0.21";

sName      = "Oracle"
sAskPhrase = "!oracle";

iInterval  = 8 * 1000;
--iInterval  = nil; -- uncomment this if you don't want to use this feature

aAnswers = {
             "No.",
             "Yes.",
             "NOOOOOOOOOOOOOOOOOOO!",
             "Definitely.",
             "All signs point to yes.",
             "Yeah :)",
             "HELL NO!",
             "No way my friend!",
             "Never ever.",
             "As certain as death!",
             "Not here. In my coffee break.",
             "No...now go and blame your mother in law!",
             "Don't count on it.",
             "Still wearing womans dresses?.",
             "Without a doubt!",
             "My reply is no.",
             "You may rely on it.",
             "I can't predict now, need some food first!",
             "My sources say no...",
             "Yes, most likely.",
             "Pffffffew...Who is the one with the smelly feets here?....",
             "Concentrate and ask again.",
             "You look like a girl you know that?.",
             "This is very doubtful.",
             "Stop bothering me....",
             "Ewwwww  did you brushed your teeth yet?",
             "Better not tell you know ;-)",
             "Couldn't read from brain. (A)bort, (R)etry, (I)gnore?_",
             "I calculated the probability to 50 percent.",
             "I know but I won't tell you :-)",
             "Pay me and I'm gonna tell you.",
             "Ask your mummy, she knows better than a stupid billard ball!",
             "Are you kidding?",
             "What? Sorry I haven't paid attention, ask again...",
             "Huh?",
             "Blah blahhh blahh...",
             "Boooooooooooooring",
             "You must be kidding!",
             "HAHA, they say i am stupid but look at you.",
             "Are you serious?",
             "You must be a real goof then...",
             "Dont you have some social life dude? ",
             "Haha, I like you...funny guy, you are :-)",
             "Geeeeee...what a stupid question.",
             "Stop doing drugs :-P",
             "Go ask [SU]Buick, He pretends to be smarter then i am  (NOT).",
             "How could you think of such things?",
             "How should I know?",
             "And they say there are no stupid questions...",
             "Get a life and leave me alone!",
             "BLOOD SHALL COME UPON YOU!",
             "Go to bed and ask tomorow, GOODNITE",
             "Get some money first.",
             "Ask RabidWombat, he'll know for sure :-)", -- honor to whom honor is due! :-)
             "W-e  a-r-e  B-o-r-g,  y-o-u  w-i-l-l  b-e  a-s-s-i-m-i-l-a-t-e-d,  R-e-s-i-s-t-a-n-c-e  i-s  f-u-t-i-l-e ! Err...I mean...No.",
           };

sLastNick = nil;

function Main()
  randomseed(clock());

  bot = { sBotName  = sName,
          sBotVer   = sVer,
          sBotEmail = "webmaster@dc-united.net",
          sBotSpeed = "Sol",                   -- "Speed of Light" =)
          sBotTag   = "<++ V:"..sVer..",P:Dutch,T:"..getn(aAnswers)..">",
          sBotDescr = "Here to tease you all",
          iBotShare = 0 };

  frmHub:RegBot(bot.sBotName);
  UpdateBotInfo();

  SetTimer(iInterval);
end

function NewUserConnected(curUser)
  curUser:SendData(sBotInfo);
end

function OpConnected(curUser)
  curUser:SendData(sBotInfo);
end

function DataArrival(curUser, sData)
  local _, _, cmd, args = strfind(sData, "^%b<>%s+(%S+)%s*([^%|]*)%|$");

  if (cmd == nil) then
    return 0; end;

  cmd = strlower(cmd);

  if (cmd == sAskPhrase) then
    SendToAll(sData);

    -- quick-check whether it COULD be a question somehow

   

  if (iInterval) then
    if (strfind(args, "%s+")) then
      bQuestion = 1;
      StartTimer();
    else
      bQuestion = nil;
      StopTimer();
    end
  end

  return 0;
end

function OnTimer()
  if (bQuestion) then
    SendToAll(bot.sBotName, GetRandomSentence());
  end
  StopTimer();
end

function GetRandomSentence()
 local iRnd = random(getn(aAnswers));
 return aAnswers[iRnd];
end

function UpdateBotInfo()
  sBotInfo = "$MyINFO $ALL "..bot.sBotName.." "..bot.sBotDescr..bot.sBotTag.."$ $"..bot.sBotSpeed..strchar(1).."$"..bot.sBotEmail.."$"..bot.iBotShare.."$" ;
Title:
Post by: plop on 22 January, 2004, 23:31:09
is this the whole script ??
got the idea that there is something missing.

plop
Title:
Post by: TiMeTrAVelleR on 23 January, 2004, 06:12:39
Compleet one

-- [8-Ball] - v0.21
--
-- Written by bonki 2003
--
-- ABOUT:
--   A very simple magic 8-ball implementation.
--
-- AVAILABLE COMMANDS:
--  !8-ball
--
--  If iInterval is set it even answers if somebody asks a question in main chat
--  and nobody answers after iInterval milliseconds.
--
-- CHANGELOG:
--   v0.21: Bugfix: Auto-answer is now not sent when users PM eachother
--   v0.2:  Added:  Auto-answer in main chat, see "available commands" for further details.
--          Added:  Neat-looking tag :)
--   v0.11: Bugfix: can't remember :P
--   v0.1:  Initial Version

sVer       = "0.21";

sName      = "8-Ball"
sAskPhrase = "!8-ball";

iInterval  = 8 * 1000;
--iInterval  = nil; -- uncomment this if you don't want to use this feature

aAnswers = {
             "No.",
             "Yes.",
             "NOOOOOOOOOOOOOOOOOOO!",
             "Definitely.",
             "All signs point to yes.",
             "Yeah :)",
             "HELL NO!",
             "No way my friend!",
             "Never ever.",
             "As certain as death!",
             "No...now go and blame bonki!",
             "Don't count on it.",
             "Without a doubt!",
             "My reply is no.",
             "You may rely on it.",
             "I can't predict now, need some food first!",
             "My sources say no...",
             "Yes, most likely.",
             "Concentrate and ask again.",
             "This is very doubtful.",
             "Better not tell you know ;-)",
             "Couldn't read from brain. (A)bort, (R)etry, (I)gnore?_",
             "I calculated the probability to 50 percent.",
             "I know but I won't tell you :-)",
             "Pay me and I'm gonna tell you.",
             "Ask your mummy, she knows better than a stupid billard ball!",
             "Are you kidding?",
             "What? Sorry I haven't paid attention, ask again...",
             "Huh?",
             "Blah blahhh blahh...",
             "You must be kidding!",
             "Are you serious?",
             "Haha, I like you...funny guy, you are :-)",
             "Geeeeee...what a stupid question.",
             "Stop doing drugs :-P",
             "How could you think of such things?",
             "How should I know?",
             "And they say there are no stupid questions...",
             "Get a life and leave me alone!",
             "BLOOD SHALL COME UPON YOU!",
             "TRUE NORWEGIAN BLACK METAL!!!", -- sue me!!!
             "Get some money first.",
             "Ask RabidWombat, he'll know for sure :-)", -- honor to whom honor is due! :-)
             "W-e  a-r-e  B-o-r-g,  y-o-u  w-i-l-l  b-e  a-s-s-i-m-i-l-a-t-e-d,  R-e-s-i-s-t-a-n-c-e  i-s  f-u-t-i-l-e ! Err...I mean...No.",
           };

sLastNick = nil;

function Main()
  randomseed(clock());

  bot = { sBotName  = sName,
          sBotVer   = sVer,
          sBotEmail = "bonki@no-spam.net",
          sBotSpeed = "Sol",                   -- "Speed of Light" =)
          sBotTag   = "<++ V:"..sVer..",P:bonki,T:"..getn(aAnswers)..">",
          sBotDescr = "Magic 8-Ball-Bot v"..sVer.." written by bonki 2003",
          iBotShare = 0 };

  frmHub:RegBot(bot.sBotName);
  UpdateBotInfo();

  SetTimer(iInterval);
end

function NewUserConnected(curUser)
  curUser:SendData(sBotInfo);
end

function OpConnected(curUser)
  curUser:SendData(sBotInfo);
end

function DataArrival(curUser, sData)
  local _, _, cmd, args = strfind(sData, "^%b<>%s+(%S+)%s*([^%|]*)%|$");

  if (cmd == nil) then
    return 0; end;

  cmd = strlower(cmd);

  if (cmd == sAskPhrase) then
    SendToAll(sData);

    -- quick-check whether it COULD be a question somehow

    if (strfind(strsub(args, -3), "%?") and strfind(args, "%s+")) then
      SendToAll(bot.sBotName, GetRandomSentence());
    else
      SendToAll(bot.sBotName, "I'm a magic 8-ball you fool. Ask me a question or leave me alone!");
    end

    return 1;
  end

  if (iInterval) then
    if (strfind(strsub(args, -3), "%?") and strfind(args, "%s+")) then
      bQuestion = 1;
      StartTimer();
    else
      bQuestion = nil;
      StopTimer();
    end
  end

  return 0;
end

function OnTimer()
  if (bQuestion) then
    SendToAll(bot.sBotName, GetRandomSentence());
  end
  StopTimer();
end

function GetRandomSentence()
 local iRnd = random(getn(aAnswers));
 return aAnswers[iRnd];
end

function UpdateBotInfo()
  sBotInfo = "$MyINFO $ALL "..bot.sBotName.." "..bot.sBotDescr..bot.sBotTag.."$ $"..bot.sBotSpeed..strchar(1).."$"..bot.sBotEmail.."$"..bot.iBotShare.."$" ;
end