logo

scripts

A bunch of scripts, some to be moved to their own repository
commit: 8e1f4c215db0cf82aa57c9bc3f21615183e69379
parent: 18b2ff82942f3bb7b57540ab67e6c8c757144e7e
Author: lanodan <lanodan.delta@free.fr>
Date:   Wed, 12 Mar 2014 21:11:45 +0100

URL Parser

Diffstat:

DIRCBot/.IRCBot.py.swo0
MIRCBot/.IRCBot.py.swp0
DIRCBot/.config.ini.swp0
MIRCBot/IRCBot.py9++++-----
4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/IRCBot/.IRCBot.py.swo b/IRCBot/.IRCBot.py.swo Binary files differ. diff --git a/IRCBot/.IRCBot.py.swp b/IRCBot/.IRCBot.py.swp Binary files differ. diff --git a/IRCBot/.config.ini.swp b/IRCBot/.config.ini.swp Binary files differ. diff --git a/IRCBot/IRCBot.py b/IRCBot/IRCBot.py @@ -67,11 +67,9 @@ while 1: #puts it in a loop t = text.split(':!say') #you can change t and to :) to = t[1].strip() #this code is for getting the first word after !hi irc.send('PRIVMSG '+channel+' :'+str(to)+'\n') - if text.find('http://') != -1: - t = text.split('http://') - line = t[1].strip() - t = line.split() - url = 'http://'+t[0].strip() + if text.find('http') != -1: + parse = re.findall('https?://[^\"\'\(\)\[\]\{\}\<\>]+', text) + url = str(parse[0]).rstrip() #took the first link and remove newline and whitespaces if check_url(url): get = urllib.urlopen(url) wget = get.read() @@ -79,6 +77,7 @@ while 1: #puts it in a loop if wget.find('<title>') != -1: title = get_title(wget) irc.send('PRIVMSG '+channel+' :('+url+')Title: '+title+' \n') + print '('+url+')Title: '+title if text.find(':!stop in the name of sey') != -1: irc.send('QUIT : '+quitMsg+'\n') sys.exit(0)