zmb 0.1.1 → 0.1.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/zmb.rb CHANGED
@@ -94,7 +94,7 @@ class Zmb
94
94
 
95
95
  def timeout
96
96
  if timer_timeout > @maximum_timeout
97
- if @sockets.count < 1 then
97
+ if @sockets.size < 1 then
98
98
  5
99
99
  else
100
100
  @maximum_timeout
@@ -115,6 +115,7 @@ class IrcConnection
115
115
  'join' => PermCommand.new('admin', self, :join_command),
116
116
  'part' => PermCommand.new('admin', self, :part_command),
117
117
  'raw' => PermCommand.new('admin', self, :raw_command),
118
+ 'nick' => PermCommand.new('admin', self, :nick_command),
118
119
  'tell' => PermCommand.new('admin', self, :tell_command, 2),
119
120
  }
120
121
  end
@@ -211,6 +212,11 @@ class IrcConnection
211
212
  nil
212
213
  end
213
214
 
215
+ def nick_command(e, nick)
216
+ write "NICK #{nick}"
217
+ "Nick changed to #{nick}"
218
+ end
219
+
214
220
  def tell_command(e, to, message)
215
221
  msg = msg.split("\n") if not msg.respond_to?('each')
216
222
  msg.each{ |m| message(to, m) }
@@ -0,0 +1,42 @@
1
+ class NickServ
2
+ def initialize(sender, settings)
3
+ @password = settings['password'] if settings.has_key?('password')
4
+ end
5
+
6
+ def to_json(*a)
7
+ { 'plugin' => 'nickserv', 'password' => @password }.to_json(*a)
8
+ end
9
+
10
+ def self.wizard
11
+ {
12
+ 'password' => { 'help' => 'Password to authenticate with NickServ.', 'default' => nil },
13
+ }
14
+ end
15
+
16
+ def event(sender, e)
17
+ e.delegate.message('NickServ', "IDENTIFY #{@password}") if e.command == '001' and @password
18
+ end
19
+
20
+ def commands
21
+ require 'zmb/commands'
22
+ {
23
+ 'nickserv' => PermCommand.new('admin', self, :set, 1, 'Set your NickServ password.'),
24
+ }
25
+ end
26
+
27
+ def set(e, password=nil)
28
+ if password then
29
+ @password = password
30
+ "Password set to #{@password}"
31
+ else
32
+ @password = nil
33
+ "Password unset."
34
+ end
35
+ end
36
+ end
37
+
38
+ Plugin.define do
39
+ name "nickserv"
40
+ description "Authenticates the zmb bot with NickServ."
41
+ object NickServ
42
+ end
@@ -0,0 +1,29 @@
1
+ class System
2
+ def initialize(sender, settings) ;end
3
+
4
+ def to_json(*a)
5
+ { 'plugin' => 'system' }.to_json(*a)
6
+ end
7
+
8
+ def commands
9
+ require 'zmb/commands'
10
+ {
11
+ 'uptime' => Command.new(self, :uptime, 0, 'Server uptime'),
12
+ 'date' => Command.new(self, :date, 0, 'Display the server date/time'),
13
+ }
14
+ end
15
+
16
+ def uptime(e)
17
+ `uptime`.chomp
18
+ end
19
+
20
+ def date(e)
21
+ "#{Time.now}"
22
+ end
23
+ end
24
+
25
+ Plugin.define do
26
+ name "system"
27
+ description "System infomation (uptime, date)"
28
+ object System
29
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zmb}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kylef"]
12
- s.date = %q{2010-02-24}
12
+ s.date = %q{2010-02-28}
13
13
  s.default_executable = %q{zmb}
14
14
  s.description = %q{ZMB, messenger bot}
15
15
  s.email = %q{inbox@kylefuller.co.uk}
@@ -35,8 +35,10 @@ Gem::Specification.new do |s|
35
35
  "plugins/bank.rb",
36
36
  "plugins/commands.rb",
37
37
  "plugins/irc.rb",
38
+ "plugins/nickserv.rb",
38
39
  "plugins/quote.rb",
39
40
  "plugins/relay.rb",
41
+ "plugins/system.rb",
40
42
  "plugins/users.rb",
41
43
  "test/helper.rb",
42
44
  "test/test_zmb.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zmb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kylef
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-24 00:00:00 +00:00
12
+ date: 2010-02-28 00:00:00 +00:00
13
13
  default_executable: zmb
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -58,8 +58,10 @@ files:
58
58
  - plugins/bank.rb
59
59
  - plugins/commands.rb
60
60
  - plugins/irc.rb
61
+ - plugins/nickserv.rb
61
62
  - plugins/quote.rb
62
63
  - plugins/relay.rb
64
+ - plugins/system.rb
63
65
  - plugins/users.rb
64
66
  - test/helper.rb
65
67
  - test/test_zmb.rb