Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
showierdata9978 committed Oct 28, 2023
1 parent 608bcca commit 66ab802
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
8 changes: 6 additions & 2 deletions MeowerBot/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from typing import Literal
from httpx import Response

def _post_fix(msg):
return "\n".join(msg.split("\n"))

class MeowerAPI:
base_uri = "https://api.meower.org/"

Expand Down Expand Up @@ -232,12 +235,12 @@ async def get_posts(self, chat: str | generic.UUID, page: int = 1) -> PagedReque
return PagedRequest[Post].from_json(resp.text)

async def send_post(self, chat: str | generic.UUID, content: str) -> Post:
content = _post_fix(content)
if chat == "home":
resp = await self.client.post(f"/home/", json={"content": content})
else:
resp = await self.client.post(f"/posts/{chat}", json={"content": content})

print(resp.text, resp.status_code)
if resp.status_code == 429:
raise RuntimeError("[API] Ratelimited: Sending posts")

Expand All @@ -249,7 +252,6 @@ async def send_post(self, chat: str | generic.UUID, content: str) -> Post:
if resp.status_code == 404:
raise RuntimeError("[API] 404 Chat Not found")

print(resp.text)
return Post.from_json(resp.text)

async def get_post(self, uuid: generic.UUID) -> Post:
Expand All @@ -262,6 +264,8 @@ async def get_post(self, uuid: generic.UUID) -> Post:
return Post.from_json(resp.text)

async def update_post(self, uuid: generic.UUID, content: str) -> Post:
content = _post_fix(content)

resp = await self.client.patch(f"/posts", params={"id": uuid}, json={"content": content})

if resp.status_code == 429:
Expand Down
4 changes: 1 addition & 3 deletions MeowerBot/Bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class cbids(StrEnum):
raw_message = "raw_message"
direct = "direct"
statuscode = "statuscode"
print(str(cbids.error))

callbacks = [i for i in cbids]

class Bot(Client):
Expand Down Expand Up @@ -128,7 +128,6 @@ def update_commands(self):

self.commands.update(cog.commands)
for i in cog.callbacks.keys():
print(self.callbacks)
self.callbacks[str(i)].append(cog.callbacks[str(i)])


Expand Down Expand Up @@ -209,7 +208,6 @@ def command(self, name=None, args=0, aliases = None):
def inner(func):

cmd = AppCommand(func, name=name, args=args)
cmd.register_class(self)

self.commands = AppCommand.add_command(self.commands, cmd)

Expand Down
2 changes: 1 addition & 1 deletion MeowerBot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

__version__ = "3.0.0"
__version__ = "3.0.2"


# Public library imports
Expand Down
2 changes: 1 addition & 1 deletion MeowerBot/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def inner(func):
cmd = AppCommand(func, name=name, args=args)
cmd.register_class(self.connected)

self.subcommand = AppCommand.add_command(self.subcommands, cmd)
self.subcommands = AppCommand.add_command(self.subcommands, cmd)
self.connected.update_commands()

return cmd #dont want mb to register this as a root command
Expand Down
20 changes: 10 additions & 10 deletions MeowerBot/ext/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ def generate_help(self):
page_size = 0
for name, cog in self.bot.cogs.items():

self.page+= f"-- [ {name} ] --\n"
self.page+= f"-- [ {name} ] -- \n "
page_size = len(self.page)

for command in cog.commands.values():
self.handle_command(command.name, command)

if page_size >= 500:
self.pages.append(self.pages)
self.page = f"\n-- [ {name} ] --\n"
self.pages.append(self.page)
self.page = f"-- [ {name} ] -- \n "
page_size = len(self.page)

self.page += "\n-- [ Unsorted ] --\n"
self.page += "-- [ Unsorted ] -- \n "
page_size = len(self.page)


Expand All @@ -52,8 +52,8 @@ def generate_help(self):
self.handle_command(name, comamnd)

if page_size >= 500:
self.pages.append(self.pages)
self.page = f"-- [ Unsorted ] --\n"
self.pages.append(self.page)
self.page = f"-- [ Unsorted ] -- \n "
page_size = len(self.page)

self.pages.append(self.page)
Expand All @@ -77,14 +77,14 @@ def handle_command(self, name, cmd: AppCommand):



self.page += "\n"
self.page += " \n "

for subcommand_name, command in cmd.subcommands.items():
self.page += f"\t"
self.page += f" \t "
self.handle_command(f"{name} {subcommand_name}", command)
self.page += "\n"
self.page += " \n "

self.page += "\n"
self.page += " \n "

@command(name="help")
async def help(self, ctx, page: int=0):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "MeowerBot"
version = "3.0.1.1"
version = "3.0.2"
description = "A meower bot lib for py"
authors = ["showierdata9978 <68120127+showierdata9978@users.noreply.github.com>"]
license = "MIT"
Expand Down

0 comments on commit 66ab802

Please sign in to comment.