home
·
contact
·
privacy
projects
/
plomlombot-irc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Shorten default timeout.
[plomlombot-irc.git]
/
plomlombot.py
diff --git
a/plomlombot.py
b/plomlombot.py
index b312eb261d6c79610acd15882a2737fb81f49aa4..2d2d885d9436b13f97223a5bc3c897634a09e36b 100644
(file)
--- a/
plomlombot.py
+++ b/
plomlombot.py
@@
-1,13
+1,15
@@
import socket
import socket
-import datetime
+import datetime
import select
import time
import re
import urllib.request
import html
import select
import time
import re
import urllib.request
import html
+servernet = "irc.freenode.net"
+port = 6667
servername = ""
servername = ""
-timeout =
48
0
+timeout =
24
0
username = "plomlombot"
nickname = username
channel = "#zrolaps"
username = "plomlombot"
nickname = username
channel = "#zrolaps"
@@
-69,7
+71,7
@@
class IO:
line)
return line
line)
return line
-io = IO(
"irc.freenode.net", 6667
)
+io = IO(
servernet, port
)
io.send_line("NICK " + nickname)
io.send_line("USER " + username + " 0 * : ")
io.send_line("JOIN " + channel)
io.send_line("NICK " + nickname)
io.send_line("USER " + username + " 0 * : ")
io.send_line("JOIN " + channel)
@@
-101,6
+103,10
@@
while 1:
for i in range(len(matches)):
url = matches[i]
webpage = urllib.request.urlopen(url)
for i in range(len(matches)):
url = matches[i]
webpage = urllib.request.urlopen(url)
+ content_type = webpage.info().get_content_type()
+ if not content_type in ('text/html', 'text/xml',
+ 'application/xhtml+xml'):
+ continue
charset = webpage.info().get_content_charset()
content = webpage.read().decode(charset)
title = str(content).split('<title>')[1].split('</title>')[0]
charset = webpage.info().get_content_charset()
content = webpage.read().decode(charset)
title = str(content).split('<title>')[1].split('</title>')[0]