Already converted modules now use new Response class
This commit is contained in:
parent
5c5e0fbe8f
commit
637861b3ae
10 changed files with 173 additions and 127 deletions
|
|
@ -15,14 +15,14 @@ class Tinyfier(threading.Thread):
|
|||
if status == http.client.OK and len(page) < 100:
|
||||
srv = re.match(".*((ht|f)tps?://|www.)([^/ ]+).*", self.url)
|
||||
if srv is None:
|
||||
self.msg.send_chn("Mauvaise URL : %s" % (self.url))
|
||||
self.msg.srv.send_response(Response(self.msg.sender, "Mauvaise URL : %s" % (self.url), self.msg.channel))
|
||||
else:
|
||||
self.msg.send_chn("URL pour %s : %s" % (srv.group(3), page.decode()))
|
||||
self.msg.srv.send_response(Response(self.msg.sender, "URL pour %s : %s" % (srv.group(3), page.decode()), self.msg.channel))
|
||||
else:
|
||||
print ("ERROR: ycc.fr seem down?")
|
||||
self.msg.send_chn("La situation est embarassante, il semblerait que YCC soit down :(")
|
||||
self.msg.srv.send_response(Response(self.msg.sender, "La situation est embarassante, il semblerait que YCC soit down :(", self.msg.channel))
|
||||
|
||||
def getPage(s, p):
|
||||
def getPage(s, p):
|
||||
conn = http.client.HTTPConnection(s, timeout=10)
|
||||
try:
|
||||
conn.request("GET", p)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,12 @@ def help_tiny ():
|
|||
def help_full ():
|
||||
return "!ycc [<url>]: with an argument, reduce the given <url> thanks to ycc.fr; without argument, reduce the last URL said on the current channel."
|
||||
|
||||
def load(context):
|
||||
Tinyfier.Response = Response
|
||||
|
||||
def reload():
|
||||
imp.reload(Tinyfier)
|
||||
imp.reload(Tinyfier)
|
||||
Tinyfier.Response = Response
|
||||
|
||||
def cmd_ycc(msg):
|
||||
global LAST_URLS
|
||||
|
|
@ -27,17 +31,16 @@ def cmd_ycc(msg):
|
|||
t = Tinyfier.Tinyfier(url, msg)
|
||||
t.start()
|
||||
else:
|
||||
msg.send_chn("%s: je n'ai pas d'autre URL à réduire" % msg.nick)
|
||||
return Response(msg.sender, "je n'ai pas d'autre URL à réduire", msg.channel, nick=msg.nick)
|
||||
else:
|
||||
if len(msg.cmd) < 6:
|
||||
for url in msg.cmd[1:]:
|
||||
t = Tinyfier.Tinyfier(url, msg)
|
||||
t.start()
|
||||
else:
|
||||
msg.send_chn("%s: je ne peux pas réduire autant d'URL d'un seul"
|
||||
" coup." % msg.nick)
|
||||
return False
|
||||
return True
|
||||
return Response(msg.sender, "je ne peux pas réduire autant d'URL "
|
||||
"d'un seul coup.", msg.channel, nick=msg.nick)
|
||||
return False
|
||||
|
||||
LAST_URLS = dict()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue