-
Notifications
You must be signed in to change notification settings - Fork 97
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
de67007
commit b409111
Showing
10 changed files
with
110 additions
and
112 deletions.
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
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
import botpy | ||
from botpy import logging | ||
from botpy.ext.cog_yaml import read | ||
from botpy.manage import C2CManageEvent | ||
|
||
test_config = read(os.path.join(os.path.dirname(__file__), "config.yaml")) | ||
|
||
_log = logging.get_logger() | ||
|
||
|
||
class MyClient(botpy.Client): | ||
async def on_friend_add(self, event: C2CManageEvent): | ||
_log.info("用户添加机器人:" + str(event)) | ||
await self.api.post_c2c_message( | ||
openid=event.openid, | ||
msg_type=0, | ||
event_id=event.event_id, | ||
content="hello", | ||
) | ||
|
||
async def on_friend_del(self, event: C2CManageEvent): | ||
_log.info("用户删除机器人:" + str(event)) | ||
|
||
async def on_c2c_msg_reject(self, event: C2CManageEvent): | ||
_log.info("用户关闭机器人主动消息:" + str(event)) | ||
|
||
async def on_c2c_msg_receive(self, event: C2CManageEvent): | ||
_log.info("用户打开机器人主动消息:" + str(event)) | ||
|
||
|
||
if __name__ == "__main__": | ||
# 通过预设置的类型,设置需要监听的事件通道 | ||
# intents = botpy.Intents.none() | ||
# intents.public_messages=True | ||
|
||
# 通过kwargs,设置需要监听的事件通道 | ||
intents = botpy.Intents(public_messages=True) | ||
client = MyClient(intents=intents) | ||
client.run(appid=test_config["appid"], secret=test_config["secret"]) |
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,42 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
import botpy | ||
from botpy import logging | ||
from botpy.ext.cog_yaml import read | ||
from botpy.manage import GroupManageEvent | ||
|
||
test_config = read(os.path.join(os.path.dirname(__file__), "config.yaml")) | ||
|
||
_log = logging.get_logger() | ||
|
||
|
||
class MyClient(botpy.Client): | ||
async def on_group_add_robot(self, event: GroupManageEvent): | ||
_log.info("机器人被添加到群聊:" + str(event)) | ||
await self.api.post_group_message( | ||
group_openid=event.group_openid, | ||
msg_type=0, | ||
event_id=event.event_id, | ||
content="hello", | ||
) | ||
|
||
async def on_group_del_robot(self, event: GroupManageEvent): | ||
_log.info("机器人被移除群聊:" + str(event)) | ||
|
||
async def on_group_msg_reject(self, event: GroupManageEvent): | ||
_log.info("群聊关闭机器人主动消息:" + str(event)) | ||
|
||
async def on_group_msg_receive(self, event: GroupManageEvent): | ||
_log.info("群聊打开机器人主动消息:" + str(event)) | ||
|
||
|
||
if __name__ == "__main__": | ||
# 通过预设置的类型,设置需要监听的事件通道 | ||
# intents = botpy.Intents.none() | ||
# intents.public_messages=True | ||
|
||
# 通过kwargs,设置需要监听的事件通道 | ||
intents = botpy.Intents(public_messages=True) | ||
client = MyClient(intents=intents) | ||
client.run(appid=test_config["appid"], secret=test_config["secret"]) |
This file was deleted.
Oops, something went wrong.