cinch-yaml-keywords 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,49 @@
1
1
  # Cinch YAML keywords plugin
2
2
 
3
3
  A Cinch plugin to define keywords and display description when keyword matches, keywords are saved in yaml file for persistence.
4
+
5
+ ## Installation
6
+
7
+ First install the gem by running:
8
+
9
+ ```bash
10
+ gem install cinch-yaml-keywords
11
+ ```
12
+
13
+ Then load it in your bot:
14
+
15
+ ```ruby
16
+ require "cinch"
17
+ require "cinch/plugins/yamlkeywords"
18
+
19
+ bot = Cinch::Bot.new do
20
+ configure do |c|
21
+ c.plugins.plugins = [Cinch::Plugins::YamlKeywords]
22
+ end
23
+ end
24
+
25
+ bot.start
26
+ ```
27
+
28
+ ## Commands
29
+
30
+ ```irc
31
+ !keywords # list all definitions
32
+ !keyword <keyword> # show single definition
33
+ !keyword <keyword> <definition> # define without spaces
34
+ !keyword '<keyword>' <definition> # define with spaces
35
+ !keyword "<keyword>" <definition> # define with spaces
36
+ !forget <keyword> # remove definition
37
+ <keyword> # display definition
38
+ ```
39
+
40
+ ## Example
41
+
42
+ <mpapis>: !keyword 'gist it' Please use https://gist.github.com for anything longer then 2 lines of text.
43
+ <user8549586> I get error 4838948: fkjfdlg
44
+ <mpapis>: gist it all so I can see the context
45
+ <smfbot>: Please use https://gist.github.com for anything longer then 2 lines of text.
46
+
47
+ ## Development
48
+
49
+ Run the `./test-run.sh` script to play with results of your changes in channel listed in `example/config.yaml`
@@ -25,9 +25,9 @@ module Cinch
25
25
  end
26
26
  end
27
27
 
28
- match(/keyword (\S+) (.+)$/, method: :keyword_define)
29
- match(/keyword '(.*)' (.+)$/, method: :keyword_define)
30
- match(/keyword "(.*)" (.+)$/, method: :keyword_define)
28
+ match(/keyword '(.*)' (.+)$/, group: :define, method: :keyword_define)
29
+ match(/keyword "(.*)" (.+)$/, group: :define, method: :keyword_define)
30
+ match(/keyword (\S+) (.+)$/, group: :define, method: :keyword_define)
31
31
  def keyword_define(m, keyword, definition)
32
32
  if @keywords[keyword]
33
33
  m.reply "Redefining '#{keyword}' from: '#{@keywords[keyword]}' to: '#{definition}'."
@@ -47,6 +47,17 @@ module Cinch
47
47
  end
48
48
  end
49
49
 
50
+ match(/forget (\S+)$/, method: :keyword_forget)
51
+ def keyword_forget(m, keyword)
52
+ if @keywords[keyword]
53
+ m.reply "'#{keyword}' was defined as: '#{@keywords[keyword]}'."
54
+ @keywords.delete(keyword)
55
+ update_store
56
+ else
57
+ m.reply "'#{keyword}' is not defined."
58
+ end
59
+ end
60
+
50
61
  listen_to :channel
51
62
  def listen(m)
52
63
  if keyword = @keywords.keys.find{|k| Regexp.new(k).match(m.message) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-yaml-keywords
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
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: 2012-06-27 00:00:00.000000000 Z
12
+ date: 2012-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cinch