Sha256: 6973c3912f05c018a537987f8473a1c8d917d865053de55cc5c7534670bb1608

Contents?: true

Size: 1.73 KB

Versions: 10

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

require 'pandorified/version'
require 'pandorified/result'
require 'pandorified/session'

# This is the top-level module for interacting with the Pandorabots API.
#
# There are some sugar methods which delegate to {Pandorified::Session} under
# the hood.
module Pandorified
  # Send a message to a bot and receive a response.
  #
  # See {Pandorified::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.
  #
  # @param [String] input Text to say to the bot.
  # @param [String] botid A valid Pandorabots botid.
  # @param [String] custid An itentifier used to keep track of this conversaion.
  #
  # @return [Pandorified::Result] The bot's response as a result object.
  def self.talk(input, botid, custid = nil)
    Pandorified::Session.new(botid, custid).talk(input)
  end

  # Send a message to a bot and receive a response (if successsful).
  #
  # If Pandorabots responds with an error, {Pandorified::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.
  #
  # @param [String] input Text to say to the bot.
  # @param [String] botid A valid Pandorabots botid.
  # @param [String] custid An itentifier used to keep track of this conversaion.
  #
  # @return [String] The bot's response text.
  def self.talk!(input, botid, custid = nil)
    Pandorified::Session.new(botid, custid).talk!(input).to_s
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pandorified-0.9.13 lib/pandorified.rb
pandorified-0.9.12 lib/pandorified.rb
pandorified-0.9.11 lib/pandorified.rb
pandorified-0.9.10 lib/pandorified.rb
pandorified-0.9.9 lib/pandorified.rb
pandorified-0.9.8 lib/pandorified.rb
pandorified-0.9.7 lib/pandorified.rb
pandorified-0.9.6 lib/pandorified.rb
pandorified-0.9.5 lib/pandorified.rb
pandorified-0.9.4 lib/pandorified.rb