def output(self, channel, user, options): args = options.args try: m = re.match(r'^%(\d)$', args) if m: args = self._last5urls[channel][int(m.group(1))-1] except Exception: r = None self._bot.notice(user.nick, 'No url exists for %' + m.group(1)) else: if args.find('://', 0, 10) == -1: args = 'http://' + args if options.list: r = args elif options.title: r = Url.title(args) elif options.content: r = Url.content_type(args) elif options.preview: r = Url.description(args) elif options.short: r = Url.googleshort(args) elif options.expand: r = Url.googleexpand(args) elif options.port: r = Url.port(args, options.port) elif options.dns: r = Url.dns(args) if r: if options.private: self._bot.notice(user.nick, r) else: return ModuleResult('%s, %s' % (r, user.nick))
def append_if_url(self, channel, msg): ''' @param msg: ''' m = self._regex_url.search(msg) if m is not None: if not self._last5urls.has_key(channel): self._last5urls[channel] = [] sz = len(self._last5urls[channel]) if sz == 5: self._last5urls[channel].pop() if sz == 0 or (sz and self._last5urls[channel][0] != m.group(0)): self._last5urls[channel].insert(0, m.group(0)) if self._bot.has_status('url'): r = Url.title(m.group(0), only_title=True) if r: self._bot.say(channel, r)