pandorabots 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -0
- data/lib/pandorabots.rb +42 -0
- metadata +59 -0
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
A simple ruby api for http://www.pandorabots.com/
|
2
|
+
See http://www.pandorabots.com/botmaster/en/faq#h2 for api info
|
3
|
+
|
4
|
+
Usage (eventually):
|
5
|
+
|
6
|
+
require "rubygems"
|
7
|
+
require "pandorabots"
|
8
|
+
|
9
|
+
response = Pandorabots.talk(bot_id, input, cust_id)
|
10
|
+
|
11
|
+
if (response[:success])
|
12
|
+
bot_id = response[:bot_id]
|
13
|
+
cust_id = response[:cust_id]
|
14
|
+
input = response[:input]
|
15
|
+
ouput = response[:ouput]
|
16
|
+
else
|
17
|
+
error_message = response[:output]
|
18
|
+
end
|
data/lib/pandorabots.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require 'net/http'
|
3
|
+
require "xmlsimple"
|
4
|
+
|
5
|
+
module Pandorabots
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
PANDORABOTS_URL = "http://www.pandorabots.com/pandora/talk-xml"
|
8
|
+
|
9
|
+
#talk to a pandora bot
|
10
|
+
def self.talk(bot_id, input, cust_id=nil)
|
11
|
+
uri = URI.parse(PANDORABOTS_URL)
|
12
|
+
params = {"botid" => bot_id, "input" => input}
|
13
|
+
if cust_id
|
14
|
+
params['custid'] = cust_id
|
15
|
+
end
|
16
|
+
response = Net::HTTP.post_form(uri, params)
|
17
|
+
|
18
|
+
if (response && response.code.to_i >= 200 && response.code.to_i < 300)
|
19
|
+
hash = XmlSimple.xml_in(response.body)
|
20
|
+
if hash["status"].to_i == 0
|
21
|
+
result = {
|
22
|
+
:success => true,
|
23
|
+
:bot_id => hash["botid"],
|
24
|
+
:cust_id => hash["custid"],
|
25
|
+
:input => hash["input"][0],
|
26
|
+
:output => hash["that"][0]}
|
27
|
+
return result
|
28
|
+
else
|
29
|
+
result = {
|
30
|
+
:success => false,
|
31
|
+
:bot_id => hash["botid"],
|
32
|
+
:cust_id => hash["custid"],
|
33
|
+
:input => hash["input"][0],
|
34
|
+
:output => hash["message"][0]}
|
35
|
+
return result
|
36
|
+
end
|
37
|
+
else
|
38
|
+
p response.body
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pandorabots
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Geoff Hackett
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: xml-simple
|
16
|
+
requirement: &70282925586100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70282925586100
|
25
|
+
description: just use Pandorabots.talk(bot_id, input, cust_id). See http://www.pandorabots.com/botmaster/en/faq#h2
|
26
|
+
for more info on api
|
27
|
+
email:
|
28
|
+
- ghackett@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/pandorabots.rb
|
34
|
+
- README.md
|
35
|
+
homepage: http://github.com/ghackett/pandorabots-gem
|
36
|
+
licenses: []
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.3.6
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.8.10
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: Simple Api for http://pandorabots.com
|
59
|
+
test_files: []
|