예제 #1
0
파일: web.py 프로젝트: Dusk-Argentum/taine
    async def issues_handler(self, data):
        issue = data['issue']
        issue_num = issue['number']
        action = data['action']
        if issue['user']['login'] == 'taine-bot':
            return

        # we only really care about opened or closed
        if action == "closed":
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                return  # oh well

            await report.resolve(ContextProxy(self.bot), None, False)
            report.commit()
        elif action in ("opened", "reopened"):
            # is the issue new?
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                report = Report.from_issue(issue)
                await GitHubClient.get_instance().add_issue_comment(
                    issue['number'], f"Tracked as `{report.report_id}`.")

            await report.unresolve(ContextProxy(self.bot), None, False)
            report.commit()
예제 #2
0
파일: web.py 프로젝트: cfi2017/taine
    async def issues_handler(self, data):
        issue = data['issue']
        issue_num = issue['number']
        action = data['action']
        if data['sender']['login'] == 'taine-bot':
            return

        # we only really care about opened or closed
        if action == "closed":
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                return  # oh well

            await report.resolve(ContextProxy(self.bot),
                                 None,
                                 False,
                                 pend=True)
            report.commit()
        elif action in ("opened", "reopened"):
            # is the issue new?
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                report = Report.from_issue(issue)
                if not issue['title'].startswith(report.report_id):
                    formatted_title = re.sub(r'^([A-Z]{3}(-\d+)?\s)?',
                                             f"{report.report_id} ",
                                             issue['title'])
                    await GitHubClient.get_instance().rename_issue(
                        issue['number'], formatted_title)
                await GitHubClient.get_instance().add_issue_comment(
                    issue['number'], f"Tracked as `{report.report_id}`.")
                await report.update_labels()

            await report.unresolve(ContextProxy(self.bot), None, False)
            report.commit()