Skip to content

Commit

Permalink
labhub.py: Add error message when nick is empty
Browse files Browse the repository at this point in the history
All of the backends do not have `nick` attribute.
Hence an error will be shown whenever nick is empty.

Closes coala#632
  • Loading branch information
abhishalya committed Nov 2, 2018
1 parent b9d569d commit c3601ee
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/labhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def team_mapping(self):
@cmdfilter
def members_only(self, msg, cmd, args, dry_run):
user = msg.frm.nick
if not user:
self.log.exception('No attribute named nick')
return None, None, None

commands = constants.PRIVATE_CMDS

if cmd in commands:
Expand Down Expand Up @@ -122,6 +126,9 @@ def invite_cmd(self, msg, match):
"""
invitee = match.group(1)
inviter = msg.frm.nick
if not inviter:
self.log.exception('No attribute named nick')
return

team = 'newcomers' if match.group(2) is None else match.group(2)
team = team.lower()
Expand Down Expand Up @@ -180,6 +187,9 @@ def callback_message(self, msg):
"""Invite the user whose message includes the holy 'hello world'"""
if re.search(r'hello\s*,?\s*world', msg.body, flags=re.IGNORECASE):
user = msg.frm.nick
if not user:
self.log.exception('No attribute named nick')
return
if (not self.is_team_member(user, 'newcomers')
and user not in self.hello_world_users):
response = tenv().get_template(
Expand All @@ -196,6 +206,9 @@ def callback_message(self, msg):
def create_issue_cmd(self, msg, match):
"""Create issues on GitHub and GitLab repositories.""" # Ignore QuotesBear, LineLengthBear, PyCodeStyleBear
user = msg.frm.nick
if not user:
self.log.exception('No attribute named nick')
return
repo_name = match.group(1)
iss_title = match.group(2)
iss_description = match.group(3) if match.group(3) is not None else ''
Expand Down Expand Up @@ -234,6 +247,9 @@ def unassign_cmd(self, msg, match):
issue_number = match.group(4)

user = msg.frm.nick
if not user:
self.log.exception('No attribute named nick')
return

try:
assert org == self.GH_ORG_NAME or org == self.GL_ORG_NAME
Expand Down Expand Up @@ -317,6 +333,9 @@ def assign_cmd(self, msg, match):
iss_number = match.group(4)

user = msg.frm.nick
if not user:
self.log.exception('No attribute named nick')
return

try:
assert org == self.GH_ORG_NAME or org == self.GL_ORG_NAME
Expand Down

0 comments on commit c3601ee

Please sign in to comment.