Пример #1
0
Файл: img.py Проект: cxr00/Zote
 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)
Пример #2
0
Файл: bot.py Проект: cxr00/Zote
 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)
Пример #3
0
Файл: bot.py Проект: cxr00/Zote
 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"])
Пример #4
0
Файл: bot.py Проект: cxr00/Zote
 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"])
Пример #5
0
Файл: bot.py Проект: cxr00/Zote
 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")
Пример #6
0
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
Пример #7
0
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")
Пример #8
0
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)