cinch-tinychat 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.rdoc +41 -0
- data/lib/cinch/plugins/tiny_chat.rb +51 -0
- metadata +83 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Richard Banks
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
### Authors
|
2
|
+
@doubledave
|
3
|
+
@Namasteh
|
4
|
+
|
5
|
+
### Files
|
6
|
+
tiny_chat.rb
|
7
|
+
|
8
|
+
### Dependencies
|
9
|
+
* [Cinch](http://rubygems.org/gems/cinch)
|
10
|
+
* OpenURI
|
11
|
+
* [Nokogiri](http://rubygems.org/gems/nokogiri)
|
12
|
+
* CGI
|
13
|
+
|
14
|
+
### Description
|
15
|
+
The _TinyChat_ gem (created for the Cinch IRC Bot Framework) is used to parse an XML API from apigee.com for TinyChat the browser chat client. Using it's commands you can have essential information of a TinyChat room returned to the channel.
|
16
|
+
|
17
|
+
### Installation
|
18
|
+
To install the gem:
|
19
|
+
|
20
|
+
> gem install cinch-tinychat
|
21
|
+
|
22
|
+
### Configuration
|
23
|
+
Firstly, the _TinyChat_ gem does not need an API key as it simply parses VML data from a link delivered through the bot.
|
24
|
+
|
25
|
+
Secondly, in order for this plugin to work you **must** load it into the bot. In most Cinch IRC bot formats you will do the following:
|
26
|
+
|
27
|
+
At the top of bot.rb put this line:
|
28
|
+
```ruby
|
29
|
+
require 'cinch-tinychat'
|
30
|
+
```
|
31
|
+
|
32
|
+
In the c.plugins section of bot.rb insert this:
|
33
|
+
```ruby
|
34
|
+
[Cinch::Plugins::TinyChat]
|
35
|
+
```
|
36
|
+
|
37
|
+
### Usage
|
38
|
+
|
39
|
+
The TinyChat plugin will query the room you ask it to and return with information on it.
|
40
|
+
|
41
|
+
* !(tinychat|tc) \<room\>: The bot will return with room information.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'cinch'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
module Cinch
|
7
|
+
module Plugins
|
8
|
+
class TinyChat
|
9
|
+
include Cinch::Plugin
|
10
|
+
|
11
|
+
set :plugin_name, 'tinychat'
|
12
|
+
set :help, <<-USAGE.gsub(/^ {6}/, '')
|
13
|
+
The TinyChat plugin will query the room you ask it to and return with information on it.
|
14
|
+
* !(tinychat|tc) <room>: The bot will return with room information.
|
15
|
+
USAGE
|
16
|
+
|
17
|
+
match /tinychat (.+)/
|
18
|
+
match /tc (.+)/
|
19
|
+
|
20
|
+
def execute(m, room)
|
21
|
+
tcLogo = "0,12TinyChat"
|
22
|
+
query = URI::encode(room)
|
23
|
+
doc = Nokogiri::XML(open("http://tinychat.apigee.com/#{query}.xml").read)
|
24
|
+
|
25
|
+
online = doc.css("names").collect{|j| j.inner_text}.join(', ')
|
26
|
+
onlineCount = doc.root["total_count"]
|
27
|
+
roomName = doc.root["name"]
|
28
|
+
|
29
|
+
url = "http://tinychat.com/#{roomName}"
|
30
|
+
|
31
|
+
onlineCount = onlineCount.to_i
|
32
|
+
|
33
|
+
if doc.root["message"]
|
34
|
+
begin
|
35
|
+
eMessage = doc.root["message"]
|
36
|
+
raise "Error: #{eMessage}"
|
37
|
+
rescue
|
38
|
+
m.reply "#{tcLogo} || I have been given an error of: \"#{$!}\"! Please contact my master."
|
39
|
+
end
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
m.reply "There's #{onlineCount} user in #{roomName}. | User: #{online} | #{tcLogo} URL: #{url}" if onlineCount == 1
|
44
|
+
|
45
|
+
m.reply "There's #{onlineCount} users in #{roomName}. | Users: #{online} | #{tcLogo} URL: #{url}" if onlineCount >= 2
|
46
|
+
|
47
|
+
m.reply "There are no users in #{roomName}. | #{tcLogo} URL: #{url}" if onlineCount == 0
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-tinychat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Richard Banks
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cinch
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nokogiri
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: The TinyChat plugin will query the room you ask it to and return with
|
47
|
+
information on it.
|
48
|
+
email: namaste@rawrnet.net
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- LICENSE
|
56
|
+
- README.rdoc
|
57
|
+
- lib/cinch/plugins/tiny_chat.rb
|
58
|
+
homepage: http://github.com/namasteh/cinch-tinychat
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.23
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: The TinyChat plugin will query the room you ask it to and return with information
|
82
|
+
on it.
|
83
|
+
test_files: []
|