cogbot 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed9500a2174f92bcc12ab3cae3e2654a3607267a
4
- data.tar.gz: f45b95e057fb6c7610fe6093f9e473b7d138566f
3
+ metadata.gz: 436cb0282f50bde8d3f00070a739fb3fc6dd2b38
4
+ data.tar.gz: ce90f1cc3122c393d2a143aa809e1145a57a005f
5
5
  SHA512:
6
- metadata.gz: 8ce87667fc15508303457c29a78dee2070166f1373128737c1ec98b34a8fdae4829db43befe5b22fc5a380853aefa07921ea999fc71d1279e7e2e04a2f75c915
7
- data.tar.gz: 2e695e32ea44f41fa127fe5d24772b0dad73784779f928cc7a37ac35c1de9b7b7f9e3ca2d8be8ecbbc5b36a802bd04c312e980d01949f48b70139dc47532b909
6
+ metadata.gz: 5ef7a996b413f973187ebe10bae323b75a578bf4a7bf302a8c1936194f539296b66a4c93fb9656bfe36ab5c7c0056d0759207397c11112419bab14ae2ad131f2
7
+ data.tar.gz: bd833aba9ec78a958e74c413e3a93b3a232c64aa844d016055a0072d602803053db931469871b1774b7bce9a457e2cb7a00e11135e95136b16a42a3a6738bbc2
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ config/cogbot.yml
4
4
  vendor/
5
5
  *.swp
6
6
  *.swo
7
+ coverage/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 2.2.3
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Cogbot Changelog
2
2
  ===================
3
3
 
4
+ ### v0.1.3 - 2015-11-20
5
+ - add more listened actions on trello listener plugin
6
+ - update dependencies
7
+
4
8
  ### v0.1.2 - 2015-03-16
5
9
  - add link to status on twitter plugin search results
6
10
  - add age of status in twitter plugin
data/Gemfile.lock CHANGED
@@ -1,83 +1,93 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cogbot (0.1.2)
5
- cinch (= 2.2.4)
6
- daemons (~> 1.1.9)
7
- eventmachine (= 1.0.7)
4
+ cogbot (0.1.3)
5
+ cinch (= 2.3.1)
6
+ daemons (~> 1.2.3)
7
+ eventmachine (= 1.0.8)
8
8
  eventmachine_httpserver (~> 0.2.1)
9
9
  fortune_gem (~> 0.0.8)
10
- json (~> 1.8.2)
11
- nokogiri (~> 1.6.6)
10
+ json (~> 1.8.3)
11
+ nokogiri (~> 1.6.6.4)
12
12
  thor (~> 0.19.1)
13
- twitter (~> 5.13.0)
13
+ twitter (~> 5.15.0)
14
14
  yajl-ruby (~> 1.2.1)
15
15
 
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- addressable (2.3.7)
19
+ addressable (2.3.8)
20
20
  awesome_print (1.6.1)
21
21
  buftok (0.2.0)
22
- cinch (2.2.4)
22
+ cinch (2.3.1)
23
23
  coderay (1.1.0)
24
- daemons (1.1.9)
24
+ daemons (1.2.3)
25
25
  docile (1.1.5)
26
- equalizer (0.0.9)
27
- eventmachine (1.0.7)
26
+ domain_name (0.5.25)
27
+ unf (>= 0.0.5, < 1.0.0)
28
+ equalizer (0.0.10)
29
+ eventmachine (1.0.8)
28
30
  eventmachine_httpserver (0.2.1)
29
- faraday (0.9.1)
31
+ faraday (0.9.2)
30
32
  multipart-post (>= 1.2, < 3)
31
33
  flog (4.3.2)
32
34
  ruby_parser (~> 3.1, > 3.1.0)
33
35
  sexp_processor (~> 4.4)
34
36
  fortune_gem (0.0.8)
35
- http (0.6.3)
37
+ http (0.9.8)
38
+ addressable (~> 2.3)
39
+ http-cookie (~> 1.0)
40
+ http-form_data (~> 1.0.1)
36
41
  http_parser.rb (~> 0.6.0)
42
+ http-cookie (1.0.2)
43
+ domain_name (~> 0.5)
44
+ http-form_data (1.0.1)
37
45
  http_parser.rb (0.6.0)
38
- json (1.8.2)
46
+ json (1.8.3)
39
47
  memoizable (0.4.2)
40
48
  thread_safe (~> 0.3, >= 0.3.1)
41
49
  method_source (0.8.2)
42
50
  mini_portile (0.6.2)
43
- minitest (5.5.1)
51
+ minitest (5.8.2)
44
52
  minitest-ci (3.0.3)
45
53
  minitest (~> 5.0, >= 5.0.6)
46
- multi_json (1.10.1)
47
54
  multipart-post (2.0.0)
48
- naught (1.0.0)
49
- nokogiri (1.6.6.2)
55
+ naught (1.1.0)
56
+ nokogiri (1.6.6.4)
50
57
  mini_portile (~> 0.6.0)
51
- pry (0.10.1)
58
+ pry (0.10.3)
52
59
  coderay (~> 1.1.0)
53
60
  method_source (~> 0.8.1)
54
61
  slop (~> 3.4)
55
62
  rake (10.4.2)
56
- ruby_parser (3.6.4)
63
+ ruby_parser (3.7.2)
57
64
  sexp_processor (~> 4.1)
58
- sexp_processor (4.4.5)
65
+ sexp_processor (4.6.0)
59
66
  simple_oauth (0.3.1)
60
- simplecov (0.9.1)
67
+ simplecov (0.10.0)
61
68
  docile (~> 1.1.0)
62
- multi_json (~> 1.0)
63
- simplecov-html (~> 0.8.0)
64
- simplecov-html (0.8.0)
69
+ json (~> 1.8)
70
+ simplecov-html (~> 0.10.0)
71
+ simplecov-html (0.10.0)
65
72
  simplecov-rcov (0.2.3)
66
73
  simplecov (>= 0.4.1)
67
74
  slop (3.6.0)
68
75
  thor (0.19.1)
69
76
  thread_safe (0.3.5)
70
- twitter (5.13.0)
77
+ twitter (5.15.0)
71
78
  addressable (~> 2.3)
72
79
  buftok (~> 0.2.0)
73
- equalizer (~> 0.0.9)
80
+ equalizer (= 0.0.10)
74
81
  faraday (~> 0.9.0)
75
- http (~> 0.6.0)
82
+ http (>= 0.4, < 0.10)
76
83
  http_parser.rb (~> 0.6.0)
77
84
  json (~> 1.8)
78
85
  memoizable (~> 0.4.0)
79
86
  naught (~> 1.0)
80
87
  simple_oauth (~> 0.3.0)
88
+ unf (0.1.4)
89
+ unf_ext
90
+ unf_ext (0.0.7.1)
81
91
  yajl-ruby (1.2.1)
82
92
 
83
93
  PLATFORMS
@@ -93,3 +103,6 @@ DEPENDENCIES
93
103
  rake
94
104
  simplecov
95
105
  simplecov-rcov
106
+
107
+ BUNDLED WITH
108
+ 1.10.6
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Downloads](http://img.shields.io/gem/dt/cogbot.svg)](https://rubygems.org/gems/cogbot)
5
5
  [![Dependency Status](https://img.shields.io/gemnasium/mose/cogbot.svg)](https://gemnasium.com/mose/cogbot)
6
6
  [![Code Climate](http://img.shields.io/codeclimate/github/mose/cogbot.svg)](https://codeclimate.com/github/mose/cogbot)
7
+ [![Inch](https://inch-ci.org/github/mose/cogbot.svg)](https://inch-ci.org/github/mose/cogbot)
7
8
 
8
9
  Cogbot is an irc bot written in ruby based on [Cinch bot framework](https://github.com/cinchrb/cinch).
9
10
 
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env rake
2
+
3
+ require 'bundler/setup'
2
4
  require "bundler/gem_tasks"
3
5
  require "rake/testtask"
4
6
 
@@ -12,4 +14,4 @@ task :ci_cleanup do
12
14
  MiniTest::Ci.clean
13
15
  end
14
16
 
15
- task :default => :test
17
+ task :default => :test
data/cogbot.gemspec CHANGED
@@ -16,15 +16,15 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = Cogbot::VERSION
18
18
 
19
- gem.add_dependency 'cinch', '2.2.4'
19
+ gem.add_dependency 'cinch', '2.3.1'
20
20
  gem.add_dependency "thor", '~> 0.19.1'
21
- gem.add_dependency "eventmachine", '1.0.7'
21
+ gem.add_dependency "eventmachine", '1.0.8'
22
22
  gem.add_dependency "eventmachine_httpserver", '~> 0.2.1'
23
- gem.add_dependency 'nokogiri', '~> 1.6.6'
24
- gem.add_dependency "daemons", '~> 1.1.9'
23
+ gem.add_dependency 'nokogiri', '~> 1.6.6.4'
24
+ gem.add_dependency "daemons", '~> 1.2.3'
25
25
 
26
- gem.add_dependency 'twitter', '~> 5.13.0' # twitter plugin
27
- gem.add_dependency 'json', '~> 1.8.2' # stackoverflow plugin
26
+ gem.add_dependency 'twitter', '~> 5.15.0' # twitter plugin
27
+ gem.add_dependency 'json', '~> 1.8.3' # stackoverflow plugin
28
28
  gem.add_dependency 'yajl-ruby', '~> 1.2.1' # rubygems plugin
29
29
  gem.add_dependency 'fortune_gem', '~> 0.0.8' # fortune plugin
30
30
 
data/lib/cogbot/server.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # eventmachine engine for serving as a webhook destination
1
2
  class Server < EM::Connection
2
3
  include EM::HttpServer
3
4
 
data/lib/cogbot/setup.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Cogbot
2
2
  module Setup
3
+ extend self
3
4
 
4
- def self.setvalue default
5
+ def setvalue(default)
5
6
  input = $stdin.gets.chomp
6
7
  if input == ''
7
8
  default
@@ -10,7 +11,7 @@ module Cogbot
10
11
  end
11
12
  end
12
13
 
13
- def self.setbinary default
14
+ def setbinary(default)
14
15
  input = $stdin.gets.chomp
15
16
  if input == ''
16
17
  default
@@ -19,7 +20,7 @@ module Cogbot
19
20
  end
20
21
  end
21
22
 
22
- def self.setlist default
23
+ def setlist(default)
23
24
  input = $stdin.gets.chomp
24
25
  if input == ''
25
26
  default
@@ -28,7 +29,7 @@ module Cogbot
28
29
  end
29
30
  end
30
31
 
31
- def self.init
32
+ def init
32
33
  st = "\033[0;33m"
33
34
  en = "\033[m"
34
35
 
@@ -60,11 +61,18 @@ module Cogbot
60
61
  print "#{st}What plugins will be enabled for #{main['nick']} ?#{en} [#{default['main']['plugins'].join(',')}] "
61
62
  main['plugins'] = setlist default['main']['plugins']
62
63
 
64
+ write(main)
65
+ return main
66
+ end
67
+
68
+ def write(content)
63
69
  FileUtils.mkdir_p(CONFIG_DIR) unless File.directory?(CONFIG_DIR)
64
70
  FileUtils.mkdir_p(LOG_DIR) unless File.directory?(LOG_DIR)
65
- File.open(CONFIG_FILE,'w') { |f| YAML::dump({ 'main' => main }, f) }
66
- return main
71
+ File.open(CONFIG_FILE,'w') do |f|
72
+ YAML::dump({ 'main' => content }, f)
73
+ end
67
74
  end
75
+
68
76
  end
69
77
  end
70
78
 
data/lib/cogbot/utils.rb CHANGED
@@ -1,5 +1,8 @@
1
+ # this is a monkey patching over the String class
2
+ # to bring the camelcase method from rails
1
3
  class String
2
4
 
5
+ # the famous camelize method so useful in metaprogramming
3
6
  def camelize
4
7
  self.downcase!
5
8
  self.gsub!(/(?:_| )?(.)([^_ ]*)/) { "#{$1.upcase}#{$2}" }
@@ -1,3 +1,4 @@
1
+ # just the cogbot version
1
2
  module Cogbot
2
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
3
4
  end
data/lib/cogbot.rb CHANGED
@@ -6,16 +6,18 @@ require 'net/http'
6
6
  require 'daemons'
7
7
  require 'thor'
8
8
  require 'yajl'
9
- #require 'cinch/storage/yaml'
10
9
  require "lib/cogbot/version"
11
10
  require "lib/cogbot/utils"
12
11
  require "lib/cogbot/server"
13
12
 
13
+ # main cogbot module
14
14
  module Cogbot
15
15
 
16
+ # cogbot cli parser and launcher
16
17
  class Bot < Thor
17
18
 
18
19
  desc "start", "start cogbot"
20
+ # manages the start cli command
19
21
  def start
20
22
 
21
23
  # prepare config
@@ -60,9 +62,6 @@ module Cogbot
60
62
  c.options = { 'cogconf' => config }
61
63
  c.plugins.prefix = config['main']['prefix']
62
64
  c.plugins.plugins = plugins
63
- #c.storage.backend = Cinch::Storage::YAML
64
- #c.storage.basedir = File.join(ROOT_DIR,"yaml")
65
- #c.storage.autosave = true
66
65
  end
67
66
  on :message, "hi" do |m|
68
67
  m.reply "Hello, #{m.user.nick}"
@@ -90,6 +89,7 @@ module Cogbot
90
89
  end
91
90
 
92
91
  desc "stop", "stop cogbot"
92
+ # manages the stop cli command
93
93
  def stop
94
94
  pid_file = File.join('/', 'tmp', 'cogbot.pid')
95
95
  pid = File.read(pid_file).to_i if File.exist?(pid_file)
@@ -97,6 +97,7 @@ module Cogbot
97
97
  end
98
98
 
99
99
  desc "restart", "restart cogbot"
100
+ # manages the restart cli command, just stopping and startinbg in sequence
100
101
  def restart
101
102
  stop
102
103
  start
@@ -15,15 +15,11 @@ module Cinch
15
15
  @bot.config.options['cogconf']['main']['channels'].each do |channel|
16
16
  #['#dev'].each do |channel|
17
17
  hash['commits'].each do |c|
18
- files = ""
19
- files += '[= ' + short(c['modified']).join(' ') + ' ] ' unless c['modified'].empty?
20
- files += '[- ' + short(c['removed']).join(' ') + ' ] ' unless c['removed'].empty?
21
- files += '[+ ' + short(c['added']).join(' ') + ' ] ' unless c['added'].empty?
22
18
  Channel(channel).msg "%s@%s: %s %s" % [
23
19
  c['committer']['name'],
24
20
  hash['repository']['name'],
25
21
  CGI::unescape(c['message']),
26
- files
22
+ files(c)
27
23
  ]
28
24
  end
29
25
  end
@@ -33,6 +29,14 @@ module Cinch
33
29
  x.map { |l| l.gsub(/([^\/]*)\//) { |s| s[0,1] + '/'} }
34
30
  end
35
31
 
32
+ def files(c)
33
+ back = ""
34
+ back += '[= ' + short(c['modified']).join(' ') + ' ] ' unless c['modified'].empty?
35
+ back += '[- ' + short(c['removed']).join(' ') + ' ] ' unless c['removed'].empty?
36
+ back += '[+ ' + short(c['added']).join(' ') + ' ] ' unless c['added'].empty?
37
+ back
38
+ end
39
+
36
40
  end
37
41
  end
38
42
  end
@@ -1,7 +1,9 @@
1
1
  require "cgi"
2
2
 
3
+
3
4
  module Cinch
4
5
  module Plugins
6
+
5
7
  class Trellolistener
6
8
  include Cinch::Plugin
7
9
 
@@ -11,175 +13,327 @@ module Cinch
11
13
 
12
14
  def listen(m, json)
13
15
  hash = Yajl::Parser.parse(URI.unescape(json))
14
- #bot.loggers.debug(hash.inspect)
15
- if @bot.config.options['cogconf']['trello']
16
+ # bot.loggers.debug(hash.inspect)
17
+ if @bot.config.options['cogconf']['trello']
18
+ msg = TrelloMessage.new(hash['action'])
19
+ output = msg.output
20
+ if msg.notfound
21
+ puts "------------- not yet implemented: #{hash['action']['type']} ------"
22
+ bot.loggers.debug(json)
23
+ puts "---------------------------------------------------"
24
+ return
25
+ end
26
+
16
27
  @bot.config.options['cogconf']['trello']['announce'].each do |announce|
17
- if hash['action']['data']['board']['name'] == announce['board']
28
+ if msg.board == announce['board']
18
29
  channel = announce['channel']
19
- action = hash['action']['type']
20
- case action
21
- when 'updateBoard'
22
- # not implemented yet
23
- # "prefs":{"cardAging":"pirate"}
24
- # "prefs":{"voting":"members"}
25
- when 'addMemberToBoard'
26
- message(channel, hash, "added %s to board" % [
27
- Format(:aqua, hash['action']['member']['username'])
28
- ])
29
- when 'removeMemberFromBoard'
30
- message(channel, hash, "removed %s from board" % [
31
- Format(:aqua, hash['action']['member']['username'])
32
- ])
33
- when 'updateList'
34
- message(channel, hash, "changed column name %s to %s" % [
35
- Format(:orange, hash['action']['data']['old']['name']),
36
- Format(:orange, hash['action']['data']['list']['name'])
37
- ])
38
- when 'createCard'
39
- message(channel, hash, "created \"%s\" in %s" % [
40
- truncate(hash['action']['data']['card']['name']),
41
- Format(:orange, hash['action']['data']['list']['name'])
42
- ])
43
- when 'addMemberToCard'
44
- message(channel, hash, "added %s to \"%s\"" % [
45
- Format(:aqua, hash['action']['member']['username']),
46
- truncate(hash['action']['data']['card']['name'])
47
- ]) or puts json
48
- when 'removeMemberFromCard'
49
- message(channel, hash, "removed %s from \"%s\"" % [
50
- Format(:aqua, hash['action']['member']['username']),
51
- truncate(hash['action']['data']['card']['name'])
52
- ]) or puts json
53
- when 'updateCard'
54
- if hash['action']['data']['old']
55
- if hash['action']['data']['listAfter']
56
- message(channel, hash, "moved \"%s\" from %s to %s" % [
57
- truncate(hash['action']['data']['card']['name']),
58
- Format(:orange, hash['action']['data']['listBefore']['name']),
59
- Format(:orange, hash['action']['data']['listAfter']['name'])
60
- ])
61
- elsif hash['action']['data']['old']['desc']
62
- message(channel, hash, "changed desc on \"%s\" in %s to \"%s\"" % [
63
- truncate(hash['action']['data']['card']['name']),
64
- Format(:orange, hash['action']['data']['list']['name']),
65
- truncate(hash['action']['data']['card']['desc'])
66
- ])
67
- elsif hash['action']['data']['old']['closed'] != nil
68
- if hash['action']['data']['card']['closed']
69
- message(channel, hash, "archived \"%s\" from %s" % [
70
- truncate(hash['action']['data']['card']['name']),
71
- Format(:orange, hash['action']['data']['list']['name'])
72
- ])
73
- else
74
- message(channel, hash, "restored \"%s\" in %s" % [
75
- truncate(hash['action']['data']['card']['name']),
76
- Format(:orange, hash['action']['data']['list']['name'])
77
- ])
78
- end
79
- elsif hash['action']['data']['old'].has_key? 'due'
80
- if hash['action']['data']['card']['due'] && hash['action']['data']['old']['due']
81
- date_new = Date.parse(hash['action']['data']['card']['due']).strftime("%a %-d %b")
82
- date_old = Date.parse(hash['action']['data']['old']['due']).strftime("%a %-d %b")
83
- message(channel, hash, "changed date on \"%s\" in %s, from %s to %s" % [
84
- truncate(hash['action']['data']['card']['name']),
85
- Format(:orange, hash['action']['data']['list']['name']),
86
- Format(:yellow, date_old),
87
- Format(:yellow, date_new)
88
- ])
89
- elsif hash['action']['data']['card']['due']
90
- date_new = Date.parse(hash['action']['data']['card']['due']).strftime("%a %-d %b")
91
- message(channel, hash, "set date on \"%s\" in %s, to %s" % [
92
- truncate(hash['action']['data']['card']['name']),
93
- Format(:orange, hash['action']['data']['list']['name']),
94
- Format(:yellow, date_new)
95
- ])
96
- else
97
- date_old = Date.parse(hash['action']['data']['old']['due']).strftime("%a %-d %b")
98
- message(channel, hash, "removed date on \"%s\" in %s, was \"%s\"" % [
99
- truncate(hash['action']['data']['card']['name']),
100
- Format(:orange, hash['action']['data']['list']['name']),
101
- Format(:yellow, date_old)
102
- ])
103
- end
104
- else
105
- puts "---- no known old ----"
106
- bot.loggers.debug(json)
107
- puts "---- / no known old ----"
108
- end
109
- else
110
- puts "---- no old ----"
111
- bot.loggers.debug(json)
112
- puts "---- / no old ----"
113
- end
114
- when 'voteOnCard'
115
- message(channel, hash, "voted on card \"%s\"" % [
116
- truncate(hash['action']['data']['card']['name'])
117
- ])
118
- when 'addLabelToCard'
119
- message(channel, hash, "labelled \"%s\" as %s" % [
120
- truncate(hash['action']['data']['card']['name']),
121
- Format(:green, hash['action']['data']['label']['name'])
122
- ])
123
- when 'removeLabelFromCard'
124
- message(channel, hash, "unlabelled \"%s\" as %s" % [
125
- truncate(hash['action']['data']['card']['name']),
126
- Format(:grey, hash['action']['data']['label']['name'])
127
- ])
128
- when 'commentCard'
129
- message(channel, hash, "commented on \"%s\" in %s: %s" % [
130
- truncate(hash['action']['data']['card']['name']),
131
- Format(:orange, hash['action']['data']['list']['name']),
132
- truncate(hash['action']['data']['text'])
133
- ])
134
- when 'addChecklistToCard'
135
- message(channel, hash, "added checklist \"%s\" on \"%s\"" % [
136
- truncate(hash['action']['data']['checklist']['name']),
137
- truncate(hash['action']['data']['card']['name'])
138
- ])
139
- when 'updateChecklist'
140
- message(channel, hash, "changed checklist \"%s\" to \"%s\"" % [
141
- truncate(hash['action']['data']['checkItem']['name']),
142
- truncate(hash['action']['data']['old']['name'])
143
- ])
144
- when 'createCheckItem'
145
- message(channel, hash, "added \"%s\" in checklist \"%s\" on \"%s\"" % [
146
- truncate(hash['action']['data']['checkItem']['name']),
147
- truncate(hash['action']['data']['checklist']['name']),
148
- truncate(hash['action']['data']['card']['name'])
149
- ])
150
- when 'updateCheckItem'
151
- message(channel, hash, "changed \"%s\" in checklist \"%s\" to \"%s\" on \"%s\"" % [
152
- truncate(hash['action']['data']['old']['name']),
153
- truncate(hash['action']['data']['checklist']['name']),
154
- truncate(hash['action']['data']['checkItem']['name']),
155
- truncate(hash['action']['data']['card']['name'])
156
- ])
157
- when 'updateCheckItemStateOnCard'
158
- message(channel, hash, "changed state of \"%s\" in \"%s\" to %s on \"%s\"" % [
159
- truncate(hash['action']['data']['checkItem']['name']),
160
- truncate(hash['action']['data']['checklist']['name']),
161
- Format(:yellow, hash['action']['data']['checkItem']['state']),
162
- truncate(hash['action']['data']['card']['name'])
163
- ])
164
- when 'moveCardFromBoard'
165
- message(channel, hash, "moved card \"%s\" to board %s" % [
166
- truncate(hash['action']['data']['card']['name']),
167
- Format(:yellow, "[%s]" % hash['action']['data']['boardTarget']['name'])
168
- ])
169
- else
170
- puts "------------- not yet implemented: #{action} ------"
171
- bot.loggers.debug(json)
172
- puts "---------------------------------------------------"
173
- end
30
+ Channel(channel).send(msg.output)
174
31
  end
175
32
  end
176
33
  end
177
34
  end
178
35
 
36
+ end
37
+ end
38
+ end
39
+
40
+
41
+ module Cinch
42
+ module Plugins
43
+
44
+ class TrelloMessage
45
+
46
+ attr_reader :notfound
47
+
48
+ def initialize(action)
49
+ @creator = action['memberCreator']['username']
50
+ @member = action['member']['username'] if action['member']
51
+ @data = action['data']
52
+ @type = action['type']
53
+ @card = @data['card']['name'] ? truncate(@data['card']['name']) : @data['card']['id']
54
+ @notfound = false
55
+ end
56
+
57
+ def format(*args)
58
+ Cinch::Formatting.format(*args)
59
+ end
60
+
61
+ def board
62
+ @data['board']['name']
63
+ end
64
+
65
+ def invalidate
66
+ @notfound = true
67
+ end
68
+
69
+ def output
70
+ if self.respond_to?(@type.to_sym)
71
+ "%s %s %s %s" % [
72
+ format(:yellow, "[%s]" % board),
73
+ format(:aqua, @creator),
74
+ self.send(@type.to_sym),
75
+ format(:grey, "(%s)" % trellolink)
76
+ ]
77
+ else
78
+ invalidate
79
+ end
80
+ end
81
+
82
+ def trellolink
83
+ "https://trello.com/c/#{@data['card']['shortLink']}"
84
+ end
85
+
86
+ def addMemberToBoard
87
+ "added %s to board" % [
88
+ format(:aqua, @member)
89
+ ]
90
+ end
91
+
92
+ def removeMemberFromBoard
93
+ "removed %s from board" % [
94
+ format(:aqua, @member)
95
+ ]
96
+ end
97
+
98
+ def createList
99
+ "created new column %s" % [
100
+ format(:orange, @data['list']['name'])
101
+ ]
102
+ end
103
+
104
+ def updateList
105
+ "changed column name %s to %s" % [
106
+ format(:orange, @data['old']['name']),
107
+ format(:yellow, @data['list']['name'])
108
+ ]
109
+ end
110
+
111
+ def createCard
112
+ "created \"%s\" in %s" % [
113
+ @card,
114
+ format(:orange, @data['list']['name'])
115
+ ]
116
+ end
117
+
118
+ def deleteCard
119
+ "deleted \"%s\" from %s" % [
120
+ @card,
121
+ format(:orange, @data['list']['name'])
122
+ ]
123
+ end
124
+
125
+ def addMemberToCard
126
+ "added %s to \"%s\"" % [
127
+ format(:aqua, @member),
128
+ @card
129
+ ]
130
+ end
131
+
132
+ def removeMemberFromCard
133
+ "removed %s from \"%s\"" % [
134
+ format(:aqua, @member),
135
+ @card
136
+ ]
137
+ end
138
+
139
+ def updateCard
140
+ if @data['old']
141
+ if @data['listAfter']
142
+ updateCard_moved
143
+ elsif @data['old']['desc']
144
+ updateCard_changed
145
+ elsif @data['old']['closed'] != nil
146
+ if @data['card']['closed']
147
+ updateCard_archived
148
+ else
149
+ updateCard_restored
150
+ end
151
+ elsif @data['old'].has_key? 'due'
152
+ if @data['card']['due'] && @data['old']['due']
153
+ updateCard_changedate
154
+ elsif @data['card']['due']
155
+ updateCard_setdate
156
+ else
157
+ updateCard_removedate
158
+ end
159
+ else
160
+ invalidate
161
+ end
162
+ else
163
+ invalidate
164
+ end
165
+ end
166
+
167
+ def updateCard_moved
168
+ "moved \"%s\" from %s to %s" % [
169
+ @card,
170
+ format(:orange, @data['listBefore']['name']),
171
+ format(:orange, @data['listAfter']['name'])
172
+ ]
173
+ end
174
+
175
+ def updateCard_changed
176
+ "changed desc on \"%s\" in %s to \"%s\"" % [
177
+ @card,
178
+ format(:orange, @data['list']['name']),
179
+ truncate(@data['card']['desc'])
180
+ ]
181
+ end
182
+
183
+ def updateCard_archived
184
+ "archived \"%s\" from %s" % [
185
+ @card,
186
+ format(:orange, @data['list']['name'])
187
+ ]
188
+ end
189
+
190
+ def updateCard_restored
191
+ "restored \"%s\" in %s" % [
192
+ @card,
193
+ format(:orange, @data['list']['name'])
194
+ ]
195
+ end
196
+
197
+ def updateCard_changedate
198
+ "changed date on \"%s\" in %s, from %s to %s" % [
199
+ @card,
200
+ format(:orange, @data['list']['name']),
201
+ format(:yellow, format_date(@data['card']['due'])),
202
+ format(:yellow, format_date(@data['old']['due']))
203
+ ]
204
+ end
205
+
206
+ def updateCard_setdate
207
+ "set date on \"%s\" in %s, to %s" % [
208
+ @card,
209
+ format(:orange, @data['list']['name']),
210
+ format(:yellow, format_date(@data['card']['due']))
211
+ ]
212
+ end
213
+
214
+ def updateCard_removedate
215
+ "removed date on \"%s\" in %s, was \"%s\"" % [
216
+ @card,
217
+ format(:orange, @data['list']['name']),
218
+ format(:yellow, format_date(@data['old']['due']))
219
+ ]
220
+ end
221
+
222
+ def voteOnCard
223
+ "voted on card \"%s\"" % [
224
+ @card
225
+ ]
226
+ end
227
+
228
+ def addLabelToCard
229
+ "labelled \"%s\" as %s" % [
230
+ @card,
231
+ format(:green, @data['label']['name'])
232
+ ]
233
+ end
234
+
235
+ def removeLabelFromCard
236
+ "unlabelled \"%s\" as %s" % [
237
+ @card,
238
+ format(:grey, @data['label']['name'])
239
+ ]
240
+ end
241
+
242
+ def updateLabel
243
+ if @data['old']
244
+ if @data['old']['name']
245
+ "changed label name \"%s\" to \"%s\"" % [
246
+ format(:orange, @data['old']['name']),
247
+ format(:yellow, @data['label']['name'])
248
+ ]
249
+ elsif @data['old']['color']
250
+ "changed label \"%s\" color from %s to %s" % [
251
+ format(:green, @data['label']['name']),
252
+ format(:orange, @data['old']['color']),
253
+ format(:yellow, @data['label']['color'])
254
+ ]
255
+ else
256
+ invalidate
257
+ end
258
+ else
259
+ invalidate
260
+ end
261
+ end
262
+
263
+ def commentCard
264
+ "commented on \"%s\" in %s: %s" % [
265
+ @card,
266
+ format(:orange, @data['list']['name']),
267
+ truncate(@data['text'])
268
+ ]
269
+ end
270
+
271
+ def updateComment
272
+ "updated comment on \"%s\" in %s: %s" % [
273
+ @card,
274
+ format(:orange, @data['list']['name']),
275
+ truncate(@data['text'])
276
+ ]
277
+ end
278
+
279
+ def deleteComment
280
+ "deleted comment on \"%s\" in %s" % [
281
+ @card,
282
+ format(:orange, @data['list']['name']),
283
+ ]
284
+ end
285
+
286
+ def addChecklistToCard
287
+ "added checklist \"%s\" on \"%s\"" % [
288
+ @data['checklist']['name'],
289
+ @card
290
+ ]
291
+ end
292
+
293
+ def updateChecklist
294
+ "changed checklist \"%s\" to \"%s\"" % [
295
+ @data['checkItem']['name'],
296
+ @data['old']['name']
297
+ ]
298
+ end
299
+
300
+ def createCheckItem
301
+ "added \"%s\" in checklist \"%s\" on \"%s\"" % [
302
+ @data['checkItem']['name'],
303
+ @data['checklist']['name'],
304
+ @card
305
+ ]
306
+ end
307
+
308
+ def updateCheckItem
309
+ "changed \"%s\" in checklist \"%s\" to \"%s\" on \"%s\"" % [
310
+ @data['old']['name'],
311
+ @data['checklist']['name'],
312
+ @data['checkItem']['name'],
313
+ @card
314
+ ]
315
+ end
316
+
317
+ def updateCheckItemStateOnCard
318
+ "changed state of \"%s\" in \"%s\" to %s on \"%s\"" % [
319
+ @data['checkItem']['name'],
320
+ @data['checklist']['name'],
321
+ format(:yellow, @data['checkItem']['state']),
322
+ @card
323
+ ]
324
+ end
325
+
326
+ def moveCardFromBoard
327
+ "moved card \"%s\" to board %s" % [
328
+ @card,
329
+ format(:yellow, "[%s]" % @data['boardTarget']['name'])
330
+ ]
331
+ end
332
+
179
333
  private
180
334
 
181
- def link(x)
182
- "https://trello.com/c/#{x}"
335
+ def format_date(time)
336
+ Date.parse(time).strftime("%a %-d %b")
183
337
  end
184
338
 
185
339
  def truncate(content, limit=50)
@@ -197,15 +351,7 @@ module Cinch
197
351
  message.strip
198
352
  end
199
353
 
200
- def message(channel, hash, msg)
201
- Channel(channel).send("%s %s %s %s" % [
202
- Format(:yellow, "[%s]" % hash['action']['data']['board']['name']),
203
- Format(:aqua, hash['action']['memberCreator']['username']),
204
- msg,
205
- Format(:grey, "(%s)" % link(hash['action']['data']['card']['shortLink']))
206
- ])
207
- end
208
-
209
354
  end
210
355
  end
211
356
  end
357
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cogbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - mose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cinch
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.4
19
+ version: 2.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.4
26
+ version: 2.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.7
47
+ version: 1.0.8
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.7
54
+ version: 1.0.8
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: eventmachine_httpserver
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,56 +72,56 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.6.6
75
+ version: 1.6.6.4
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.6.6
82
+ version: 1.6.6.4
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: daemons
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.1.9
89
+ version: 1.2.3
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.1.9
96
+ version: 1.2.3
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: twitter
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 5.13.0
103
+ version: 5.15.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 5.13.0
110
+ version: 5.15.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.8.2
117
+ version: 1.8.3
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.8.2
124
+ version: 1.8.3
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: yajl-ruby
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -322,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
322
  version: '0'
323
323
  requirements: []
324
324
  rubyforge_project:
325
- rubygems_version: 2.4.5
325
+ rubygems_version: 2.4.8
326
326
  signing_key:
327
327
  specification_version: 4
328
328
  summary: Yet another irc bot, focused on helping development teams.