@@ -78,17 +78,28 @@ def issues(self, update, _):
78
78
# Issue opened, edited, closed, reopened, assigned, unassigned, labeled,
79
79
# unlabeled, milestoned, or demilestoned.
80
80
# TODO: Possibly support editing, closing, reopening, etc. of issues
81
- if update .payload ['action' ] == 'opened' :
81
+ if update .payload ['action' ] in ( 'opened' , 'closed' , 'reopened' ) :
82
82
issue = update .payload ['issue' ]
83
83
author = issue ['user' ]
84
84
repo = update .payload ['repository' ]
85
85
86
- text = render_github_markdown (issue ['body' ], repo ['full_name' ])
86
+ if update .payload ['action' ] == 'opened' :
87
+ desc = '🐛 New issue'
88
+ if issue ['body' ]:
89
+ text = "\n \n " + render_github_markdown (issue ['body' ], repo ['full_name' ])
90
+ else :
91
+ text = "\n \n No description provided."
92
+ elif update .payload ['action' ] == 'closed' :
93
+ desc = '✅ Issue closed'
94
+ text = ""
95
+ elif update .payload ['action' ] == 'reopened' :
96
+ desc = '🔄 Issue reopened'
97
+ text = ""
87
98
88
99
issue_link = link (issue ['html_url' ], f'{ repo ["full_name" ]} #{ issue ["number" ]} { issue ["title" ]} ' )
89
100
author_link = link (author ['html_url' ], '@' + author ['login' ])
90
101
data_link = encode_data_link (('issue' , repo ['full_name' ], issue ['number' ], author ['login' ]))
91
- text = f'{ data_link } 🐛 New issue { issue_link } \n by { author_link } \n \n { text } '
102
+ text = f'{ data_link } { desc } { issue_link } \n by { author_link } { text } '
92
103
93
104
self ._send (repo , text , lambda r : r .issues )
94
105
@@ -112,6 +123,23 @@ def issue_comment(self, update, context):
112
123
113
124
self ._send (repo , text , lambda r : r .pull_comments if is_pull_request else r .issue_comments )
114
125
126
+ def discussion (self , update , _ ):
127
+ # Discussion created, edited, deleted, pinned, unpinned, locked, unlocked, transferred,
128
+ # category_changed, answered, unanswered, labeled, or unlabeled
129
+ if update .payload ['action' ] == 'created' :
130
+ discussion = update .payload ['discussion' ]
131
+ author = discussion ['user' ]
132
+ repo = update .payload ['repository' ]
133
+
134
+ text = render_github_markdown (discussion ['body' ], repo ['full_name' ])
135
+
136
+ issue_link = link (discussion ['html_url' ], f'{ repo ["full_name" ]} #{ discussion ["number" ]} { discussion ["title" ]} ' )
137
+ author_link = link (author ['html_url' ], '@' + author ['login' ])
138
+ data_link = encode_data_link (('discussion' , repo ['full_name' ], discussion ['number' ], author ['login' ]))
139
+ text = f'{ data_link } ⁉️ New discussion { issue_link } \n by { author_link } \n \n { text } '
140
+
141
+ self ._send (repo , text , lambda r : r .issues , suffix = "" )
142
+
115
143
def pull_request (self , update , context ):
116
144
# Pull request opened, closed, reopened, edited, assigned, unassigned, review requested,
117
145
# review request removed, labeled, unlabeled, or synchronized.
@@ -121,7 +149,10 @@ def pull_request(self, update, context):
121
149
author = pull_request ['user' ]
122
150
repo = update .payload ['repository' ]
123
151
124
- text = render_github_markdown (pull_request ['body' ], repo ['full_name' ])
152
+ if pull_request ['body' ]:
153
+ text = render_github_markdown (pull_request ['body' ], repo ['full_name' ])
154
+ else :
155
+ text = "No description provided"
125
156
126
157
pull_request_link = link (pull_request ['html_url' ],
127
158
f'{ repo ["full_name" ]} #{ pull_request ["number" ]} { pull_request ["title" ]} ' )
@@ -140,28 +171,28 @@ def pull_request_review(self, update, context):
140
171
author = review ['user' ]
141
172
repo = update .payload ['repository' ]
142
173
143
- if not review ['body' ]:
144
- return
145
-
146
- text = render_github_markdown ( review [ 'body' ], repo [ 'full_name' ])
174
+ if review ['body' ]:
175
+ text = " \n \n " + render_github_markdown ( review [ 'body' ], repo [ 'full_name' ])
176
+ else :
177
+ text = ""
147
178
148
179
review_link = link (review ['html_url' ],
149
180
f'{ repo ["full_name" ]} #{ pull_request ["number" ]} { pull_request ["title" ]} ' )
150
181
author_link = link (author ['html_url' ], '@' + author ['login' ])
151
182
data_link = encode_data_link (('pull request' , repo ['full_name' ], pull_request ['number' ], author ['login' ]))
152
183
153
- if review ['state' ] in ('commented' , 'approved' , 'request_changes' ):
184
+ if review ['state' ] in ('commented' , 'approved' , 'request_changes' , 'changes_requested' ):
154
185
if review ['state' ] == 'commented' :
155
186
state = 'Commented'
156
187
emoji = '💬'
157
188
elif review ['state' ] == 'approved' :
158
189
state = 'Approved'
159
190
emoji = '✅'
160
- elif review ['state' ] == 'request_changes' :
191
+ elif review ['state' ] in ( 'request_changes' , 'changes_requested' ) :
161
192
state = 'Changes requested'
162
193
emoji = '‼️'
163
194
164
- text = f'{ data_link } { emoji } New pull request review { review_link } \n { state } by { author_link } \n \n { text } '
195
+ text = f'{ data_link } { emoji } New pull request review { review_link } \n { state } by { author_link } { text } '
165
196
self ._send (repo , text , lambda r : r .pull_reviews )
166
197
167
198
def pull_request_review_comment (self , update , context ):
0 commit comments