Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 6a114a0

Browse files
author
Bryce Verdier
committed
Adding script to get a url from docs.python.org/library.
1 parent bc45632 commit 6a114a0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/scripts/python_library.coffee

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Description:
2+
# Allows hubot to get the link to a Python 2 or 3 libaray.
3+
#
4+
# Dependencies:
5+
# None
6+
#
7+
# Commands:
8+
# hubot python(2|3) library <name> - Gets the url of the named library if it exists.
9+
#
10+
# Author:
11+
# Bryce Verdier (btv)
12+
13+
module.exports = (robot) ->
14+
robot.respond /python(2|3) library (.*)/i, (msg) ->
15+
matches = msg.match
16+
libraryMe robot, matches[1], matches[2], (text) ->
17+
msg.send text
18+
19+
libraryMe = (robot, version, lib, callback) ->
20+
url = "http://docs.python.org/#{version}/library/#{lib}.html"
21+
robot.http(url)
22+
.get() (err,res,body) ->
23+
if res.statusCode != 200
24+
callback "MERP! The library #{lib} does not exist!"
25+
else
26+
callback url
27+

0 commit comments

Comments
 (0)