You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
871 B
33 lines
871 B
#!/ysr/bin/env python3 |
|
|
|
""" |
|
.. module::LMGTFY |
|
:synopsis: LMGTFY |
|
.. moduleauthor::Nick Krichevsky <nick@ollien.com> |
|
""" |
|
|
|
import urllib.parse |
|
from pyircbot.modulebase import ModuleBase, command |
|
from pyircbot.modules.ModInfo import info |
|
|
|
BASE_URL = "http://lmgtfy.com/?q=" |
|
|
|
|
|
class LMGTFY(ModuleBase): |
|
|
|
@info("lmgtfy <term> display a condescending internet query", cmds=["lmgtfy"]) |
|
@command("lmgtfy", require_args=True) |
|
def handleMessage(self, msg, cmd): |
|
message = msg.trailing.split(" ")[1:] |
|
link = self.createLink(message) |
|
self.bot.act_PRIVMSG(msg.args[0], "%s: %s" % (msg.prefix.nick, link)) |
|
|
|
def createLink(self, message): |
|
finalUrl = BASE_URL |
|
|
|
for word in message: |
|
finalUrl += urllib.parse.quote(word) |
|
if word != message[-1]: |
|
finalUrl += "+" |
|
|
|
return finalUrl
|
|
|