.format
This commit is contained in:
parent
2812569593
commit
7ab4f756fe
22 changed files with 69 additions and 78 deletions
|
@ -19,7 +19,7 @@ def permissions(inp, bot=None, notice=None):
|
|||
for k in permissions:
|
||||
groups.append(k)
|
||||
if not groups:
|
||||
notice("%s is not a group with permissions" % inp)
|
||||
notice("{} is not a group with permissions".format(inp))
|
||||
return None
|
||||
|
||||
for v in groups:
|
||||
|
@ -27,10 +27,10 @@ def permissions(inp, bot=None, notice=None):
|
|||
for value in permissions[v]["users"]:
|
||||
members = members + value + ", "
|
||||
if members:
|
||||
notice("the members in the %s group are.." % v)
|
||||
notice("the members in the {} group are..".format(v))
|
||||
notice(members[:-2])
|
||||
else:
|
||||
notice("there are no members in the %s group" % v)
|
||||
notice("there are no members in the {} group".format(v))
|
||||
|
||||
|
||||
@hook.command(permissions=["permissions_users"])
|
||||
|
@ -51,7 +51,7 @@ def deluser(inp, bot=None, notice=None):
|
|||
if specgroup == k:
|
||||
groups.append(k)
|
||||
if not groups:
|
||||
notice("%s is not a group with permissions" % inp[1])
|
||||
notice("{} is not a group with permissions".format(inp[1]))
|
||||
return None
|
||||
|
||||
removed = 0
|
||||
|
@ -61,14 +61,14 @@ def deluser(inp, bot=None, notice=None):
|
|||
if inp[0] == value:
|
||||
users.remove(inp[0])
|
||||
removed = 1
|
||||
notice("%s has been removed from the group %s" % (inp[0], v))
|
||||
notice("{} has been removed from the group {}".format(inp[0], v))
|
||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||
if specgroup:
|
||||
if removed == 0:
|
||||
notice("%s is not in the group %s" % (inp[0], specgroup))
|
||||
notice("{} is not in the group {}".format(inp[0], specgroup))
|
||||
else:
|
||||
if removed == 0:
|
||||
notice("%s is not in any groups" % inp[0])
|
||||
notice("{} is not in any groups".format(inp[0]))
|
||||
|
||||
|
||||
@hook.command(permissions=["permissions_users"])
|
||||
|
@ -89,14 +89,14 @@ def adduser(inp, bot=None, notice=None):
|
|||
try:
|
||||
users = permissions[targetgroup]["users"]
|
||||
except KeyError:
|
||||
notice("no such group as %s" % targetgroup)
|
||||
notice("no such group as {}".format(targetgroup))
|
||||
return None
|
||||
if user in users:
|
||||
notice("%s is already in %s" % (user, targetgroup))
|
||||
notice("{} is already in {}".format(user, targetgroup))
|
||||
return None
|
||||
|
||||
users.append(user)
|
||||
notice("%s has been added to the group %s" % (user, targetgroup))
|
||||
notice("{} has been added to the group {}".format(user, targetgroup))
|
||||
users.sort()
|
||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||
|
||||
|
@ -106,9 +106,9 @@ def adduser(inp, bot=None, notice=None):
|
|||
def stop(inp, nick=None, conn=None):
|
||||
"""stop [reason] -- Kills the bot with [reason] as its quit message."""
|
||||
if inp:
|
||||
conn.cmd("QUIT", ["Killed by %s (%s)" % (nick, inp)])
|
||||
conn.cmd("QUIT", ["Killed by {} ({})".format(nick, inp)])
|
||||
else:
|
||||
conn.cmd("QUIT", ["Killed by %s." % nick])
|
||||
conn.cmd("QUIT", ["Killed by {}.".format(nick)])
|
||||
time.sleep(5)
|
||||
os.execl("./cloudbot", "cloudbot", "stop")
|
||||
|
||||
|
@ -117,9 +117,9 @@ def stop(inp, nick=None, conn=None):
|
|||
def restart(inp, nick=None, conn=None):
|
||||
"""restart [reason] -- Restarts the bot with [reason] as its quit message."""
|
||||
if inp:
|
||||
conn.cmd("QUIT", ["Restarted by %s (%s)" % (nick, inp)])
|
||||
conn.cmd("QUIT", ["Restarted by {} ({})".format(nick, inp)])
|
||||
else:
|
||||
conn.cmd("QUIT", ["Restarted by %s." % nick])
|
||||
conn.cmd("QUIT", ["Restarted by {}.".format(nick)])
|
||||
time.sleep(5)
|
||||
os.execl("./cloudbot", "cloudbot", "restart")
|
||||
|
||||
|
@ -133,7 +133,7 @@ def clearlogs(inp, input=None):
|
|||
@hook.command(permissions=["botcontrol"])
|
||||
def join(inp, conn=None, notice=None):
|
||||
"""join <channel> -- Joins <channel>."""
|
||||
notice("Attempting to join %s..." % inp)
|
||||
notice("Attempting to join {}...".format(inp))
|
||||
conn.join(inp)
|
||||
|
||||
|
||||
|
@ -146,7 +146,7 @@ def part(inp, conn=None, chan=None, notice=None):
|
|||
target = inp
|
||||
else:
|
||||
target = chan
|
||||
notice("Attempting to leave %s..." % target)
|
||||
notice("Attempting to leave {}...".format(target))
|
||||
conn.part(target)
|
||||
|
||||
|
||||
|
@ -159,7 +159,7 @@ def cycle(inp, conn=None, chan=None, notice=None):
|
|||
target = inp
|
||||
else:
|
||||
target = chan
|
||||
notice("Attempting to cycle %s..." % target)
|
||||
notice("Attempting to cycle {}...".format(target})
|
||||
conn.part(target)
|
||||
conn.join(target)
|
||||
|
||||
|
@ -170,7 +170,7 @@ def nick(inp, notice=None, conn=None):
|
|||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
||||
notice("Invalid username!")
|
||||
return
|
||||
notice("Attempting to change nick to \"%s\"..." % inp)
|
||||
notice("Attempting to change nick to \"{}\"...".format(inp))
|
||||
conn.set_nick(inp)
|
||||
|
||||
|
||||
|
@ -189,10 +189,10 @@ def say(inp, conn=None, chan=None):
|
|||
inp = inp.split(" ")
|
||||
if inp[0][0] == "#":
|
||||
message = " ".join(inp[1:])
|
||||
out = "PRIVMSG %s :%s" % (inp[0], message)
|
||||
out = "PRIVMSG {} :{}".format(inp[0], message)
|
||||
else:
|
||||
message = " ".join(inp[0:])
|
||||
out = "PRIVMSG %s :%s" % (chan, message)
|
||||
out = "PRIVMSG {} :{}".format(chan, message)
|
||||
conn.send(out)
|
||||
|
||||
|
||||
|
@ -208,11 +208,11 @@ def me(inp, conn=None, chan=None):
|
|||
for x in inp[1:]:
|
||||
message = message + x + " "
|
||||
message = message[:-1]
|
||||
out = "PRIVMSG %s :\x01ACTION %s\x01" % (inp[0], message)
|
||||
out = "PRIVMSG {} :\x01ACTION {}\x01".format(inp[0], message)
|
||||
else:
|
||||
message = ""
|
||||
for x in inp[0:]:
|
||||
message = message + x + " "
|
||||
message = message[:-1]
|
||||
out = "PRIVMSG %s :\x01ACTION %s\x01" % (chan, message)
|
||||
out = "PRIVMSG {} :\x01ACTION {}\x01".format(chan, message)
|
||||
conn.send(out)
|
||||
|
|
Reference in a new issue