-# def __init__(self, bot):
-# self.gitlab = None
-
- def configure(self, configuration):
- ## TODO: set up a connection to the gitlab API
-
- self.gitlab = gitlab.Gitlab(git_host,admin_token,verify_ssl=False)
-
-# notify_re = re.compile('notify_(.*)')
-
-# def get_mr_rooms(self, project_id):
-# """
-# Return a list of errbot room '<roomname>@domain' names which have a 'notify_<roomname>' label on the project
-# Log an error if you found a 'notify_<roomname>' but margebot isn't in a <roomname> room...
-# """
-# retval = []
-# labels = this.gitlab.getlabels(project_id)
-# for a_label in labels:
-# notify_match = self.notify_re.search(a_label['name'])
-# if notify_match:
-# roomname = notify_match.group(1)
-#
-# b_room_found = False
-# marge_rooms = xmpp.rooms()
-# for a_room in marge_rooms:
-# if a_room.node() == roomname:
-# retval.append(a_room.person()) # yeah rooms are people: person = node@domain
-# b_room_found = True
-# if not b_room_found:
-# self.log.error("Label of {} found, but margebot isn't tracking that room".format(roomname))
-# else:
-# retval.append(roomname)
-# return retval
-
- @webhook('/margebot/<rooms>/'
- def gitlab_hook(self, request):
+ def __init__(self, *args, **kwargs):
+ self.git_host = None
+ self.chatroom_host = None
+ super().__init__(*args, **kwargs)
+
+ def get_configuration_template(self):
+ return {'GIT_HOST': 'gitlab.example.com',
+ 'CHATROOM_HOST': 'conference.jabber.example.com'}
+
+ def check_configuration(self, configuration):
+ super().check_configuration(configuration)
+
+ def activate(self):
+ if not self.config:
+ self.log.info('Margebot is not configured. Forbid activation')
+ return
+ self.git_host = self.config['GIT_HOST']
+ self.chatroom_host = self.config['CHATROOM_HOST']
+ self.gitlab = gitlab.Gitlab(self.git_host,admin_token,verify_ssl=False)
+
+ super().activate()
+
+ def deactivate(self):
+ # TODO: Anything special for closing gitlab ?
+ super().deactivate()
+
+# def configure(self, configuration):
+# ## TODO: set up a connection to the gitlab API
+# if self.config:
+# self.gitlab = gitlab.Gitlab(self.git_host,admin_token,verify_ssl=False)
+
+ @webhook('/margebot/<rooms>/')
+ def gitlab_hook(self, request, rooms):