From d4b6283e232b93629b3b05938cdfa03ebbf26733 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sun, 29 Nov 2015 11:40:55 +0100 Subject: [PATCH] [github] new command to retrieve SSH keys --- modules/github.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/github.py b/modules/github.py index 924c06e..ddd0851 100644 --- a/modules/github.py +++ b/modules/github.py @@ -28,6 +28,11 @@ def info_user(username): return user +def user_keys(username): + keys = web.getURLContent("https://github.com/%s.keys" % quote(username)) + return keys.split('\n') + + def info_issue(repo, issue=None): rp = info_repos(repo) if rp["items"]: @@ -129,6 +134,23 @@ def cmd_github_user(msg): return res +@hook.command("github_user_keys", + help="Display user SSH keys", + help_usage={ + "USERNAME": "Show USERNAME's SSH keys", + }) +def cmd_github_user_keys(msg): + if not len(msg.args): + raise IMException("indicate a user name to search") + + res = Response(channel=msg.channel, nomore="No more keys") + + for k in user_keys(" ".join(msg.args)): + res.append_message(k) + + return res + + @hook.command("github_issue", help="Display repository's issues", help_usage={