Class: Cinch::Plugins::EnCinch
- Inherits:
-
Object
- Object
- Cinch::Plugins::EnCinch
show all
- Includes:
- Cinch::Plugin
- Defined in:
- lib/cinch/plugins/encinch/encinch.rb,
lib/cinch/plugins/encinch/storage.rb,
lib/cinch/plugins/encinch/version.rb,
lib/cinch/plugins/encinch/encryption.rb
Defined Under Namespace
Classes: Encryption, Storage
Constant Summary
collapse
- VERSION =
"0.1.6"
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EnCinch.
7
8
9
10
11
12
13
14
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 7
def initialize(*)
super
config[:uncrypted] ||= Array.new
config[:ignore] ||= Array.new
config[:encrypt] ||= Hash.new
shared[:encinch] = EnCinch::Storage.new(bot, config.dup)
end
|
Instance Method Details
#blowfish(key) ⇒ Object
65
66
67
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 65
def blowfish(key)
@fish = Encryption.new(key)
end
|
#capture(m, message) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 22
def capture(m, message)
target = (m.channel? ? m.channel.name : m.user.nick).downcase
options = shared[:encinch].storage.data
return if options[:ignore].include?(target)
return unless key = options[:encrypt][target] || options[:encrypt][:default]
blowfish(key)
message = strip(message)
decrypted = decrypt(message)
@fish = nil
decrypted << '\u0001' if m.action?
raw = modify_raw(m.raw, decrypted)
dispatch(Message.new(raw, m.bot))
end
|
#decrypt(message) ⇒ Object
61
62
63
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 61
def decrypt(message)
@fish.decrypt(message)
end
|
#encrypt(message) ⇒ Object
57
58
59
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 57
def encrypt(message)
@fish.encrypt(message)
end
|
#encrypted?(data) ⇒ Boolean
69
70
71
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 69
def encrypted?(data)
!!data.match(/\+OK \S+/)
end
|
#key_exchange(m, key, cbc = false) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/cinch/plugins/encinch/encinch.rb', line 49
def key_exchange(m, key, cbc = false)
return if m.channel?
debug "captured key exchange event with key: #{m.message}"
end
|