Ejemplo n.º 1
0
def shortenIt(willie, trigger):
	if not trigger.group(2):
		return willie.reply("No url.")
	query = trigger.group(2)
	if query.startswith('www'):
		query = 'http://' + query

	try:
		response = web.head(query)
	except ValueError, e:
		return willie.reply('something tells me thats not a real url')
Ejemplo n.º 2
0
def service(willie, trigger, command, args):
    t = o.services[command]
    template = t.replace('${args}', urllib.quote(args.encode('utf-8'), ''))
    template = template.replace('${nick}', urllib.quote(trigger.nick, ''))
    uri = template.replace('${sender}', urllib.quote(trigger.sender, ''))

    info = web.head(uri)
    if isinstance(info, list):
        info = info[0]
    if not 'text/plain' in info.get('content-type', '').lower():
        return willie.reply("Sorry, the service didn't respond in plain text.")
    bytes = web.get(uri)
    lines = bytes.splitlines()
    if not lines:
        return willie.reply("Sorry, the service didn't respond any output.")
    willie.say(lines[0][:350])
Ejemplo n.º 3
0
def service(willie, trigger, command, args):
    t = o.services[command]
    template = t.replace('${args}', urllib.quote(args.encode('utf-8'), ''))
    template = template.replace('${nick}', urllib.quote(trigger.nick, ''))
    uri = template.replace('${sender}', urllib.quote(trigger.sender, ''))

    info = web.head(uri)
    if isinstance(info, list):
        info = info[0]
    if not 'text/plain' in info.get('content-type', '').lower():
        return willie.reply("Sorry, the service didn't respond in plain text.")
    bytes = web.get(uri)
    lines = bytes.splitlines()
    if not lines:
        return willie.reply("Sorry, the service didn't respond any output.")
    willie.say(lines[0][:350])