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

Commit

Permalink
Feat: Switch to pycharm
Browse files Browse the repository at this point in the history
- Fixes a few type bugs
- Make it so you can shut the bot down dynamically
  • Loading branch information
showierdata9978 committed Dec 14, 2023
1 parent 356df8e commit 56f32ac
Show file tree
Hide file tree
Showing 35 changed files with 376 additions and 311 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
root=true
end_of_line = lf
insert_final_newline = true

Expand Down
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is for deploying mb.py's docs
cloudflare_token=
account_id=
project_name=
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/MeowerBot.py-2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions .readthedocs.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions .vscode/settings.json

This file was deleted.

7 changes: 3 additions & 4 deletions MeowerBot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"""

__version__ = "3.0.3"

from ._version import __version__

# Public library imports
from . import bot as botm

from .bot import Bot, cbids
from .bot import Bot, cbids, CallBackIds

__all__ = ["__version__", "Bot", "botm", "cbids"]
__all__ = ["__version__", "Bot", "botm", "cbids", "CallBackIds"]
1 change: 1 addition & 0 deletions MeowerBot/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '3.2.0'
11 changes: 5 additions & 6 deletions MeowerBot/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

from httpx import AsyncClient
from ..data import generic
from ..data.api.reports import PagedRequest
from ..data.generic import Post

from .shared import api_resp, post_resp

from .admin import Admin
from .chats import Chats
from .shared import api_resp, post_resp
from .user import User as API_USER_WRAPPER
from ..data import generic
from ..data.api.reports import PagedRequest
from ..data.generic import Post


class MeowerAPI:
Expand Down Expand Up @@ -66,5 +65,5 @@ async def get_inbox(self):
async def search_users(self, query: str, page: int = 1, ):
return api_resp(PagedRequest[Post], await self.client.get("/search/users", params={"q": query, "p": page, "autoget": None}))

async def search_home(self, query: str, page: int = 1) -> PagedRequest[Post]:
async def search_home(self, query: str, page: int = 1):
return api_resp(PagedRequest[Post], await self.client.get("/search/home", params={"q": query, "p": page, "autoget": None}))
15 changes: 8 additions & 7 deletions MeowerBot/api/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from httpx import AsyncClient
from ..data.api.reports import ReportRequest, Report, AdminNotesResponse
from ..data import generic
from typing import Literal

from httpx import AsyncClient

from .shared import api_resp, post_resp
from ..data import generic
from ..data.api.reports import AdminNotesResponse, Report, ReportRequest


def notes_return(resp): return api_resp(AdminNotesResponse, resp)
Expand All @@ -28,11 +29,11 @@ async def edit_report(self, uuid: generic.UUID, status: Literal["no_action_taken
async def escalate_report(self, uuid: generic.UUID):
return reports_return(await self.client.post(f"/admin/reports/{uuid}/escalate/"))

async def fetch_note(self, indentifier: str):
return notes_return(await self.client.get(f"/admin/notes/{indentifier}", params={"autoget": None}))
async def fetch_note(self, identifier: str):
return notes_return(await self.client.get(f"/admin/notes/{identifier}", params={"autoget": None}))

async def create_note(self, indentifier: str, notes: str):
return notes_return(await self.client.put(f"/admin/notes/{indentifier}", json={"notes": notes}))
async def create_note(self, identifier: str, notes: str):
return notes_return(await self.client.put(f"/admin/notes/{identifier}", json={"notes": notes}))

async def get_post(self, uuid: generic.UUID):
return post_resp(await self.client.get(f"/admin/posts/{uuid}", params={"autoget": None}))
Expand Down
11 changes: 5 additions & 6 deletions MeowerBot/api/chats.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from httpx import AsyncClient
from ..data import generic
from ..data.api.chats import Chats, ChatGroup

from httpx import Response
from httpx import AsyncClient, Response

from .shared import api_resp
from ..data import generic
from ..data.api.chats import ChatGroup, Chats


def chat_return(resp: Response):
Expand All @@ -15,7 +13,7 @@ class Chats:
def __init__(self, client: AsyncClient) -> None:
self.client = client

async def fetch_all(self) -> Chats:
async def fetch_all(self):
return api_resp(Chats, await self.client.get("/chats/", params={"autoget": None}))

async def create(self, nickname: str):
Expand All @@ -27,6 +25,7 @@ async def get(self, uuid: generic.UUID):
async def update(self, uuid: generic.UUID, nickname: str):
return chat_return(await self.client.patch(f"/chats/{uuid}", josn={"nickname": nickname}))

# noinspection PyTypeChecker
async def leave(self, uuid: generic.UUID) -> dict:
return api_resp(dict, await self.client.delete(f"/chats/{uuid}"))

Expand Down
4 changes: 3 additions & 1 deletion MeowerBot/api/shared.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Tuple, Union

from httpx import Response
from typing import Union, Tuple

from ..data.generic import Post


Expand Down
15 changes: 7 additions & 8 deletions MeowerBot/api/user.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from typing import Literal
from urllib.parse import urljoin

from httpx import AsyncClient

from .shared import api_resp
from ..data.api.chats import ChatGroup
from ..data.api.reports import PagedRequest
from ..data.generic import Post
from ..data.api.user import (
Relationship
)
from ..data.api.chats import ChatGroup

from typing import Literal

from .shared import api_resp
from urllib.parse import urljoin
from ..data.generic import Post


class User:
Expand All @@ -30,4 +29,4 @@ async def edit_relationship(self, username, state: Literal[0, 1, 2]):
return api_resp(Relationship, await self.client.patch(f"/users/{username}/relationship", json={"state": state}))

async def dm(self, username):
return api_resp(ChatGroup, self._get(username, 'dm'))
return api_resp(ChatGroup, await self._get(username, 'dm'))
Loading

0 comments on commit 56f32ac

Please sign in to comment.