kittybot 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/kittybot +29 -0
  2. data/plugins/echo.rb +7 -0
  3. data/plugins/logger.rb +16 -0
  4. data/plugins.rb +30 -0
  5. metadata +61 -0
data/kittybot ADDED
@@ -0,0 +1,29 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'cinch'
4
+
5
+ require './plugins'
6
+
7
+ $bot = Cinch::Bot.new do
8
+ configure do |c|
9
+ c.server = 'irc.freenode.net'
10
+ c.user = 'kittybot'
11
+ c.nick = 'KittyBot'
12
+ c.realname = 'The Kitty Bot, of course!'
13
+ c.channels = ['#kittybot', '#elementary-web']
14
+ c.plugins.plugins = $plugins
15
+ end
16
+
17
+ on :private, /!say #(\S+) (.+)/i do |m, channel_name, what_to_say|
18
+ if m.user.nick == 'davidboy'
19
+ $bot.channels.each do |c|
20
+ if c.name == "##{channel_name}"
21
+ c.msg what_to_say
22
+ puts 'nice'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ $bot.start
data/plugins/echo.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'cinch'
2
+
3
+ class Echo
4
+ include Cinch::Plugin
5
+
6
+
7
+ end
data/plugins/logger.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'cinch'
2
+
3
+ class Logger
4
+ include Cinch::Plugin
5
+ listen_to :message
6
+
7
+ def initialize *args
8
+ super
9
+ end
10
+
11
+ def listen m
12
+ File.open('logs', 'a') do |file|
13
+ file.puts "#{m.user.nick}: #{m.message}"
14
+ end
15
+ end
16
+ end
data/plugins.rb ADDED
@@ -0,0 +1,30 @@
1
+ # Two little methods we'll need, lifted from activesupport (thanks guys! :D)
2
+ def constantize(camel_cased_word)
3
+ names = camel_cased_word.split('::')
4
+ names.shift if names.empty? || names.first.empty?
5
+
6
+ constant = Object
7
+ names.each do |name|
8
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
9
+ end
10
+ constant
11
+ end
12
+
13
+ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
14
+ if first_letter_in_uppercase
15
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
16
+ else
17
+ lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
18
+ end
19
+ end
20
+
21
+
22
+ $plugins = []
23
+
24
+ Dir.glob('plugins/*.rb').each do |plugin|
25
+ require './' + plugin
26
+ $plugins << constantize(camelize(plugin.split('/')[1].split('.')[0]))
27
+ end
28
+
29
+
30
+
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kittybot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Reed
9
+ autorequire:
10
+ bindir: .
11
+ cert_chain: []
12
+ date: 2011-08-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cinch
16
+ requirement: &12985740 !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: *12985740
25
+ description: SOO ANOYING!
26
+ email: dboyreed@charter.net
27
+ executables:
28
+ - kittybot
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - kittybot
33
+ - plugins.rb
34
+ - plugins/logger.rb
35
+ - plugins/echo.rb
36
+ - ./kittybot
37
+ homepage: ''
38
+ licenses: []
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 1.8.8
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: The world-famous kittybot
61
+ test_files: []