Module: Pandorified

Defined in:
lib/pandorified.rb,
lib/pandorified/result.rb,
lib/pandorified/session.rb,
lib/pandorified/version.rb

Overview

This is the top-level module for interacting with the Pandorabots API.

There are some sugar methods which delegate to Session under the hood.

Defined Under Namespace

Classes: PandorabotsError, Result, Session

Constant Summary collapse

API_URL =
'https://www.pandorabots.com/pandora/talk-xml'
VERSION =
'0.9.13'

Class Method Summary collapse

Class Method Details

.talk(input, botid, custid = nil) ⇒ Pandorified::Result

Send a message to a bot and receive a response.

See Result for ways to handle the response, or use talk! which raises an exception on errors.

If you want to remember the botid and custid between multiple calls, you should use Pandorabots::Session instead of this method.

Parameters:

  • input (String)

    Text to say to the bot.

  • botid (String)

    A valid Pandorabots botid.

  • custid (String) (defaults to: nil)

    An itentifier used to keep track of this conversaion.

Returns:



25
26
27
# File 'lib/pandorified.rb', line 25

def self.talk(input, botid, custid = nil)
  Pandorified::Session.new(botid, custid).talk(input)
end

.talk!(input, botid, custid = nil) ⇒ String

Send a message to a bot and receive a response (if successsful).

If Pandorabots responds with an error, PandorabotsError is raised.

If you’d rather check for and handle the error yourself, use talk instead of this method.

If you want to remember the botid and custid between multiple calls, you should use Pandorabots::Session instead of this method.

Parameters:

  • input (String)

    Text to say to the bot.

  • botid (String)

    A valid Pandorabots botid.

  • custid (String) (defaults to: nil)

    An itentifier used to keep track of this conversaion.

Returns:

  • (String)

    The bot’s response text.



45
46
47
# File 'lib/pandorified.rb', line 45

def self.talk!(input, botid, custid = nil)
  Pandorified::Session.new(botid, custid).talk!(input).to_s
end