-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70d4b44
commit 464aea7
Showing
7 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 创建 Bot 实例 | ||
|
||
首先从`lagrange`库直接导入`Lagrange`类,随后创建实例。 | ||
|
||
初始化参数中,`uin`可直接传入`0`(类型为`int`),`protocol`根据`sign_url`的类型而定,如果使用`Linux`的`Signer`,`protocol`请传入`linux`,以此类推。 | ||
|
||
`sign_url`需要传入一个实际可用的`Lagrange Sign`地址,注意本项目的`Sign`与其他`Lagrange`实现的同版本一致。 | ||
|
||
将初始化的类实例赋值给一个变量后,可使用实例方法订阅事件以及启动。调用该实例的`launch`方法即可启动`lagrange-python`。 | ||
|
||
> 目前`lagrange-python`只支持扫码登录,如果扫码登录后出现`Code 45`,请检查`Sign`是否正常(连接状态?请求地址?协议版本?)。 | ||
初始化完毕后,可参考下一章节对具体的事件进行响应以及处理。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 事件 | ||
|
||
`lagrange-python`采用事件订阅制。 | ||
|
||
`创建 Bot 实例`章节中,初始化的实例具有`subscribe`方法,可以使用该方法进行订阅事件。 | ||
|
||
**参数** | ||
|
||
- event (*dataclass*): 订阅事件数据类,可参考下方事件列表。 | ||
- handler (*function*): 订阅事件的处理函数。 | ||
|
||
> `handler`函数需要传入一个`client`(类型为`lagrange.client.client.Client`)和需要处理的事件,事件可以有联合类型,但是订阅只可传入一种事件数据类。 | ||
## 事件列表 | ||
|
||
如果事件以`Friend`或`Private`开头,则通过`lagrange.client.events.friend`导入。 | ||
|
||
反之,如果以`Group`开头,则通过`lagrange.client.events.group`导入。 | ||
|
||
|事件名称|备注| | ||
|-----|-----| | ||
|`GroupMessage`|群消息| | ||
|`GroupRecall`|群消息撤回| | ||
|`GroupNudge`|群戳一戳| | ||
|`GroupSign`|群打卡| | ||
|`GroupMuteMember`|群禁言| | ||
|`GroupMemberJoinRequest`|加群申请| | ||
|`GroupMemberJoined`|群成员增加| | ||
|`GroupMemberQuit`|群成员减少| | ||
|`GroupMemberGotSpecialTitle`|群成员获得特殊头衔| | ||
|`GroupNameChanged`|群名变动| | ||
|`GroupReaction`|群消息回应| | ||
|`GroupAlbumUpdate`|群相册更新(上传)| | ||
|`GroupInvite`|邀请入群| | ||
|`GroupMemberJoinedByInvite`|群成员邀请入群| | ||
|`FriendMessage`|私聊消息| | ||
|`FriendRecall`|私聊撤回| | ||
|`FriendRequest`|好友申请| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# lagrange-python | ||
|
||
## 快速开始 | ||
|
||
lagrange-python 有两种下载方式可供选择: | ||
|
||
- 从`PyPI`拉取最新`Release`; | ||
- 直接从[项目 GitHub 主页](https://github.com/LagrangeDev/lagrange-python)拉取最新`commit`。 | ||
|
||
社区内也有基于纯协议进行开发的标准适配,如 [nekobox](https://github.com/wyapx/nekobox)(Satori)等。 | ||
|
||
步骤如下: | ||
|
||
1. [创建 Bot 实例并登录](CreateBot/) | ||
3. [订阅事件](Event/) |