mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-27 05:21:10 -05:00
RelayLink/TLDInfo: py3 compat && PkgInfo: simplify imports (ref #12)
This commit is contained in:
parent
0a718f25f8
commit
4dc9dd9cbc
@ -34,16 +34,15 @@ import supybot.plugins as plugins
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
from collections import OrderedDict, defaultdict
|
from collections import OrderedDict, defaultdict
|
||||||
try:
|
try: # Python 3
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
except ImportError:
|
from html.parser import HTMLParser
|
||||||
|
except ImportError: # Python 2
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
from HTMLParser import HTMLParser
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
try:
|
|
||||||
from HTMLParser import HTMLParser
|
|
||||||
except ImportError:
|
|
||||||
from html.parser import HTMLParser
|
|
||||||
try:
|
try:
|
||||||
from supybot.i18n import PluginInternationalization
|
from supybot.i18n import PluginInternationalization
|
||||||
_ = PluginInternationalization('PkgInfo')
|
_ = PluginInternationalization('PkgInfo')
|
||||||
|
@ -303,7 +303,11 @@ class RelayLink(callbacks.Plugin):
|
|||||||
args['oldnick'] = '\x03%s%s\x03' % (self.simpleHash(msg.nick), args['oldnick'])
|
args['oldnick'] = '\x03%s%s\x03' % (self.simpleHash(msg.nick), args['oldnick'])
|
||||||
args['newnick'] = '\x03%s%s\x03' % (self.simpleHash(msg.args[0]), args['newnick'])
|
args['newnick'] = '\x03%s%s\x03' % (self.simpleHash(msg.args[0]), args['newnick'])
|
||||||
s = '%(network)s%(oldnick)s is now known as %(newnick)s'
|
s = '%(network)s%(oldnick)s is now known as %(newnick)s'
|
||||||
for (channel, c) in irc.state.channels.iteritems():
|
try:
|
||||||
|
chandict = irc.state.channels.iteritems()
|
||||||
|
except AttributeError: # Python 3 compatibility
|
||||||
|
chandict = irc.state.channels.items()
|
||||||
|
for (channel, c) in chandict:
|
||||||
if msg.args[0] in c.users:
|
if msg.args[0] in c.users:
|
||||||
self.sendToOthers(irc, channel, s, args)
|
self.sendToOthers(irc, channel, s, args)
|
||||||
|
|
||||||
|
@ -53,7 +53,10 @@ class TLDInfo(callbacks.Plugin):
|
|||||||
db = "http://www.iana.org/domains/root/db/"
|
db = "http://www.iana.org/domains/root/db/"
|
||||||
text = text.split(".")[-1] # IANA's DB doesn't care about second level domains
|
text = text.split(".")[-1] # IANA's DB doesn't care about second level domains
|
||||||
# Encode everything in IDN in order to support international TLDs
|
# Encode everything in IDN in order to support international TLDs
|
||||||
|
try: # Python 2
|
||||||
s = text.decode("utf8").encode("idna")
|
s = text.decode("utf8").encode("idna")
|
||||||
|
except AttributeError: # Python 3
|
||||||
|
s = text.encode("idna").decode()
|
||||||
try:
|
try:
|
||||||
data = utils.web.getUrl(db + s)
|
data = utils.web.getUrl(db + s)
|
||||||
except utils.web.Error as e:
|
except utils.web.Error as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user