Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def service(bot, 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 bot.reply("Sorry, the service didn't respond in plain text.")
bytes = web.get(uri)
lines = bytes.splitlines()
if not lines:
return bot.reply("Sorry, the service didn't respond any output.")
bot.say(lines[0][:350])