Skip to content

Instantly share code, notes, and snippets.

@issackelly
Created April 9, 2011 13:23
Show Gist options
  • Save issackelly/911398 to your computer and use it in GitHub Desktop.
Save issackelly/911398 to your computer and use it in GitHub Desktop.
"""/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