Commit 1d486751 authored by Abhijith PA's avatar Abhijith PA
Browse files

Merge branch 'balasankarc' into 'master'

Manage issue opening/closing/reopening

Also ran autopep8 for ensuring PEP8 Compliancy.

See merge request !1
parents 806474da 8c5fb793
......@@ -38,12 +38,12 @@ class MUCBot(sleekxmpp.ClientXMPP):
"""
A bot which messages to group chat when creating/commenting
issues of a specified gitlab/github project (webhooks)
issues of a specified gitlab/github project (webhooks)
"""
def __init__(self, jid, password, room, nick):
sleekxmpp.ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
# The session_start event will be triggered when
......@@ -53,11 +53,9 @@ class MUCBot(sleekxmpp.ClientXMPP):
# our roster.
self.add_event_handler("session_start", self.start)
self.add_event_handler("muc::%s::got_online" % self.room,
self.muc_online)
def start(self, event):
"""
Process the session_start event.
......@@ -79,31 +77,27 @@ class MUCBot(sleekxmpp.ClientXMPP):
# password=the_room_password,
wait=True)
app = Flask(__name__)
@app.route('/',methods=['POST'])
@app.route('/', methods=['POST'])
def foo():
data = json.loads(request.data)
#message="null"
m1 = data["user"]["username"]
m2 = data["object_attributes"]["title"]
m3 = data["object_attributes"]["url"]
#m4 = data["object_attributes"]["note"]
#m5 = data["issue"]["title"]
#if "issue" == data["object_kind"]:
message=m1 + " created a new issue:--> " + m2 + " " + m3
# else:
#message=m1 + 'commented: ' + m4 + 'on issue:: ' + m5 + m3
#try:
self.send_message(mto=self.room,mbody=message,mtype='groupchat')
#except:
# sys.exc_info()[0]
return "OK"
data = json.loads(request.data)
issue_id = data['object_attributes']['iid']
issue_title = data['object_attributes']['title']
issue_user = data['user']['name']
state = data['object_attributes']['state']
msg = "Issue #%d '%s' - %s by %s" % (issue_id,
issue_title,
state,
issue_user
)
self.send_message(mto=self.room, mbody=msg, mtype='groupchat')
return "OK"
if __name__ == '__main__':
app.run(host= '0.0.0.0')
app.run(host='0.0.0.0')
def muc_online(self, presence):
return
if __name__ == '__main__':
# Setup the command line arguments.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment