def add_image(self, tag, this): to_add = Property(tag=this.replace("https://", ""), val=embedify(url=this)) self[tag].append(to_add) self.current[tag].append(to_add) self.source[tag].append(Property(tag=to_add.tag)) self.source.save(echo=False)
def record_msg(m: Message): if not m.server: return nonlocal che if m.server.id: if m.channel.id: if m.channel.id in che: if m.id not in che[m.channel.id]: che[m.channel.id] += Property(m.id) else: che += Qoid(tag=m.channel.id) che[m.channel.id] += Property(m.id) che.save(echo=False)
async def silence(ctx, user, *args): del args # Ignored parameters if user.id not in cfg["silenced"]: cfg["silenced"] += Property(tag=user.id, val=None) await zote.add_reaction(ctx.message, reactions["on"]) else: cfg["silenced"] -= user.id await zote.add_reaction(ctx.message, reactions["off"])
async def cog_add(ctx, cog_name, cog_tag, cog_val, *args): nonlocal cogs del args # Ignored parameters try: # cog_name = args[0] # cog_tag = args[1] # cog_val = args[2] cogs[cog_name] += Property(cog_tag, cog_val) cogs.save(echo=False) except IndexError: await zote.add_reaction(ctx.message, reactions["no"])
async def ignore(ctx, user, *args): """Ignore users based on their ID """ del args # Ignored parameters try: if user.id in cfg["mods"]: print("Cannot ignore moderators or administrators") await zote.add_reaction(ctx, reactions["no"]) elif user.id not in cfg["ignored"]: cfg["ignored"] += Property(tag=user.id, val=None) await zote.say(f"Now ignoring {str(user)}") else: cfg["ignored"] -= user.id await zote.say(f"Stopped ignoring {str(user)}") except NotFound: print("Could not find user") except HTTPException: print("HTTP error of some sort")
def qoidify_server_channels(zote, s_id: str, tag=None): server = zote.get_server(s_id) out = Qoid(tag=tag if tag else server.name) for ch in server.channels: out += Property(ch.name, ch) return out
from qoid import Property p_a = Property("PropertyA", "valueA") p_b = Property("PropertyB", "valueB") p_c = Property("PropertyC") print("p_a", p_a) print("p_b", p_b) print("p_c", p_c) print() p_ba = p_b + p_a print("add") print(p_ba) print() print("bool") print(bool(p_a)) print() print("bytes") print(bytes(p_b)) print() print("equal") print("p_a == p_a", p_a == p_a) print("p_a == p_b", p_a == p_b) print() print("greater/less than")
from qoid import Property, Qoid, Bill p_a = Property("PropertyA", "valueA") p_b = Property("PropertyB", "valueB") p_c = Property("PropertyC") q_a = Qoid("Qoid A", [p_a, p_b]) q_b = Qoid("Qoid B", [p_b]) q_c = Qoid("Qoid C", [p_b, p_c]) b_a = Bill("Example Bill", [q_a, q_b, q_c]) b_a -= q_b b_a.save() b_a += q_b print(b_a) b_a = Bill.open("Example Bill.cxr") print(b_a)