@@ -55,6 +55,13 @@ def _iter_chat_ids(self, repository):
55
55
if repo == repo_id :
56
56
yield chat_id
57
57
58
+ def _send (self , repo , text ):
59
+ text = truncate (text , TRUNCATED_MESSAGE , REPLY_MESSAGE )
60
+
61
+ for chat_id in self ._iter_chat_ids (repo ):
62
+ self .dispatcher .bot .send_message (chat_id = chat_id , text = text ,
63
+ parse_mode = ParseMode .HTML , disable_web_page_preview = True )
64
+
58
65
def issues (self , update , _ ):
59
66
# Issue opened, edited, closed, reopened, assigned, unassigned, labeled,
60
67
# unlabeled, milestoned, or demilestoned.
@@ -69,18 +76,27 @@ def issues(self, update, _):
69
76
issue_link = link (issue ['html_url' ], f'{ repo ["full_name" ]} #{ issue ["number" ]} { issue ["title" ]} ' )
70
77
author_link = link (author ['html_url' ], '@' + author ['login' ])
71
78
data_link = encode_data_link (('issue' , repo ['full_name' ], issue ['number' ], author ['login' ]))
72
- text = f'{ data_link } 🐛 New Issue { issue_link } \n by { author_link } \n \n { text } '
73
-
74
- text = truncate (text , TRUNCATED_MESSAGE , REPLY_MESSAGE )
79
+ text = f'{ data_link } 🐛 New issue { issue_link } \n by { author_link } \n \n { text } '
75
80
76
- for chat_id in self ._iter_chat_ids (repo ):
77
- self .dispatcher .bot .send_message (chat_id = chat_id , text = text ,
78
- parse_mode = ParseMode .HTML , disable_web_page_preview = True )
81
+ self ._send (repo , text )
79
82
80
83
def issue_comment (self , update , context ):
81
84
# Any time a comment on an issue is created, edited, or deleted.
82
85
# TODO: Possibly support editing and closing of comments?
83
- pass
86
+ if update .payload ['action' ] == 'created' :
87
+ issue = update .payload ['issue' ]
88
+ comment = update .payload ['comment' ]
89
+ author = comment ['user' ]
90
+ repo = update .payload ['repository' ]
91
+
92
+ text = render_github_markdown (comment ['body' ], repo ['full_name' ])
93
+
94
+ issue_link = link (issue ['html_url' ], f'{ repo ["full_name" ]} #{ issue ["number" ]} { issue ["title" ]} ' )
95
+ author_link = link (author ['html_url' ], '@' + author ['login' ])
96
+ data_link = encode_data_link (('issue' , repo ['full_name' ], issue ['number' ], author ['login' ]))
97
+ text = f'{ data_link } 💬 New comment on { issue_link } \n by { author_link } \n \n { text } '
98
+
99
+ self ._send (repo , text )
84
100
85
101
def pull_request (self , update , context ):
86
102
# Pull request opened, closed, reopened, edited, assigned, unassigned, review requested,
0 commit comments