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