Example #1
0
    def get_command(self, update):
        message_text = update['message']['text']
        split_message = message_text.split(' ')
        if len(split_message) == 1:
            return 'Tienes que indicarme qué issue quieres que te busque.'
        elif not split_message[1].isdecimal():
            return ('Tienes que entregarme un número para que pueda encontrar '
                    'la issue.')
        number = int(split_message[1])
        issue, status_code = self.github.get_issue(number)

        if status_code == 200:
            author = issue['user']['login']
            number = issue['number']
            title = issue['title']
            text = issue['body']
            url = issue['html_url']

            message = Formatter.format_issue(author, number, title, text, url)
        elif status_code == 404:
            message = 'No encontré esa issue. :('
        else:
            message = ('Github nos ha entregado una respuesta no esperada. '
                       'Por favor vuelve a intentarlo')

        return message
Example #2
0
    def process_request(self, update):
        action = update.get('action')
        issue = update['issue']
        if action == 'opened':
            author = issue['user']['login']
            number = issue['number']
            title = issue['title']
            text = issue['body']
            url = issue['html_url']
            message_text = 'Se ha creado una issue!\n'
            message_text += Formatter.format_issue(author, number, title, text,
                                                   url)
            for chat_id in self.chat:
                self.telegram.send_message(chat_id, message_text)

            error_text = self.seek_exception(text)
            if error_text:
                self.post_helpful_link(error_text, number)
        elif action == 'closed':
            self.check_googleable(issue)