Files @ 9d8b64cd0db0
Branch filter:

Location: integration/matrix/__init__.py

andrewsh
Initial version.
MATRIX_USERNAME = '@user:matrix.org'
MATRIX_PASSWORD = 'password'

### To get the token, uncomment the following lines:

# from matrix_client.client import MatrixClient

# client = MatrixClient("https://matrix.org:8448")
# token = client.login_with_password(username=MATRIX_USERNAME, password=MATRIX_PASSWORD)
# print "Token: %s" token

MATRIX_TOKEN = 'Eichijoh9Eiph9ShooReih3igooSoh1Aeweequ0iej5quae0Sithei9aequahPhaiceu2taewoi8ung2tie9soh8eew2oucieg6aiseiX1aeQu9oe3eerah7hohB9reR'

room = '!fo2yie8Eo8:matrix.org'

from matrix_client.api import MatrixHttpApi
matrix = MatrixHttpApi("https://matrix.org", token=MATRIX_TOKEN)

#==============================================================================
# POST PUSH HOOK
#==============================================================================

# this function will be executed after each push it's executed after the
# build-in hook that Kallithea uses for logging pushes
def _pushhook(*args, **kwargs):
    """
    Post push hook
    kwargs available:

      :param server_url: url of instance that triggered this hook
      :param config: path to .ini config used
      :param scm: type of VS 'git' or 'hg'
      :param username: name of user who pushed
      :param ip: ip of who pushed
      :param action: push
      :param repository: repository name
      :param pushed_revs: list of pushed revisions
    """
    commits = len(kwargs['pushed_revs'])
    response = matrix.send_message(room, "%s has pushed %s %s to the repository %s/%s" % (kwargs['username'], commits, "commit" if commits == 1 else "commits", kwargs['server_url'], kwargs['repository']))
    return 0

PUSH_HOOK = _pushhook