Skip to content

Commit

Permalink
fix: export MessageFlagModes (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWT233 authored Dec 25, 2022
1 parent b6f9c6d commit 6951b51
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
14 changes: 12 additions & 2 deletions khl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

# infra
from .interface import AsyncRunnable, LazyLoadable
from ._types import (MessageTypes, ChannelTypes, ChannelPrivacyTypes, EventTypes, GuildMuteTypes, SlowModeTypes,
RoleTypes, SoftwareTypes, BadgeTypes)
from ._types import (
MessageTypes,
ChannelTypes,
ChannelPrivacyTypes,
EventTypes,
GuildMuteTypes,
SlowModeTypes,
RoleTypes,
SoftwareTypes,
BadgeTypes,
MessageFlagModes,
)
from .cert import Cert
from .receiver import Receiver, WebhookReceiver, WebsocketReceiver
from .requester import HTTPRequester
Expand Down
2 changes: 1 addition & 1 deletion khl/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class BadgeTypes(IntEnum):
ONLINE_MAX = 2


class MessageFlagMode(Enum):
class MessageFlagModes(Enum):
"""types of message flag mode"""
BEFORE = 'before'
AFTER = 'after'
Expand Down
17 changes: 13 additions & 4 deletions khl/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Union, List, Dict

from . import api
from ._types import MessageTypes, ChannelTypes, SlowModeTypes, MessageFlagMode
from ._types import MessageTypes, ChannelTypes, SlowModeTypes, MessageFlagModes
from .gateway import Requestable, Gateway
from .interface import LazyLoadable
from .permission import ChannelPermission, PermissionHolder
Expand Down Expand Up @@ -85,8 +85,14 @@ async def update(self, name: str = None, topic: str = None, slow_mode: Union[int
await self.load()
return rt

async def list_users(self, search: str = None, role: Union[Role, str, int] = None, mobile_verified: bool = None,
active_time: int = None, joined_at: int = None, page: int = 1, page_size: int = 50,
async def list_users(self,
search: str = None,
role: Union[Role, str, int] = None,
mobile_verified: bool = None,
active_time: int = None,
joined_at: int = None,
page: int = 1,
page_size: int = 50,
filter_user_id: str = None) -> List[User]:
"""list the users who can see this channel"""
params = {'guild_id': self.guild_id, 'channel_id': self.id, 'page': page, 'page_size': page_size}
Expand All @@ -105,7 +111,10 @@ async def list_users(self, search: str = None, role: Union[Role, str, int] = Non
users = await self.gate.exec_paged_req(api.Guild.userList(**params))
return [User(_gate_=self.gate, _lazy_loaded_=True, **i) for i in users]

async def list_messages(self, page_size: int = None, pin: int = None, flag: MessageFlagMode = None,
async def list_messages(self,
page_size: int = None,
pin: int = None,
flag: MessageFlagModes = None,
msg_id: str = None) -> Dict:
"""list the messages in this channel (only for public channel now)"""
params = {'target_id': self.id}
Expand Down

0 comments on commit 6951b51

Please sign in to comment.