cinch-yaml-memo 1.0.0
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/LICENSE +14 -0
- data/README.md +3 -0
- data/lib/cinch/plugins/yamlmemo.rb +67 -0
- metadata +68 -0
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2012 Peter Aronoff, Michal Papis
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# source: https://github.com/telemachus/antinoos/blob/master/memo.rb
|
2
|
+
# license: https://github.com/telemachus/antinoos/blob/master/LICENSE
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Cinch
|
7
|
+
module Plugins
|
8
|
+
class YamlMemo
|
9
|
+
include Cinch::Plugin
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
super
|
13
|
+
if File.exist?('memos.yaml')
|
14
|
+
@memos = YAML.load_file('memos.yaml')
|
15
|
+
else
|
16
|
+
@memos = {}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
listen_to :message
|
21
|
+
match /memo (.+?) (.+)/
|
22
|
+
|
23
|
+
def listen(m)
|
24
|
+
if @memos.key?(m.user.nick) and @memos[m.user.nick].size > 0
|
25
|
+
while @memos[m.user.nick].size > 0
|
26
|
+
msg = @memos[m.user.nick].shift
|
27
|
+
m.reply msg
|
28
|
+
end
|
29
|
+
@memos.delete m.user.nick
|
30
|
+
update_store
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute(m, nick, message)
|
35
|
+
if nick == m.user.nick
|
36
|
+
m.reply "You can't leave memos for yourself..."
|
37
|
+
elsif nick == bot.nick
|
38
|
+
m.reply "You can't leave memos for me..."
|
39
|
+
elsif @memos.key?(nick)
|
40
|
+
msg = make_msg(m.user.nick, m.channel, message, Time.now)
|
41
|
+
@memos[nick] << msg
|
42
|
+
m.reply "Added memo for #{nick}"
|
43
|
+
update_store
|
44
|
+
else
|
45
|
+
@memos[nick] ||= []
|
46
|
+
msg = make_msg(m.user.nick, m.channel, message, Time.now)
|
47
|
+
@memos[nick] << msg
|
48
|
+
m.reply "Added memo for #{nick}"
|
49
|
+
update_store
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def update_store
|
54
|
+
synchronize(:update) do
|
55
|
+
File.open('memos.yaml', 'w') do |fh|
|
56
|
+
YAML.dump(@memos, fh)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def make_msg(nick, channel, text, time)
|
62
|
+
t = time.strftime("%Y-%m-%d")
|
63
|
+
"<#{nick}/#{channel}/#{t}> #{text}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-yaml-memo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michal Papis
|
9
|
+
- Peter Aronoff
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-06-26 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: cinch
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '2'
|
31
|
+
description: A Cinch plugin to store and replay messages, messages are saved in yaml
|
32
|
+
file for persistence.
|
33
|
+
email:
|
34
|
+
- mpapis@gmail.com
|
35
|
+
- telemachus@arpinum.org
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- lib/cinch/plugins/yamlmemo.rb
|
43
|
+
homepage: https://github.com/mpapis/yaml-memo
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.9.1
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.24
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: A Cinch plugin to store and replay messages, messages are saved in yaml file
|
67
|
+
for persistence.
|
68
|
+
test_files: []
|