@@ -75,9 +75,14 @@ func color(clr string) int {
75
75
}
76
76
77
77
var (
78
- successColor = color ("1ac600" )
79
- warnColor = color ("ffd930" )
80
- failedColor = color ("ff3232" )
78
+ greenColor = color ("1ac600" )
79
+ greenColorLight = color ("bfe5bf" )
80
+ yellowColor = color ("ffd930" )
81
+ greyColor = color ("4f545c" )
82
+ purpleColor = color ("7289da" )
83
+ orangeColor = color ("eb6420" )
84
+ orangeColorLight = color ("e68d60" )
85
+ redColor = color ("ff3232" )
81
86
)
82
87
83
88
// SetSecret sets the discord secret
@@ -104,7 +109,7 @@ func getDiscordCreatePayload(p *api.CreatePayload, meta *DiscordMeta) (*DiscordP
104
109
{
105
110
Title : title ,
106
111
URL : p .Repo .HTMLURL + "/src/" + refName ,
107
- Color : successColor ,
112
+ Color : greenColor ,
108
113
Author : DiscordEmbedAuthor {
109
114
Name : p .Sender .UserName ,
110
115
URL : setting .AppURL + p .Sender .UserName ,
@@ -127,7 +132,7 @@ func getDiscordDeletePayload(p *api.DeletePayload, meta *DiscordMeta) (*DiscordP
127
132
{
128
133
Title : title ,
129
134
URL : p .Repo .HTMLURL + "/src/" + refName ,
130
- Color : warnColor ,
135
+ Color : redColor ,
131
136
Author : DiscordEmbedAuthor {
132
137
Name : p .Sender .UserName ,
133
138
URL : setting .AppURL + p .Sender .UserName ,
@@ -149,7 +154,7 @@ func getDiscordForkPayload(p *api.ForkPayload, meta *DiscordMeta) (*DiscordPaylo
149
154
{
150
155
Title : title ,
151
156
URL : p .Repo .HTMLURL ,
152
- Color : successColor ,
157
+ Color : greenColor ,
153
158
Author : DiscordEmbedAuthor {
154
159
Name : p .Sender .UserName ,
155
160
URL : setting .AppURL + p .Sender .UserName ,
@@ -199,7 +204,7 @@ func getDiscordPushPayload(p *api.PushPayload, meta *DiscordMeta) (*DiscordPaylo
199
204
Title : title ,
200
205
Description : text ,
201
206
URL : titleLink ,
202
- Color : successColor ,
207
+ Color : greenColor ,
203
208
Author : DiscordEmbedAuthor {
204
209
Name : p .Sender .UserName ,
205
210
URL : setting .AppURL + p .Sender .UserName ,
@@ -218,48 +223,48 @@ func getDiscordIssuesPayload(p *api.IssuePayload, meta *DiscordMeta) (*DiscordPa
218
223
case api .HookIssueOpened :
219
224
title = fmt .Sprintf ("[%s] Issue opened: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
220
225
text = p .Issue .Body
221
- color = warnColor
226
+ color = orangeColor
222
227
case api .HookIssueClosed :
223
228
title = fmt .Sprintf ("[%s] Issue closed: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
224
- color = failedColor
229
+ color = redColor
225
230
text = p .Issue .Body
226
231
case api .HookIssueReOpened :
227
232
title = fmt .Sprintf ("[%s] Issue re-opened: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
228
233
text = p .Issue .Body
229
- color = warnColor
234
+ color = yellowColor
230
235
case api .HookIssueEdited :
231
236
title = fmt .Sprintf ("[%s] Issue edited: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
232
237
text = p .Issue .Body
233
- color = warnColor
238
+ color = yellowColor
234
239
case api .HookIssueAssigned :
235
240
title = fmt .Sprintf ("[%s] Issue assigned to %s: #%d %s" , p .Repository .FullName ,
236
241
p .Issue .Assignee .UserName , p .Index , p .Issue .Title )
237
242
text = p .Issue .Body
238
- color = successColor
243
+ color = greenColor
239
244
case api .HookIssueUnassigned :
240
245
title = fmt .Sprintf ("[%s] Issue unassigned: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
241
246
text = p .Issue .Body
242
- color = warnColor
247
+ color = yellowColor
243
248
case api .HookIssueLabelUpdated :
244
249
title = fmt .Sprintf ("[%s] Issue labels updated: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
245
250
text = p .Issue .Body
246
- color = warnColor
251
+ color = yellowColor
247
252
case api .HookIssueLabelCleared :
248
253
title = fmt .Sprintf ("[%s] Issue labels cleared: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
249
254
text = p .Issue .Body
250
- color = warnColor
255
+ color = yellowColor
251
256
case api .HookIssueSynchronized :
252
257
title = fmt .Sprintf ("[%s] Issue synchronized: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
253
258
text = p .Issue .Body
254
- color = warnColor
259
+ color = yellowColor
255
260
case api .HookIssueMilestoned :
256
261
title = fmt .Sprintf ("[%s] Issue milestone: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
257
262
text = p .Issue .Body
258
- color = warnColor
263
+ color = yellowColor
259
264
case api .HookIssueDemilestoned :
260
265
title = fmt .Sprintf ("[%s] Issue clear milestone: #%d %s" , p .Repository .FullName , p .Index , p .Issue .Title )
261
266
text = p .Issue .Body
262
- color = warnColor
267
+ color = yellowColor
263
268
}
264
269
265
270
return & DiscordPayload {
@@ -282,26 +287,41 @@ func getDiscordIssuesPayload(p *api.IssuePayload, meta *DiscordMeta) (*DiscordPa
282
287
}
283
288
284
289
func getDiscordIssueCommentPayload (p * api.IssueCommentPayload , discord * DiscordMeta ) (* DiscordPayload , error ) {
285
- title := fmt .Sprintf ("#%d %s" , p .Issue .Index , p .Issue .Title )
290
+ title := fmt .Sprintf ("#%d: %s" , p .Issue .Index , p .Issue .Title )
286
291
url := fmt .Sprintf ("%s/issues/%d#%s" , p .Repository .HTMLURL , p .Issue .Index , CommentHashTag (p .Comment .ID ))
287
292
content := ""
288
293
var color int
289
294
switch p .Action {
290
295
case api .HookIssueCommentCreated :
291
- title = "New comment: " + title
296
+ if p .IsPull {
297
+ title = "New comment on pull request " + title
298
+ color = greenColorLight
299
+ } else {
300
+ title = "New comment on issue " + title
301
+ color = orangeColorLight
302
+ }
292
303
content = p .Comment .Body
293
- color = successColor
294
304
case api .HookIssueCommentEdited :
295
- title = "Comment edited: " + title
305
+ if p .IsPull {
306
+ title = "Comment edited on pull request " + title
307
+ } else {
308
+ title = "Comment edited on issue " + title
309
+ }
296
310
content = p .Comment .Body
297
- color = warnColor
311
+ color = yellowColor
298
312
case api .HookIssueCommentDeleted :
299
- title = "Comment deleted: " + title
313
+ if p .IsPull {
314
+ title = "Comment deleted on pull request " + title
315
+ } else {
316
+ title = "Comment deleted on issue " + title
317
+ }
300
318
url = fmt .Sprintf ("%s/issues/%d" , p .Repository .HTMLURL , p .Issue .Index )
301
319
content = p .Comment .Body
302
- color = warnColor
320
+ color = redColor
303
321
}
304
322
323
+ title = fmt .Sprintf ("[%s] %s" , p .Repository .FullName , title )
324
+
305
325
return & DiscordPayload {
306
326
Username : discord .Username ,
307
327
AvatarURL : discord .IconURL ,
@@ -328,24 +348,24 @@ func getDiscordPullRequestPayload(p *api.PullRequestPayload, meta *DiscordMeta)
328
348
case api .HookIssueOpened :
329
349
title = fmt .Sprintf ("[%s] Pull request opened: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
330
350
text = p .PullRequest .Body
331
- color = warnColor
351
+ color = greenColor
332
352
case api .HookIssueClosed :
333
353
if p .PullRequest .HasMerged {
334
354
title = fmt .Sprintf ("[%s] Pull request merged: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
335
- color = successColor
355
+ color = purpleColor
336
356
} else {
337
357
title = fmt .Sprintf ("[%s] Pull request closed: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
338
- color = failedColor
358
+ color = redColor
339
359
}
340
360
text = p .PullRequest .Body
341
361
case api .HookIssueReOpened :
342
362
title = fmt .Sprintf ("[%s] Pull request re-opened: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
343
363
text = p .PullRequest .Body
344
- color = warnColor
364
+ color = yellowColor
345
365
case api .HookIssueEdited :
346
366
title = fmt .Sprintf ("[%s] Pull request edited: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
347
367
text = p .PullRequest .Body
348
- color = warnColor
368
+ color = yellowColor
349
369
case api .HookIssueAssigned :
350
370
list := make ([]string , len (p .PullRequest .Assignees ))
351
371
for i , user := range p .PullRequest .Assignees {
@@ -355,31 +375,31 @@ func getDiscordPullRequestPayload(p *api.PullRequestPayload, meta *DiscordMeta)
355
375
strings .Join (list , ", " ),
356
376
p .Index , p .PullRequest .Title )
357
377
text = p .PullRequest .Body
358
- color = successColor
378
+ color = greenColor
359
379
case api .HookIssueUnassigned :
360
380
title = fmt .Sprintf ("[%s] Pull request unassigned: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
361
381
text = p .PullRequest .Body
362
- color = warnColor
382
+ color = yellowColor
363
383
case api .HookIssueLabelUpdated :
364
384
title = fmt .Sprintf ("[%s] Pull request labels updated: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
365
385
text = p .PullRequest .Body
366
- color = warnColor
386
+ color = yellowColor
367
387
case api .HookIssueLabelCleared :
368
388
title = fmt .Sprintf ("[%s] Pull request labels cleared: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
369
389
text = p .PullRequest .Body
370
- color = warnColor
390
+ color = yellowColor
371
391
case api .HookIssueSynchronized :
372
392
title = fmt .Sprintf ("[%s] Pull request synchronized: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
373
393
text = p .PullRequest .Body
374
- color = warnColor
394
+ color = yellowColor
375
395
case api .HookIssueMilestoned :
376
396
title = fmt .Sprintf ("[%s] Pull request milestone: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
377
397
text = p .PullRequest .Body
378
- color = warnColor
398
+ color = yellowColor
379
399
case api .HookIssueDemilestoned :
380
400
title = fmt .Sprintf ("[%s] Pull request clear milestone: #%d %s" , p .Repository .FullName , p .Index , p .PullRequest .Title )
381
401
text = p .PullRequest .Body
382
- color = warnColor
402
+ color = yellowColor
383
403
}
384
404
385
405
return & DiscordPayload {
@@ -412,17 +432,17 @@ func getDiscordPullRequestApprovalPayload(p *api.PullRequestPayload, meta *Disco
412
432
}
413
433
414
434
title = fmt .Sprintf ("[%s] Pull request review %s: #%d %s" , p .Repository .FullName , action , p .Index , p .PullRequest .Title )
415
- text = p .PullRequest . Body
435
+ text = p .Review . Content
416
436
417
437
switch event {
418
438
case HookEventPullRequestApproved :
419
- color = successColor
439
+ color = greenColor
420
440
case HookEventPullRequestRejected :
421
- color = failedColor
441
+ color = redColor
422
442
case HookEventPullRequestComment :
423
- fallthrough
443
+ color = greyColor
424
444
default :
425
- color = warnColor
445
+ color = yellowColor
426
446
}
427
447
}
428
448
@@ -452,10 +472,10 @@ func getDiscordRepositoryPayload(p *api.RepositoryPayload, meta *DiscordMeta) (*
452
472
case api .HookRepoCreated :
453
473
title = fmt .Sprintf ("[%s] Repository created" , p .Repository .FullName )
454
474
url = p .Repository .HTMLURL
455
- color = successColor
475
+ color = greenColor
456
476
case api .HookRepoDeleted :
457
477
title = fmt .Sprintf ("[%s] Repository deleted" , p .Repository .FullName )
458
- color = warnColor
478
+ color = redColor
459
479
}
460
480
461
481
return & DiscordPayload {
@@ -483,15 +503,15 @@ func getDiscordReleasePayload(p *api.ReleasePayload, meta *DiscordMeta) (*Discor
483
503
case api .HookReleasePublished :
484
504
title = fmt .Sprintf ("[%s] Release created" , p .Release .TagName )
485
505
url = p .Release .URL
486
- color = successColor
506
+ color = greenColor
487
507
case api .HookReleaseUpdated :
488
508
title = fmt .Sprintf ("[%s] Release updated" , p .Release .TagName )
489
509
url = p .Release .URL
490
- color = successColor
510
+ color = yellowColor
491
511
case api .HookReleaseDeleted :
492
512
title = fmt .Sprintf ("[%s] Release deleted" , p .Release .TagName )
493
513
url = p .Release .URL
494
- color = successColor
514
+ color = redColor
495
515
}
496
516
497
517
return & DiscordPayload {
0 commit comments