Skip to content

Commit

Permalink
Fix: Forgot an argument
Browse files Browse the repository at this point in the history
Fix: Got rid of illegal HTTP passthrough argument
Feat: Added assert tests
  • Loading branch information
showierdata9978 committed Jan 11, 2024
1 parent e0bab1a commit e1a24b2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MeowerBot/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.3.0'
__version__ = '3.3.1'
11 changes: 9 additions & 2 deletions MeowerBot/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ class User:
def __init__(self, client: AsyncClient) -> None:
self.client = client

async def _get(self, username, url, json=None, page=1, query=None, params=None):
return await self.client.get(urljoin(f"/users/{username}/", url), json=json, params={"q": query, "p": page, **params})
async def _get(self, username, url, page=1, query=None, params=None):

if query is None:
query = dict()

if params is None:
params = dict()

return await self.client.get(urljoin(f"/users/{username}/", url), params={"q": query, "p": page, **params})

async def get_posts(self, username, query, page=1):
return api_resp(PagedRequest[Post], await self._get(username, "posts", query=query, page=page, params={"autoget": None}))
Expand Down
2 changes: 1 addition & 1 deletion MeowerBot/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def send_msg(self, message) -> Optional["Post"]:
return Post(self.bot, data.to_dict(), self)

async def fetch(self) -> Optional["Chat"]:
chat = self.bot.cache.get_chat()
chat = self.bot.cache.get_chat(self.id)
if isinstance(chat, Chat): return chat

data, status = await self.bot.api.chats.get(self.id)
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.3.0"
version = "3.3.1"
description = "A meower bot lib for py"
authors = ["showierdata9978 <[email protected]>"]
license = "MIT"
Expand Down
15 changes: 12 additions & 3 deletions tests/intergration/integration_login.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from MeowerBot import Bot, CallBackIds
from MeowerBot.context import Context, Post
from MeowerBot.context import Context, PartialUser, Post, User
from MeowerBot.cog import Cog
from MeowerBot.command import command

Expand Down Expand Up @@ -90,8 +90,17 @@ async def ping(self, ctx: Context):
await ctx.send_msg("Pong!\n My latency is: " + str(self.bot.latency))




@bot.event
async def login(token):
assert await bot.get_chat("9bf5bddd-cd1a-4c0d-a34c-31ae554ed4a7").fetch() is not None
assert await bot.get_chat("9bf5bddd").fetch() is None
assert await PartialUser(bot.user.username, bot).fetch() is not None
assert await PartialUser("A" * 21, bot).fetch() is None

@bot.listen(CallBackIds.message)
async def on_message(message: Post):
assert isinstance(message, Post)
assert isinstance(bot.get_context(message), Context)

bot.register_cog(Ping(bot))
bot.register_cog(HelpExt(bot, disable_command_newlines=True))
Expand Down

0 comments on commit e1a24b2

Please sign in to comment.