def check_pastebin(c, s, t, ch, a): if len(a) > 0: nick = a[0] else: nick = '.*?' linkre = re.compile(linkexp.replace("NICK", nick)) conn = httplib.HTTPConnection(subdomain + '.pastebin.com') conn.request('GET', '/') r = conn.getresponse() bytes = r.read() if nick == ".*?": l = linkre.findall(bytes) for pair in l: if pair[1] in bot.channels[ch].users(): c.privmsg( t, "Recent pastebin by " + pair[1] + ": " + dodgefilter.url(pair[0], ch)) break else: c.privmsg(t, "No recent pastebin by anyone in " + ch + ".") else: m = linkre.search(bytes) if m: c.privmsg( t, "Recent pastebin by " + nick + ": " + dodgefilter.url(m.group(1), ch)) else: c.privmsg(t, "No recent pastebin by " + nick + ".")
def do_shorten(c, s, t, ch, a): url = ''.join(a) args = '?format=json&version=2.0.1&login=%s&apiKey=%s&longUrl=%s' % ("restorer", "R_70aec10678b8929cac02911479bfc9e7", url) conn = httplib.HTTPConnection('api.bit.ly') conn.request('GET', '/shorten'+args) r = conn.getresponse() bytes = r.read() results = json(bytes) print results tinyurl = results['results'][url]['shortUrl'] c.privmsg(t, dodgefilter.url(tinyurl, ch))
def generate_stats(c, s, t, ch, a): r = subprocess.call([pisgpath, '-co', bot.basedir + "/config/pisg.conf"]) if r == 0: c.privmsg( t, "Stats updated: " + dodgefilter.url(statsurl + chan_to_file(ch), ch)) else: c.privmsg( t, "Error running pisg (probably a config error?). Stats not updated." )
def do_shorten(c, s, t, ch, a): url = ''.join(a) args = '?format=json&version=2.0.1&login=%s&apiKey=%s&longUrl=%s' % ( "restorer", "R_70aec10678b8929cac02911479bfc9e7", url) conn = httplib.HTTPConnection('api.bit.ly') conn.request('GET', '/shorten' + args) r = conn.getresponse() bytes = r.read() results = json(bytes) print results tinyurl = results['results'][url]['shortUrl'] c.privmsg(t, dodgefilter.url(tinyurl, ch))
def do_search(c, s, t, ch, a): """Queries Google for the specified input.""" query = " ".join(a) if not query: return bot.replyError(c, t, "ERROR: no search terms specified") uri = result(query) if uri: c.privmsg(t, dodgefilter.url(uri, ch)) #if not hasattr(phenny.bot, 'last_seen_uri'): # phenny.bot.last_seen_uri = {} #phenny.bot.last_seen_uri[input.sender] = uri else: c.privmsg(t, "No results found for '%s'." % query)
def do_wiki(c, s, t, ch, a): query = ' '.join(a) args = '?format=json&action=opensearch&search=' + urllib.quote(query.encode('utf-8')) conn = httplib.HTTPConnection('en.wikipedia.org') conn.request('GET', '/w/api.php'+args) r = conn.getresponse() bytes = r.read() results = json(bytes) if len(results[1])>0: title = results[1][0].replace(' ', '_') url = "http://en.wikipedia.org/wiki/"+title c.privmsg(t, dodgefilter.url(url, ch)) else: c.privmsg(t, "No matching articles.")
def check_pastebin(c, s, t, ch, a): if len(a) > 0: nick = a[0] else: nick = '.*?' linkre = re.compile(linkexp.replace("NICK", nick)) conn = httplib.HTTPConnection(subdomain+'.pastebin.com') conn.request('GET', '/') r = conn.getresponse() bytes = r.read() if nick == ".*?": l = linkre.findall(bytes) for pair in l: if pair[1] in bot.channels[ch].users(): c.privmsg(t, "Recent pastebin by "+pair[1]+": "+dodgefilter.url(pair[0], ch)) break else: c.privmsg(t, "No recent pastebin by anyone in "+ch+".") else: m = linkre.search(bytes) if m: c.privmsg(t, "Recent pastebin by "+nick+": "+dodgefilter.url(m.group(1), ch)) else: c.privmsg(t, "No recent pastebin by "+nick+".")
def do_lasturl(c, s, t, ch, a): lu = lasturl.get(ch, "None seen.") c.privmsg(t, "Last URL: "+dodgefilter.url(lu, ch))
def print_url(c, s, t, ch, a): c.privmsg(t, "Stats: " + dodgefilter.url(statsurl + chan_to_file(ch), ch))
def print_url(c, s, t, ch, a): c.privmsg(t, "Stats: "+dodgefilter.url(statsurl+chan_to_file(ch), ch))
def generate_stats(c, s, t, ch, a): r = subprocess.call([pisgpath, '-co', bot.basedir+"/config/pisg.conf"]) if r == 0: c.privmsg(t, "Stats updated: "+dodgefilter.url(statsurl+chan_to_file(ch), ch)) else: c.privmsg(t, "Error running pisg (probably a config error?). Stats not updated.")