Core format string changes.
This commit is contained in:
parent
015dd93df3
commit
1ce777a5e4
3 changed files with 12 additions and 13 deletions
|
@ -22,7 +22,7 @@ def censor(text):
|
|||
if 'censored_strings' in bot.config:
|
||||
if bot.config['censored_strings']:
|
||||
words = map(re.escape, bot.config['censored_strings'])
|
||||
regex = re.compile('(%s)' % "|".join(words))
|
||||
regex = re.compile('({})'.format("|".join(words)))
|
||||
text = regex.sub(replacement, text)
|
||||
return text
|
||||
|
||||
|
@ -194,7 +194,7 @@ class IRC(object):
|
|||
|
||||
def join(self, channel):
|
||||
""" makes the bot join a channel """
|
||||
self.send("JOIN %s" % channel)
|
||||
self.send("JOIN {}".format(channel))
|
||||
if channel not in self.channels:
|
||||
self.channels.append(channel)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class Input(dict):
|
|||
conn.msg(chan, '(' + nick + ') ' + msg)
|
||||
|
||||
def me(msg, chan=chan):
|
||||
conn.msg(chan, "\x01%s %s\x01" % ("ACTION", msg))
|
||||
conn.msg(chan, "\x01{} {}\x01".format("ACTION", msg))
|
||||
|
||||
def notice(msg, nick=nick):
|
||||
conn.cmd('NOTICE', [nick, msg])
|
||||
|
@ -154,9 +154,9 @@ def main(conn, out):
|
|||
if inp.command == 'PRIVMSG':
|
||||
# COMMANDS
|
||||
if inp.chan == inp.nick: # private message, no command prefix
|
||||
prefix = '^(?:[%s]?|' % command_prefix
|
||||
prefix = '^(?:[{}]?|'.format(command_prefix)
|
||||
else:
|
||||
prefix = '^(?:[%s]|' % command_prefix
|
||||
prefix = '^(?:[%s]|'.format(command_prefix)
|
||||
|
||||
command_re = prefix + inp.conn.nick
|
||||
command_re += r'[,;:]+\s+)(\w+)(?:$|\s+)(.*)'
|
||||
|
@ -169,7 +169,7 @@ def main(conn, out):
|
|||
|
||||
if isinstance(command, list): # multiple potential matches
|
||||
input = Input(conn, *out)
|
||||
input.notice("Did you mean %s or %s?" %
|
||||
input.notice("Did you mean {} or {}?".format
|
||||
(', '.join(command[:-1]), command[-1]))
|
||||
elif command in bot.commands:
|
||||
input = Input(conn, *out)
|
||||
|
|
|
@ -18,7 +18,7 @@ def make_signature(f):
|
|||
|
||||
|
||||
def format_plug(plug, kind='', lpad=0):
|
||||
out = ' ' * lpad + '%s:%s:%s' % make_signature(plug[0])
|
||||
out = ' ' * lpad + '{}:{}:{}'.format(make_signature(plug[0]))
|
||||
if kind == 'command':
|
||||
out += ' ' * (50 - len(out)) + plug[1]['name']
|
||||
|
||||
|
@ -118,13 +118,12 @@ def reload(init=False):
|
|||
for plug in bot.plugs['command']:
|
||||
name = plug[1]['name'].lower()
|
||||
if not re.match(r'^\w+$', name):
|
||||
print '### ERROR: invalid command name "%s" (%s)' % (name,
|
||||
format_plug(plug))
|
||||
print '### ERROR: invalid command name "{}" ({})'.format(name, format_plug(plug))
|
||||
continue
|
||||
if name in bot.commands:
|
||||
print "### ERROR: command '%s' already registered (%s, %s)" % \
|
||||
(name, format_plug(bot.commands[name]),
|
||||
format_plug(plug))
|
||||
print "### ERROR: command '{}' already registered ({}, {})".format(name,
|
||||
format_plug(bot.commands[name]),
|
||||
format_plug(plug))
|
||||
continue
|
||||
bot.commands[name] = plug
|
||||
|
||||
|
@ -155,7 +154,7 @@ def reload(init=False):
|
|||
for kind, plugs in sorted(bot.plugs.iteritems()):
|
||||
if kind == 'command':
|
||||
continue
|
||||
print ' %s:' % kind
|
||||
print ' {}:'.format(kind)
|
||||
for plug in plugs:
|
||||
print format_plug(plug, kind=kind, lpad=6)
|
||||
print
|
||||
|
|
Reference in a new issue