-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgithub.py
46 lines (42 loc) · 2.85 KB
/
github.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Example post from github:
{u'forced': False,
u'compare': u'https://github.com/gbin/test/compare/b3cd9e66e52e...833392a49245',
u'pusher': {u'name': u'gbin', u'email': u'[email protected]'},
u'repository': {u'fork': False, u'has_wiki': True, u'name': u'test', u'has_downloads': True, u'url': u'https://github.com/gbin/test', u'created_at': u'2012-08-12T16:09:43-07:00', u'description': u'ignore this, this is for testing the new err github integration', u'private': False, u'pushed_at': u'2012-08-12T16:42:38-07:00', u'owner': {u'name': u'gbin', u'email': u'[email protected]'}, u'watchers': 0, u'open_issues': 0, u'has_issues': True, u'forks': 0, u'stargazers': 0, u'size': 128},
u'head_commit': {u'committer': {u'username': u'gbin', u'name': u'Guillaume BINET', u'email': u'[email protected]'},
u'added': [],
u'author': {u'username': u'gbin', u'name': u'Guillaume BINET', u'email': u'[email protected]'},
u'url': u'https://github.com/gbin/test/commit/833392a492453e6837173d7740c16f51e958e63f',
u'timestamp': u'2012-08-12T16:40:27-07:00',
u'modified': [u'README.md'],
u'distinct': True,
u'message': u'this time ?',
u'removed': [],
u'id': u'833392a492453e6837173d7740c16f51e958e63f'},
u'deleted': False,
u'commits': [{u'committer': {u'username': u'gbin', u'name': u'Guillaume BINET', u'email': u'[email protected]'},
u'added': [],
u'author': {u'username': u'gbin', u'name': u'Guillaume BINET', u'email': u'[email protected]'},
u'url': u'https://github.com/gbin/test/commit/833392a492453e6837173d7740c16f51e958e63f',
u'timestamp': u'2012-08-12T16:40:27-07:00',
u'modified': [u'README.md'],
u'distinct': True,
u'message': u'this time ?',
u'removed': [],
u'id': u'833392a492453e6837173d7740c16f51e958e63f'
],
u'after': u'833392a492453e6837173d7740c16f51e958e63f',
u'created': False,
u'ref': u'refs/heads/master',
u'before': u'b3cd9e66e52e4783c1a0b98fbaaad6258669275f'}
"""
from config import CHATROOM_PRESENCE
from errbot import BotPlugin
from errbot.builtins.webserver import webhook
class Github(BotPlugin):
min_err_version = '1.6.0'
@webhook(r'/github/', form_param = 'payload')
def gh_notifs(self, payload):
msg = 'Github commits on %s:\n' % payload['repository']['name'] + '\n'.join(("%s: %s [ %s ] " % (commit['author']['name'], commit['message'], commit['url']) for commit in payload['commits']))
self.send(CHATROOM_PRESENCE[0], msg, message_type='groupchat')