mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-26 04:51:08 -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.callbacks as callbacks
|
||||
from collections import OrderedDict, defaultdict
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
try: # Python 3
|
||||
from urllib.parse import urlencode
|
||||
from html.parser import HTMLParser
|
||||
except ImportError: # Python 2
|
||||
from urllib import urlencode
|
||||
from HTMLParser import HTMLParser
|
||||
import json
|
||||
import re
|
||||
try:
|
||||
from HTMLParser import HTMLParser
|
||||
except ImportError:
|
||||
from html.parser import HTMLParser
|
||||
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('PkgInfo')
|
||||
|
@ -303,7 +303,11 @@ class RelayLink(callbacks.Plugin):
|
||||
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'])
|
||||
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:
|
||||
self.sendToOthers(irc, channel, s, args)
|
||||
|
||||
|
@ -53,7 +53,10 @@ class TLDInfo(callbacks.Plugin):
|
||||
db = "http://www.iana.org/domains/root/db/"
|
||||
text = text.split(".")[-1] # IANA's DB doesn't care about second level domains
|
||||
# Encode everything in IDN in order to support international TLDs
|
||||
s = text.decode("utf8").encode("idna")
|
||||
try: # Python 2
|
||||
s = text.decode("utf8").encode("idna")
|
||||
except AttributeError: # Python 3
|
||||
s = text.encode("idna").decode()
|
||||
try:
|
||||
data = utils.web.getUrl(db + s)
|
||||
except utils.web.Error as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user