FAQ  •  Register  •  Login

Eliza Hack: Moobot

Forum rules
Post confirmed bugs and approved feature requests here. Unapproved feature requests will be deleted.

Please limit posts to One Feature per Thread unless features are closely related.
<<

Opti

User avatar

Posts: 234

Joined: Tue Sep 20, 2011 7:09 pm

Location: Footie's pantry

Post Wed Feb 06, 2013 3:13 pm

Eliza Hack: Moobot

Introducing moobot the chat-bot!! This is the public edition of moobot. The main version is only allowed on my server.
  Code:
local function MooBot(text)
  local response = ""                  -- Our response
  local user = string.upper(text)      -- Message from user in upper case
  local userOrig = user

  -- randomly selected replies if no keywords
  local randReplies = {
    "WUT DUS DAT SUJEST 2 CHU?",
    "AI SEH...",
    "I IZ NAWT SHURE AI UNDERSTIND CHU FULLEH",
    "CAYN CHU ELABIRITE IN DAT?",
    "DAT IZ QUIETE INATESTIN'",
    "DATS SO... PLZ CONTINUE...",
    "AI UNDERSTIND.",
    "WEL, WEL, GU IN..",
    "WAI ARE CHU SAYIN' DAT?",
    "PLZ EKSPLIN DA BICKGROND 2 DAT REMACK.",
    "CULD CHU SAI DAT AGAN? EN EH DIFFIRNT WAI?",
  }

  -- keywords, replies
  local replies = {
    [" CAN YOU"] = "NU, BUTT CHU SHULD B ABLE 2",
    [" DO YOU"] = "YESH, AI",
    [" CAN I"] = "MAY B CHU DON'T WANT TO",
    [" YOU ARE"] = "WUT MAKS CHU THANK AI AM",
    [" YOU'RE"] = "WUT IZ CHUR REACTION 2 MEH BEIN'",
    [" I DON'T"] = "WAI DUN'T CHU",
    [" I FEEL"] = "WHY ARE CHU FEELIN'",
    [" WHY DON'T YOU"] = "NU I WILL NOT",
    [" WHY CAN'T I"] = "CHU CAYN",
    [" ARE YOU"] = "WAI R CHU INTERESTED IF AH AM",
    [" I CAN'T"] = "ORLY NAO? CHU CAN'T",
    [" SEX"] = "EW, AI DU NUT WANT 2 KNEW ABUT",
    [" I AM"] = "HAO LONG HAD CHU BEAN",
    [" I'M"] = "WAI CHU BE TELLIN MEH THAT CHUR",
    [" I WANT"] = "WAI DO CHU WNT",
    [" WHAT"] = "WUT DO CHU THANK?",
    [" HOW"] = "WUT ANSWER WOULD PLEASE YOU THE MOST",
    [" WHO"] = "HOW OFTEN DU CHU THANK UF SICH QUESTIONS??",
    [" WHERE"] = "WHY DID YOU THINK OF THAT?",
    [" WHEN"] = "WHAT WOULD YOUR BEST FRIEND SAY TO THAT QUESTIONZ?",
    [" WHY"] = "WAT IZ IT DAT CHU REELY WUNT 2 KNOW?",
    [" PERHAPS"] = "CHU R NAWT VERY FERM ON DAT!",
    [" DRINK"] = "BEEER TAIME?",
    [" SORRY"] = "WAI R CHU APOLOGIZING",
    [" DREAMS"] = "WAI DID CHU BRANG IP TEH SIBGECT OF DREAMZ?",
    [" I LIKE"] = "IS IT GOOD THAT YOU LIKE",
    [" MAYBE"] = "CHU SPELT MAY B WRONG",
    [" NO"] = "DONUT B NEGITAIVE",
    [" YOUR"] = "WAI ARE CHU CONCERNED ABUT MAI",
    [" ALWAYS"] = "CAN YOU THINK OF A SPECIFIC EXAMPLE?",
    [" THINK"] = "DO YOU DOUBT",
    [" YES"] = "YUS? YUS.",
    [" FRIEND"] = "WAI DU CHU BRANG UP FRIENDZ?",
    [" COMPUTER"] = "WAI DU CHU MENTION COMPUTORZ",
    [" AM I"] = "CHU R NAWT",
}

  -- conjugate
  local conjugate = {
    [" I "] = "CHU",
    [" ARE "] = "IZ",
    [" WERE "] = "WAZ",
    [" YOU "] = "MEH",
    [" YOUR "] = "MAI",
    [" I'VE "] = "YOU HAV",
    [" I'M "] = "CHUR",
    [" ME "] = "CHU",
    [" AM I "] = "CHU'RE",
    [" AM "] = "R",
  }

  -- random replies, no keyword
  local function replyRandomly()
    response = randReplies[math.random(table.getn(randReplies))].."  "
  end

  -- find keyword, phrase
  local function processInput()
    for keyword, reply in pairs(replies) do
      local d, e = string.find(user, keyword, 1, 1)
      if d then
        -- process keywords
        response = response..reply.." "
       
        -- If reply already ends in a "?", then we're done.
        if string.byte(string.sub(reply, -1)) < 65 then -- "A" = 65, "?" = 63
          return
        end
       
        local h = string.len(user) - (d + string.len(keyword))
        if h > 0 then
          user = string.sub(user, -h)
        end
        for cFrom, cTo in pairs(conjugate) do
          local f, g = string.find(user, cFrom, 1, 1)
          if f then
            local j = string.sub(user, 1, f - 1).." "..cTo
            local z = string.len(user) - (f - 1) - string.len(cTo)
            response = response..j.."  "
            if z > 2 then
              local l = string.sub(user, -(z - 2))
              if not string.find(userOrig, l) then return end
            end
            if z > 2 then response = response..string.sub(user, -(z - 2)) end
            if z < 2 then response = response end
            return
          end--if f
        end--for
        response = response..user
        return
      end--if d
    end--for
   
    -- If we haven't found a reply by now, pick from our random list
    replyRandomly()
    return
  end

  -- First word is "BYE"
  if string.sub(user, 1, 3) == "BYE" then
    response = "BAI."
    return response
  end
 
  -- Trim off leading "BECAUSE"
  if string.sub(user, 1, 7) == "BECAUSE" then
    user = string.sub(user, 8)
  end
 
  user = " "..user.." "
 
  processInput()
  return response
end


function onMsgReceived(message, player)
   if message ~= "" and not player:isRobot() then
      bot:globalMsg(MooBot(message))
   end
end

-------------------------------------------------------------------------------
-- This function is called once and should return the robot's name

function getName()
    return("MooBot")
end

------------------------------------------------------------------------
-- setup
------------------------------------------------------------------------

function main()
   globalMsg("Hallo!")
   globalMsg("I am the public version of moobot, I can not be updated.")
   globalMsg("The main moobot is on [OPTIMUSERVER]")
   
   subscribe(Event.MsgReceived)
   unsubscribe(Event.Tick)
end
Last edited by Opti on Sun Feb 10, 2013 5:08 pm, edited 1 time in total.
i got a rattlesnake gun.
<<

amgine

Posts: 1399

Joined: Thu Apr 19, 2012 2:57 pm

Post Thu Feb 07, 2013 8:48 pm

Re: Eliza Hack: Moobot

what if i edit it then can i post it on my server btw i tried it good bot....
Bitfighter Forever.
<<

Opti

User avatar

Posts: 234

Joined: Tue Sep 20, 2011 7:09 pm

Location: Footie's pantry

Post Thu Feb 07, 2013 8:56 pm

Re: Eliza Hack: Moobot

amgine wrote:what if i edit it then can i post it on my server btw i tried it good bot....


Thanks, And you may edit it.
i got a rattlesnake gun.
<<

amgine

Posts: 1399

Joined: Thu Apr 19, 2012 2:57 pm

Post Thu Feb 07, 2013 9:09 pm

Re: Eliza Hack: Moobot

ill see if i can impove it..... (ill let you get the credit xd)
Bitfighter Forever.

Return to Bitfighter Features

Who is online

Users browsing this forum: No registered users and 15 guests

cron