PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: BlazeXxX on 31 October, 2003, 03:06:56

Title: CallBot
Post by: BlazeXxX on 31 October, 2003, 03:06:56
A CallBot from Bonki :)


-- Start Copying From this line
-- simple standalone CallBot by bonki 08/17/03

sBotName    = "CallBot";

sCallMsg    = "[nick] awaits you eagerly in main chat!"
sCallPhrase = "!call";

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 == sCallPhrase) then
    curUser:SendData(sData);

    callUser = GetItemByName(args)
    if (callUser) then
      sMsg = gsub(sCallMsg, "%[nick%]", curUser.sName);
      SendPmToNick(callUser.sName, sBotName, sMsg);
    else
      if (strlen(args) > 0) then
        curUser:SendData(sBotName, args.." is currently not connected!");
      else
        curUser:SendData(sBotName, "Syntax: "..sCallPhrase.." ");
      end
    end

    return 1;
  end
end

-- Finish copying