capncord api的包装器。
capncord.p的Python项目详细描述
capncord.py
py是用python编写的不和谐的api包装器。
安装
要安装库,请运行以下命令:
pip install capncord.py
根据您的环境,命令可能略有不同。如果您在安装库时遇到问题,请首先熟悉pip
如何在您的平台上工作。
教程
要创建bot,子类capncord.Bot
和重载on_ready
和on_message
。
机器人
bot类支持方法async def wait_for(event: str, check: Optional[function] = None, timeout: Optional[int] = None
、async def get_message(id: int) -> Message
、async def history() -> List[Message]
和async def get_channel(id: int) -> Channel
。
history()
返回在所有频道中发送的消息列表,最新消息位于列表的开头。
它还具有属性loop: asyncio.BaseEventLoop
、session: aiohttp.ClientSession
和user: User
。
消息
消息类具有属性id: int
、created_at: datetime.datetime
、content: str
、author: User
和channel: Channel
。
通道
channel类支持方法async def send(content: str)
和async def history() -> List[Message]
。
history()
返回此频道中发送的消息列表,最新消息位于列表的开头。
它还有属性id
。
用户
用户类支持str
。
它还有属性await User.name
和await User.messages_sent
。
要求
- Python3.5.3+
aiohttp
库websockets
库
通常pip
会为您处理这些问题。