bender-bot 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/bender/bot.rb +54 -17
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 793607ad14d0ce9b2c1f7ccbb03b3607eb26581a
4
- data.tar.gz: 9ea1a900427199fecbc1d15fc6a13240b9838350
3
+ metadata.gz: 49c34bc7e913f7b5c58fe00c947230387c53d5d4
4
+ data.tar.gz: 6c21fdfb8a97355548f890b7c8d6c5a27a55f1df
5
5
  SHA512:
6
- metadata.gz: 21098770d0c695262389ee7bd36395bc316c70cefda86a552e8e41b2d843ee22d4146cc759312642047bf449338a3b3ade20cd3631d02d93aee7681eb4a950f9
7
- data.tar.gz: 96527fd4de4d89b68ab83601b7461861476bed30f0c6e0e0a0f975aa5f860089f32813021470dde60c0e6caaa7ec0328bc97f6f2e3220917422bbe1e8baa70a8
6
+ metadata.gz: 4facedb603b3207ffd0918bbaac39722e0e00f5a03f5acf7c115b64b6edf7420c5d0dd914bb33ba282bf6aba90c7658b9079a64fca7e5bfef4b0970c2137a534
7
+ data.tar.gz: 9daa9cf4a5d88e3fb9914868cf734a5289112656119bbe571f030d58ab632b9f6f13421d377b828fa7debfd2317f643fc6232fef564c669e6920165989e80f12
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -73,14 +73,52 @@ class BenderBot
73
73
  "I'm so embarrassed. I wish everyone else was dead!",
74
74
  "Afterlife? If I thought I had to live another life, I'd kill myself right now!",
75
75
  "I'm back baby!",
76
- "LET'S GO ALREADYYYYYY!"
76
+ "LET'S GO ALREADYYYYYY!",
77
+ "I don't have emotions and sometimes that makes me very sad",
78
+ "Life is hilariously cruel"
77
79
  ]
78
80
 
81
+ COMMANDS = {
82
+ help: {
83
+ desc: 'Display this help text',
84
+ },
85
+ list: {
86
+ cmd: '',
87
+ desc: 'List open incidents'
88
+ },
89
+ close: {
90
+ fmt: 'INCIDENT_NUMBER',
91
+ desc: 'Display incident details',
92
+ },
93
+ open: {
94
+ fmt: "SEVERITY=#{SEVERITIES.keys.sort_by(&:to_i).join(',')} SUMMARY_TEXT",
95
+ desc: 'Open a new incident',
96
+ },
97
+ summary: {
98
+ desc: 'Summarize incidents from past 24 hours (open or closed)'
99
+ },
100
+ comment: {
101
+ fmt: 'INCIDENT_NUMBER COMMENT_TEXT',
102
+ desc: 'Add a comment to an incident'
103
+ }
104
+ }
79
105
 
80
106
  def reply_html message, color=:yellow
81
107
  @@hipchat[@room_name].send(nick, message, color: color)
82
108
  end
83
109
 
110
+ def reply_with_help
111
+ help = COMMANDS.each.map do |cmd, opts|
112
+ opts[:cmd] ||= cmd
113
+ opts[:cmd] = opts[:cmd].to_s.insert(0, ' ') if opts[:cmd]
114
+ opts[:fmt] ||= ''
115
+ opts[:fmt] = opts[:fmt].to_s.insert(0, ' ') if opts[:fmt]
116
+ '<code>/inc%{cmd}%{fmt}</code> - %{desc}' % opts
117
+ end.join('<br />')
118
+
119
+ reply_html help
120
+ end
121
+
84
122
 
85
123
  def handle room, sender, message
86
124
  @room_name = @@rooms.select { |r| r.xmpp_jid == room }.first.name
@@ -91,6 +129,13 @@ class BenderBot
91
129
  severity_field = SHOW_FIELDS.key 'Severity'
92
130
  severities = Hash.new { |h,k| h[k] = [] }
93
131
 
132
+ if message =~ /\/inc\s+(\w+)?\s*/
133
+ unless COMMANDS.include? $1.to_sym
134
+ reply_html 'Invalid usage', :red
135
+ reply_with_help
136
+ return
137
+ end
138
+ end
94
139
 
95
140
  case message
96
141
 
@@ -107,17 +152,9 @@ class BenderBot
107
152
  m = '<b>%{nick}</b>: %{name} (<a href="mailto:%{email}">%{email}</a>)' % u
108
153
  reply_html m, :purple
109
154
 
110
- # ?inc - This help text
111
- when /^\s*\?inc\s*$/
112
- reply_html [
113
- '<code>?inc</code> - Display this help text',
114
- '<code>/inc</code> - List open incidents',
115
- '<code>/inc <i>INCIDENT_NUMBER</i></code> - Display incident details',
116
- '<code>/inc close <i>INCIDENT_NUMBER</i></code> - Close an incident',
117
- '<code>/inc open <i>SEVERITY=1,2,3,4,5</i> <i>SUMMARY_TEXT</i></code> - Open a new incident',
118
- '<code>/inc summary</code> - Summarize incidents from past 24 hours (open or closed)',
119
- '<code>/inc comment <i>INCIDENT_NUMBER</i> <i>COMMENT_TEXT</i></code> - Add a comment to an incident'
120
- ].join('<br />')
155
+ # /inc help - This help text
156
+ when /^\s*(\?inc|\/inc\s+help)\s*$/
157
+ reply_with_help
121
158
 
122
159
  # /inc - List open incidents
123
160
  when /^\s*\/inc\s*$/
@@ -137,7 +174,7 @@ class BenderBot
137
174
  end.compact.join('<br />')
138
175
 
139
176
  if is.empty?
140
- reply_html 'No open incidents at the moment!', :green
177
+ reply_html 'Good news everyone - No open incidents at the moment!', :green
141
178
  else
142
179
  reply_html is
143
180
  end
@@ -256,6 +293,7 @@ class BenderBot
256
293
  end
257
294
  end
258
295
 
296
+
259
297
  return true
260
298
  end
261
299
 
@@ -448,11 +486,10 @@ private
448
486
  end
449
487
 
450
488
  def incident_link incident
451
- '<a href="%s">%s-%s</a>' % [
489
+ '<a href="%s">%s</a>' % [
452
490
  incident_url(incident),
453
- options.jira_project,
454
- incident['num']
491
+ incident['key']
455
492
  ]
456
493
  end
457
494
 
458
- end
495
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bender-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-20 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor