Example #1
0
    def parse_message(self, message):
        text = message.text

        dr_id = parse_dr_id(text)
        if not dr_id:
            return
        print dr_id

        if dr_id in self.items:
            item = self.items[dr_id]

            if item.first_mentioned > message.timestamp:
                item.first_mentioned = message.timestamp

            if item.last_mentioned < message.timestamp:
                item.last_mentioned = message.timestamp

            if message.is_bot and (
                    item.last_mentioned_bot is None
                    or item.last_mentioned_bot < message.timestamp):
                item.last_mentioned_bot = message.timestamp
        else:
            item = Item()
            item.id = dr_id
            item.type = 'doc'
            item.first_mentioned = message.timestamp
            item.last_mentioned = message.timestamp
            if message.is_bot:
                item.last_mentioned_bot = message.timestamp
            item.url = 'https://docs.google.com/document/d/{0}'.format(dr_id)

            self.items[dr_id] = item
    def parse_message(self, message):
        text = message.text

        pr_ids = parse_pr_id(text)
        if not pr_ids:
            return
        for pr_id in pr_ids:
            if pr_id in self.items:
                item = self.items[pr_id]

                if item.first_mentioned > message.timestamp:
                    item.first_mentioned = message.timestamp

                if item.last_mentioned < message.timestamp:
                    item.last_mentioned = message.timestamp

                if message.is_bot and (item.last_mentioned_bot is None or item.last_mentioned_bot < message.timestamp):
                    item.last_mentioned_bot = message.timestamp
            else:
                item = Item()
                item.id = pr_id
                item.type = 'pr'
                item.project = pr_id.split('#')[0]
                item.first_mentioned = message.timestamp
                item.last_mentioned = message.timestamp
                if message.is_bot:
                    item.last_mentioned_bot = message.timestamp

                item.url = 'https://github.com/augurysys/{0}/pull/{1}'.format(*pr_id.split('#'))
                self.items[pr_id] = item