cinch 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,7 +47,6 @@ require "cinch/configuration/bot"
47
47
  require "cinch/configuration/plugins"
48
48
  require "cinch/configuration/ssl"
49
49
  require "cinch/configuration/timeouts"
50
- # require "cinch/configuration/storage"
51
50
  require "cinch/configuration/dcc"
52
51
  require "cinch/configuration/sasl"
53
52
 
@@ -292,13 +291,6 @@ module Cinch
292
291
  end while @config.reconnect and not @quitting
293
292
  end
294
293
 
295
- def stop
296
- # @plugins.each do |plugin|
297
- # plugin.storage.save
298
- # plugin.storage.unload
299
- # end
300
- end
301
-
302
294
  # @endgroup
303
295
  # @group Channel Control
304
296
 
@@ -37,7 +37,6 @@ module Cinch
37
37
  :timeouts => Configuration::Timeouts.new,
38
38
  :ping_interval => 120,
39
39
  :delay_joins => 0,
40
- # :storage => Configuration::Storage.new,
41
40
  :dcc => Configuration::DCC.new,
42
41
  :sasl => Configuration::SASL.new,
43
42
  :shared => {},
@@ -383,7 +383,7 @@ module Cinch
383
383
  else
384
384
  send_cap_end
385
385
  end
386
- when "NACK"
386
+ when "NAK"
387
387
  send_cap_end
388
388
  end
389
389
  end
@@ -432,15 +432,11 @@ module Cinch
432
432
  # @return [Array<Cinch::Timer>]
433
433
  attr_reader :timers
434
434
 
435
- # @return [Storage] The per-plugin persistent storage
436
- # attr_reader :storage
437
-
438
435
  # @api private
439
436
  def initialize(bot)
440
437
  @bot = bot
441
438
  @handlers = []
442
439
  @timers = []
443
- # @storage = bot.config.storage.backend.new(@bot.config.storage, self)
444
440
  __register
445
441
  end
446
442
 
@@ -1,4 +1,4 @@
1
1
  module Cinch
2
2
  # Version of the library
3
- VERSION = '2.0.7'
3
+ VERSION = '2.0.8'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-29 00:00:00.000000000 Z
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple, friendly DSL for creating IRC bots
15
15
  email:
@@ -43,7 +43,6 @@ files:
43
43
  - lib/cinch/sasl.rb
44
44
  - lib/cinch/cached_list.rb
45
45
  - lib/cinch/bot.rb
46
- - lib/cinch/storage.rb
47
46
  - lib/cinch/isupport.rb
48
47
  - lib/cinch/helpers.rb
49
48
  - lib/cinch/handler.rb
@@ -58,7 +57,6 @@ files:
58
57
  - lib/cinch/mask.rb
59
58
  - lib/cinch/configuration/sasl.rb
60
59
  - lib/cinch/configuration/bot.rb
61
- - lib/cinch/configuration/storage.rb
62
60
  - lib/cinch/configuration/plugins.rb
63
61
  - lib/cinch/configuration/ssl.rb
64
62
  - lib/cinch/configuration/dcc.rb
@@ -76,8 +74,6 @@ files:
76
74
  - lib/cinch/constants.rb
77
75
  - lib/cinch/mode_parser.rb
78
76
  - lib/cinch/user.rb
79
- - lib/cinch/storage/yaml.rb
80
- - lib/cinch/storage/null.rb
81
77
  - lib/cinch/logger/formatted_logger.rb
82
78
  - lib/cinch/logger/zcbot_logger.rb
83
79
  - lib/cinch/exceptions.rb
@@ -104,7 +100,6 @@ files:
104
100
  - examples/plugins/autovoice.rb
105
101
  - examples/plugins/multiple_matches.rb
106
102
  - examples/plugins/url_shorten.rb
107
- - examples/plugins/memo.rb
108
103
  - examples/plugins/own_events.rb
109
104
  - examples/plugins/seen.rb
110
105
  - examples/plugins/last_nick.rb
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'cinch'
4
- require 'cinch/storage/yaml'
5
-
6
- class Memo
7
- class MemoStruct < Struct.new(:user, :channel, :text, :time)
8
- def to_s
9
- "[#{time.asctime}] <#{channel}/#{user}> #{text}"
10
- end
11
- end
12
-
13
- include Cinch::Plugin
14
-
15
- def initialize(*args)
16
- super
17
- storage[:memos] ||= {}
18
- end
19
-
20
- listen_to :message
21
- match /memo (.+?) (.+)/
22
-
23
- def listen(m)
24
- if storage[:memos].has_key?(m.user.nick)
25
- m.user.send storage[:memos].delete(m.user.nick).to_s
26
- storage.save
27
- end
28
- end
29
-
30
- def execute(m, nick, message)
31
- if storage[:memos].key?(nick)
32
- m.reply "There's already a memo for #{nick}. You can only store one right now"
33
- elsif nick == m.user.nick
34
- m.reply "You can't leave memos for yourself.."
35
- elsif nick == bot.nick
36
- m.reply "You can't leave memos for me.."
37
- else
38
- storage[:memos][nick] = MemoStruct.new(m.user.name, m.channel.name, message, Time.now)
39
- storage.save
40
- m.reply "Added memo for #{nick}"
41
- end
42
- end
43
- end
44
-
45
- bot = Cinch::Bot.new do
46
- configure do |c|
47
- c.server = "irc.freenode.org"
48
- c.channels = ["#cinch-bots"]
49
- c.plugins.plugins = [Memo]
50
- c.storage.backend = Cinch::Storage::YAML
51
- c.storage.basedir = "./yaml/"
52
- c.storage.autosave = true
53
- end
54
- end
55
-
56
- bot.start
@@ -1,31 +0,0 @@
1
- require "cinch/configuration"
2
- require "cinch/storage/null"
3
-
4
- module Cinch
5
- class Configuration
6
- # @since 2.0.0
7
- class Storage < Configuration
8
- KnownOptions = [:backend]
9
-
10
- def self.default_config
11
- {
12
- :backend => Cinch::Storage::Null
13
- }
14
- end
15
-
16
- def load(new_config, from_default)
17
- _new_config = {}
18
- new_config.each do |option, value|
19
- case option
20
- when :backend
21
- _new_config[option] = Cinch::Utilities::Kernel.string_to_const(value)
22
- else
23
- _new_config[option] = value
24
- end
25
- end
26
-
27
- super(_new_config, from_default)
28
- end
29
- end
30
- end
31
- end
@@ -1,63 +0,0 @@
1
- module Cinch
2
- # @note The interface of this class isn't fixed yet. You shouldn't
3
- # use it yet.
4
- class Storage
5
- include Enumerable
6
-
7
- # @param [Hash] options
8
- # @param [Plugin] plugin
9
- def initialize(options, plugin)
10
- end
11
-
12
- # @param [Object] key
13
- # @return [Object, nil]
14
- def [](key)
15
- end
16
-
17
- # @param [Object] key
18
- # @param [Object] value
19
- # @return [value]
20
- def []=(key, value)
21
- end
22
-
23
- # @return [self]
24
- def each
25
- self
26
- end
27
-
28
- # @return [self]
29
- def each_key
30
- self
31
- end
32
-
33
- # @return [self]
34
- def each_value
35
- self
36
- end
37
-
38
- # @param [Object] key
39
- # @return [Boolean]
40
- def has_key?(key)
41
- false
42
- end
43
- alias_method :include?, :has_key?
44
- alias_method :key?, :has_key?
45
- alias_method :member?, :has_key?
46
-
47
- # @param [Object] key
48
- # @return [Object, nil] The deleted object
49
- def delete(key)
50
- end
51
-
52
- # @return [self]
53
- def delete_if
54
- self
55
- end
56
-
57
- def save
58
- end
59
-
60
- def unload
61
- end
62
- end
63
- end
@@ -1,12 +0,0 @@
1
- require "cinch/storage"
2
-
3
- module Cinch
4
- class Storage
5
- # The Null storage is the default storage (used if the user didn't
6
- # supply a different storage) and will simply ignore all requests.
7
- # This way, plugins will continue to work if programmed properly,
8
- # but no data will be preserved.
9
- class Null < Storage
10
- end
11
- end
12
- end
@@ -1,96 +0,0 @@
1
- require "cinch/storage"
2
- require "yaml"
3
-
4
- module Cinch
5
- class Storage
6
- # A basic storage backed by YAML, using one file per plugin.
7
- class YAML < Storage
8
- # (see Storage#initialize)
9
- def initialize(options, plugin)
10
- # We are a basic example, so we load everything into memory. yey.
11
- @file = options.basedir + plugin.class.plugin_name + ".yaml"
12
- if File.exist?(@file)
13
- @yaml = ::YAML.load_file(@file) || {}
14
- else
15
- @yaml = {}
16
- end
17
- @options = options
18
-
19
- @mutex = Mutex.new
20
- end
21
-
22
- # (see Storage#[])
23
- def [](key)
24
- @yaml[key]
25
- end
26
-
27
- # (see Strage#[]=)
28
- def []=(key, value)
29
- @yaml[key] = value
30
- end
31
-
32
- # (see Storage#has_key?)
33
- def has_key?(key)
34
- @yaml.has_key?(key)
35
- end
36
- alias_method :include?, :has_key?
37
- alias_method :key?, :has_key?
38
- alias_method :member?, :has_key?
39
-
40
- # (see Storage#each)
41
- def each
42
- @yaml.each {|e| yield(e)}
43
-
44
- self
45
- end
46
-
47
- # (see Storage#each_key)
48
- def each_key
49
- @yaml.each_key {|e| yield(e)}
50
-
51
- self
52
- end
53
-
54
- # (see Storage#each_value)
55
- def each_value
56
- @yaml.each_value {|e| yield(e)}
57
-
58
- self
59
- end
60
-
61
- # (see Storage#delete)
62
- def delete(key)
63
- obj = @yaml.delete(key)
64
-
65
- obj
66
- end
67
-
68
- # (see Storage#delete_if)
69
- def delete_if
70
- delete_keys = []
71
- each do |key, value|
72
- delete_keys << key if yield(key, value)
73
- end
74
-
75
- delete_keys.each do |key|
76
- delete(key)
77
- end
78
-
79
- self
80
- end
81
-
82
- # (see Storage#save)
83
- def save
84
- @mutex.synchronize do
85
- File.open(@file, "w") do |f|
86
- f.write @yaml.to_yaml
87
- end
88
- end
89
- end
90
-
91
- # (see Storage#unload)
92
- def unload
93
- end
94
- end
95
- end
96
- end