Created
April 9, 2011 13:23
-
-
Save issackelly/911398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""/doc <something>: return python 2.7's documentation for <something>""" | |
import re | |
import importlib | |
import pydoc | |
from chatbot import send, p | |
#by default, render_doc uses shell escapes. Stop that. | |
class PlainTextDoc(pydoc.TextDoc): | |
def bold(self, x): return x | |
pydoc.text = PlainTextDoc() | |
def on_message(message): | |
r = re.search(r"\/rtd ([\w.]+)( [\w.]+)?", message[u'message']) | |
if not r: return | |
project = r.group(1) | |
term = r.group(2) || "" | |
link = "http://%s.rtfd.org/%s" % (project, term) | |
send(message['topic']['id'], link) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment