Browse Source

move parameter count check

master
Ben Harris 3 months ago
parent
commit
865f9b8b46
  1. 55
      tracer.py

55
tracer.py

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

Loading…
Cancel
Save