cinch-basic_ctcp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +40 -0
  3. data/lib/cinch/plugins/basic_ctcp.rb +39 -0
  4. metadata +82 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Dominik Honnef
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Basic CTCP plugin
2
+
3
+ This plugin implements replies for the following CTCP commands:
4
+
5
+ - CLIENTINFO
6
+ - PING
7
+ - SOURCE
8
+ - TIME
9
+ - VERSION
10
+
11
+ ## Installation
12
+ First install the gem by running:
13
+ [sudo] gem install cinch-basic_ctcp
14
+
15
+ Then load it in your bot:
16
+ require "cinch"
17
+ require "cinch/plugins/basic_ctcp"
18
+
19
+ bot = Cinch::Bot.new do
20
+ configure do |c|
21
+ # add all required options here
22
+ c.plugins.plugins = [Cinch::Plugins::BasicCTCP] # optionally add more plugins
23
+ end
24
+ end
25
+
26
+ bot.start
27
+
28
+ ## Commands
29
+ None.
30
+
31
+ ## Options
32
+ ### :commands
33
+ If this option is set, the plugin will only reply to commands which
34
+ are listed in this option.
35
+
36
+ ### Example configuration
37
+ configure do |c|
38
+ # only reply to VERSION and TIME
39
+ c.plugins.options[Cinch::Plugins::BasicCTCP][:commands] = [:version, :time]
40
+ end
@@ -0,0 +1,39 @@
1
+ require "time"
2
+
3
+ module Cinch
4
+ module Plugins
5
+ class BasicCTCP
6
+ include Cinch::Plugin
7
+
8
+ ctcp :version
9
+ ctcp :time
10
+ ctcp :ping
11
+ ctcp :source
12
+ ctcp :clientinfo
13
+ def ctcp_version(m)
14
+ m.ctcp_reply "Cinch v#{Cinch::VERSION}" if reply_to_ctcp?(:version)
15
+ end
16
+
17
+ def ctcp_time(m)
18
+ m.ctcp_reply Time.now.strftime("%a %b %d %H:%M:%S %Z %Y") if reply_to_ctcp?(:time)
19
+ end
20
+
21
+ def ctcp_ping(m)
22
+ m.ctcp_reply m.ctcp_args.join(" ") if reply_to_ctcp?(:ping)
23
+ end
24
+
25
+ def ctcp_source(m)
26
+ m.ctcp_reply "http://github.com/cinchrb/cinch" if reply_to_ctcp?(:source)
27
+ end
28
+
29
+ def ctcp_clientinfo(m)
30
+ m.ctcp_reply "ACTION PING VERSION TIME CLIENTINFO SOURCE" if reply_to_ctcp?(:clientinfo)
31
+ end
32
+
33
+ def reply_to_ctcp?(command)
34
+ commands = config[:commands]
35
+ commands.nil? || commands.include?(command)
36
+ end
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-basic_ctcp
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Dominik Honnef
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-30 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cinch
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 0
31
+ version: "1.0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Implement the most important CTCP replies for Cinch bots
35
+ email:
36
+ - dominikh@fork-bomb.org
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - LICENSE
45
+ - README.md
46
+ - lib/cinch/plugins/basic_ctcp.rb
47
+ has_rdoc: true
48
+ homepage: http://rubydoc.info/github/cinchrb/cinch-basic_ctcp
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 1
63
+ - 9
64
+ - 1
65
+ version: 1.9.1
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.7
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Implement the most important CTCP replies for Cinch bots
81
+ test_files: []
82
+