urlinfo: fix some NoneType attribute errors
This commit is contained in:
parent
fe79f444cf
commit
ceb3002281
@ -44,7 +44,18 @@ class URLInfo(Plugin):
|
||||
|
||||
bytes_io.seek(0)
|
||||
tree = etree.parse(bytes_io, etree.HTMLParser()).getroot()
|
||||
title_elements = tree.xpath("/html/head/title")
|
||||
if len(title_elements) > 0:
|
||||
self.bot.privmsg(target, '\x02[URLInfo]\x02 ' + title_elements[0].text.strip())
|
||||
if tree is None:
|
||||
return
|
||||
|
||||
title_elements = tree.xpath("/html/head/title")
|
||||
if len(title_elements) == 0:
|
||||
return
|
||||
|
||||
title = title_elements[0].text
|
||||
if title is None:
|
||||
return
|
||||
|
||||
title = title.strip()
|
||||
if title:
|
||||
self.bot.privmsg(target, '\x02[URLInfo]\x02 ' + title)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user