예제 #1
0
 async def team_join(self, event, slack):
     await asyncio.sleep(60)
     to = await slack.users.get(event['user']['id'], dm=True)
     message = SlackMessage(to=to)
     message.text = self.config['join'].format(
         self.config['files']['intro_doc']['url'])
     await slack.send(message)
예제 #2
0
    async def repo_deleted(self, event):

        slack = registry.get('slack')
        channel = await slack.channels.get(
            name=self.config['github']['channel'])
        msg = SlackMessage(to=channel)
        msg.text = 'Repository {repo} deleted by {user} :cold_sweat:'.format(
            repo=event.data['repository']['name'],
            user=event.data['sender']['login'])
        await slack.send(msg)
예제 #3
0
    async def release_created(self, event):

        slack = registry.get('slack')
        channel = await slack.channels.get(
            name=self.config['github']['channel'])
        msg = SlackMessage(to=channel)
        msg.text = 'Release {release} created in {repo} by {user}'.format(
            release=event.data['release']['tag_name'],
            repo=event.data['repository']['name'],
            user=event.data['sender']['login'])
        await slack.send(msg)
예제 #4
0
    async def members_joined(self, event, slack):

        members = await slack.users.all(fetch=True, deleted=False)
        if len(members) % 1000 == 0:
            to = await slack.channels.get(name='lobby')
            message = SlackMessage(to=to)
            message.text = ':tada: Everyone give a warm welcome to <@{user}>' \
                           ' our {number} members ! :tada:' \
                           '\nhttps://youtu.be/pbSCWgZQf_g?t=3'
            message.text = message.text.format(number=len(members),
                                               user=event['user']['id'])
            await slack.send(message)
예제 #5
0
    async def send_pr_msg(self, pr, action, color):
        footer = '+ {add} / - {del_}'.format(
            add=pr.data['pull_request']['additions'],
            del_=pr.data['pull_request']['deletions'])

        att = Attachment(fallback='pull request {}'.format(action),
                         title='Pull request {action} in <{repo_url}|{name}>:'
                         ' <{url}|{title}>'.format(
                             repo_url=pr.data['repository']['html_url'],
                             url=pr.data['pull_request']['html_url'],
                             name=pr.data['repository']['name'],
                             action=pr.data['action'],
                             title=pr.data['pull_request']['title'],
                         ),
                         color=color,
                         text='*<{url}|{title}>*\n{body}'.format(
                             url=pr.data['pull_request']['html_url'],
                             title=pr.data['pull_request']['title'],
                             body=pr.data['pull_request']['body']),
                         author_icon=pr.data['sender']['avatar_url'],
                         author_name=pr.data['sender']['login'],
                         author_link=pr.data['sender']['html_url'],
                         footer=footer)

        slack = registry.get('slack')
        channel = await slack.channels.get(
            name=self.config['github']['channel'])
        msg = SlackMessage(to=channel)
        msg.attachments.append(att)
        await slack.send(msg)
예제 #6
0
    async def send_issue_msg(self, issue, color):
        att = Attachment(fallback='issue {}'.format(issue.data['action']),
                         color=color,
                         text='*<{url}|{title}>*\n{body}'.format(
                             url=issue.data['issue']['html_url'],
                             title=issue.data['issue']['title'],
                             body=issue.data['issue']['body']),
                         title='Issue {action} in <{repo_url}|{name}>'.format(
                             repo_url=issue.data['repository']['html_url'],
                             name=issue.data['repository']['name'],
                             action=issue.data['action'],
                         ),
                         author_icon=issue.data['sender']['avatar_url'],
                         author_name=issue.data['sender']['login'],
                         author_link=issue.data['sender']['html_url'],
                         footer=', '.join(
                             label['name']
                             for label in issue.data['issue']['labels']))

        slack = registry.get('slack')
        channel = await slack.channels.get(
            name=self.config['github']['channel'])
        msg = SlackMessage(to=channel)
        msg.attachments.append(att)
        await slack.send(msg)
예제 #7
0
    async def add_candy_reaction(self, event, slack, registry):
        if event['reaction'] == 'bdfl' and event['user'] != event['item_user']:
            candy = registry.get('candy')
            user_count = await candy.add(event['item_user'])

            message_from = SlackMessage(
                to=(await slack.users.get(event['user'], dm=True)))
            message_from.text = 'You gave 1 {trigger} to <@{user}>'.format(
                trigger=self.config['candy']['trigger'],
                user=event['item_user'])

            message_to = SlackMessage(
                to=(await slack.users.get(event['item_user'], dm=True)))
            message_to.text = '<@{sender}> gave you 1 {trigger}. ' \
                              'You now have {user_count} {trigger}.'
            message_to.txt.format(
                sender=event['user'],
                trigger=self.config['candy']['trigger'],
                user_count=user_count
            )
            await slack.send(message_from)
            await slack.send(message_to)

        else:
            return
예제 #8
0
    async def hiring(self):
        slack = self.registry.get('slack')

        channel = await slack.channels.get(name='python_jobs')
        message = SlackMessage(to=channel)
        message.text = self.config['python_jobs']['hiring']
        await slack.send(message)

        message_tips = SlackMessage(to=channel)
        message_tips.text = self.config['python_jobs']['hiring_tips']
        message_tips.thread = message.thread
        await slack.send(message_tips)
예제 #9
0
    async def looking_for_job(self):
        slack = registry.get('slack')

        channel = await slack.channels.get(name='job_board')
        message = SlackMessage(to=channel)
        message.text = self.config['python_jobs']['looking']
        await slack.send(message)

        message_tips = SlackMessage(to=channel)
        message_tips.text = self.config['python_jobs']['looking_tips']
        message_tips.thread = message.thread
        await slack.send(message_tips)
예제 #10
0
    async def issues(self, event, registry):
        att = None

        if event['action'] == 'opened':
            att = self._issue_format(event, 'good')
        elif event['action'] == 'closed':
            att = self._issue_format(event, 'danger')

        if att:
            slack = registry.get('slack')
            channel = await slack.channels.get(
                name=self.config['github']['channel'])
            msg = SlackMessage(to=channel)
            msg.attachments.append(att)
            await slack.send(msg)
예제 #11
0
    async def pull_request(self, event, registry):
        att = None

        if event['action'] == 'opened':
            data = {'color': 'good', 'action': 'opened'}
            att = self._pull_request_format(event, data)
        elif event['action'] == 'closed':
            if event['pull_request']['merged']:
                data = {'color': '#6f42c1', 'action': 'merged'}
            else:
                data = {'color': 'danger', 'action': 'closed'}

            att = self._pull_request_format(event, data)

        if att:
            slack = registry.get('slack')
            channel = await slack.channels.get(
                name=self.config['github']['channel'])
            msg = SlackMessage(to=channel)
            msg.attachments.append(att)
            await slack.send(msg)