move parameter count check
This commit is contained in:
parent
1a7b63055b
commit
865f9b8b46
55
tracer.py
55
tracer.py
|
@ -68,8 +68,7 @@ populate()
|
||||||
def generate(rule):
|
def generate(rule):
|
||||||
populate()
|
populate()
|
||||||
if rule in DB:
|
if rule in DB:
|
||||||
g = random.choice(DB[rule])
|
return grammar(load_rules(random.choice(DB[rule]))).flatten("#origin#")
|
||||||
return grammar(load_rules(g)).flatten("#origin#")
|
|
||||||
|
|
||||||
|
|
||||||
def listify(col):
|
def listify(col):
|
||||||
|
@ -103,35 +102,30 @@ def fuse(argv):
|
||||||
|
|
||||||
def think(line):
|
def think(line):
|
||||||
words = line.params[1].split(" ")
|
words = line.params[1].split(" ")
|
||||||
|
if words[0] == "!!list":
|
||||||
if len(words) > 0:
|
return " ".join(DB)
|
||||||
if words[0] == "!!list":
|
elif words[0] == "!!source":
|
||||||
return " ".join(DB)
|
return REPOLINK
|
||||||
elif words[0] == "!!source":
|
elif words[0] in ["!!help", "!botlist"]:
|
||||||
return REPOLINK
|
return HELPTEXT
|
||||||
elif words[0] in ["!!help", "!botlist"]:
|
elif words[0] == "!!fuse":
|
||||||
return HELPTEXT
|
if "|" in words:
|
||||||
elif words[0] == "!!fuse":
|
w = words.index("|")
|
||||||
|
res = fuse(words[1:w])
|
||||||
|
if res:
|
||||||
|
return " ".join(words[w + 1 :]) + " " + res
|
||||||
|
else:
|
||||||
|
res = fuse(words[1:])
|
||||||
|
if res:
|
||||||
|
return res
|
||||||
|
elif words[0].startswith("!!"):
|
||||||
|
res = generate(words[0][2:])
|
||||||
|
if res:
|
||||||
if "|" in words:
|
if "|" in words:
|
||||||
w = words.index("|")
|
w = words.index("|")
|
||||||
print(words[1:w])
|
return " ".join(words[w + 1 :]) + " " + res
|
||||||
res = fuse(words[1:w])
|
|
||||||
if res:
|
|
||||||
return " ".join(words[w + 1 :]) + " " + res
|
|
||||||
else:
|
else:
|
||||||
print(words[1:])
|
return res
|
||||||
res = fuse(words[1:])
|
|
||||||
print(res)
|
|
||||||
if res:
|
|
||||||
return res
|
|
||||||
elif words[0].startswith("!!"):
|
|
||||||
res = generate(words[0][2:])
|
|
||||||
if res:
|
|
||||||
if "|" in words:
|
|
||||||
w = words.index("|")
|
|
||||||
return " ".join(words[w + 1 :]) + " " + res
|
|
||||||
else:
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
class Server(BaseServer):
|
class Server(BaseServer):
|
||||||
|
@ -151,6 +145,7 @@ class Server(BaseServer):
|
||||||
line.command == "PRIVMSG"
|
line.command == "PRIVMSG"
|
||||||
and self.has_channel(line.params[0])
|
and self.has_channel(line.params[0])
|
||||||
and self.has_user(line.hostmask.nickname)
|
and self.has_user(line.hostmask.nickname)
|
||||||
|
and len(line.params[1].split(" ")) > 0
|
||||||
and not line.hostmask is None
|
and not line.hostmask is None
|
||||||
and not self.casefold(line.hostmask.nickname) == self.nickname_lower
|
and not self.casefold(line.hostmask.nickname) == self.nickname_lower
|
||||||
and not ("batch" in line.tags and line.tags["batch"] == "1")
|
and not ("batch" in line.tags and line.tags["batch"] == "1")
|
||||||
|
@ -172,8 +167,6 @@ class Bot(BaseBot):
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
bot = Bot()
|
|
||||||
|
|
||||||
params = ConnectionParams(
|
params = ConnectionParams(
|
||||||
config["nick"],
|
config["nick"],
|
||||||
host=config["server"],
|
host=config["server"],
|
||||||
|
@ -181,7 +174,7 @@ async def main():
|
||||||
tls=config.getboolean("tls"),
|
tls=config.getboolean("tls"),
|
||||||
sasl=SASLUserPass(account["username"], account["password"]),
|
sasl=SASLUserPass(account["username"], account["password"]),
|
||||||
)
|
)
|
||||||
|
bot = Bot()
|
||||||
await bot.add_server("tilde", params)
|
await bot.add_server("tilde", params)
|
||||||
await bot.run()
|
await bot.run()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue