Skip to content

Commit

Permalink
github: implement .gh-repo command, to set/view channel's linked repo
Browse files Browse the repository at this point in the history
Considering a special "clear" argument, but that's for later.
  • Loading branch information
dgw committed Mar 9, 2020
1 parent 5706007 commit a4d9e8a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sopel_modules/github/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,24 @@ def issue_info(bot, trigger, match=None):
bot.say(''.join(response))


@commands('gh-repo')
@example('.gh-repo sopel-irc/sopel-github')
@require_chanmsg('[GitHub] You can only link a repository to a channel.')
def manage_channel_repo(bot, trigger):
"""
Set the repository to use for looking up standalone issue/PR references.
"""
allowed = bot.channels[trigger.sender].privileges.get(trigger.nick, 0) >= OP
if not allowed and not trigger.admin:
return bot.say('You must be a channel operator to use this command!')

if not trigger.group(2):
return bot.say(bot.db.get_channel_value('github_issue_repo', trigger.sender))

bot.db.set_channel_value('github_issue_repo', trigger.sender, trigger.group(3))
bot.reply('Set linked repo for %s to %s.' % (trigger.sender, trigger.group(3)))


@url(commitURL)
def commit_info(bot, trigger, match=None):
match = match or trigger
Expand Down

0 comments on commit a4d9e8a

Please sign in to comment.