提交 4ea7f142 编辑于 作者: yuudi's avatar yuudi
浏览文件

feat: leave group command

上级 38251e97
{
"stable": {
"version": 3477,
"url": "http://img.yobot.xyz/yobot/yobot3477.zip"
"version": 3482,
"url": "http://img.yobot.xyz/yobot/yobot3482.zip"
}
}
\ No newline at end of file
base: /
dest: ../docs
dest: ./dist
title: yobot
description: 公主链接群聊机器人
head:
......
......@@ -8,11 +8,11 @@ yobot 的编写出于学习目的,很高兴此工具能为大家提供帮助
邮件: <yobot@pcrbot.com>
QQ群:
770947581(满)
1044314369(满)
1067699252(满)
774394459
<!-- 1087420601 -->
1群:770947581(满)
2群:1044314369(满)
4群:1067699252(满)
5群:774394459
6群:1087420601
[项目贡献者](./project/contributors.md)
[更新日志](./project/changelog.md)
......
......@@ -20,6 +20,7 @@
| 重置密码 | 随机重置一个新密码 |
| 更新 | (权)更新机器人 |
| 重启 | (权)重新启动机器人 |
| 退出此群 | (权)命令机器人退出当前群聊 |
| version | 查看机器人版本 |
| 帮助 | 查看帮助 |
......
{
"scripts": {
"dev": "vuepress dev . --host=127.0.0.1 --open",
"build": "vuepress build ."
},
"devDependencies": {
"@vuepress/plugin-back-to-top": "^1.5.0",
"vuepress": "^1.5.0",
"vuepress-plugin-clean-urls": "^1.1.1",
"vuepress-plugin-img-lazy": "^1.0.3"
}
}
\ No newline at end of file
......@@ -26,7 +26,7 @@
联系邮箱:<a href="mailto:yobot@pcrbot.com">yobot@pcrbot.com</a>
</p>
<p>
交流群:<br>770947581(满)<br>1044314369(满)<br>1067699252(满)<br>774394459
交流群:<br>1群:770947581(满)<br>2群:1044314369(满)<br>4群:1067699252(满)<br>5群:774394459
</p>
<h2>
其他
......
......@@ -57,6 +57,10 @@
<td>重启</td>
<td>(权)重新启动机器人</td>
</tr>
<tr>
<td>退出此群</td>
<td>(权:管理员)命令机器人退出当前群聊<sup class="footnote">1</sup></td>
</tr>
<tr>
<td>version</td>
<td>查看机器人版本</td>
......@@ -67,6 +71,9 @@
</tr>
</tbody>
</table>
<p>
<sup class="footnote">1</sup>当管理员希望机器人离开群聊时,应该使用此条命令而不是直接踢出群聊,避免增加封号风险
</p>
<h2>公会战类</h2>
<p>注:本类功能仅限群聊</p>
<table>
......
from typing import Any, Dict, Union
from aiocqhttp.api import Api
from .web_util import rand_string
class GroupLeave:
def __init__(self,
glo_setting: Dict[str, Any],
bot_api: Api,
*args, **kwargs):
self.setting = glo_setting
self.api = bot_api
self.verification = {}
async def execute_async(self, ctx: Dict[str, Any]):
cmd = ctx['raw_message']
if cmd.startswith('退出此群'):
if ctx['message_type'] != 'group':
return '此功能仅可用于群聊'
if ctx['sender']['role'] == 'member':
return '只有群管理员可以这么做'
code = cmd[4:]
if code == self.verification.get(ctx['group_id']):
await self.api.send_group_msg(
group_id=ctx['group_id'],
message='正在退群',
)
await self.api.set_group_leave(
group_id=ctx['group_id'],
is_dismiss=False,
)
else:
code = rand_string(4)
self.verification[ctx['group_id']] = code
return f'警告:如果你确定要执行退群,请发送“退出此群{code}”'
......@@ -20,12 +20,12 @@ if __package__:
from .ybplugins import (boss_dmg, calender, clan_battle, gacha, homepage,
jjc_consult, login, marionette, push_news, settings,
switcher, templating, updater, web_util, ybdata,
yobot_msg, custom, miner)
yobot_msg, custom, miner, group_leave)
else:
from ybplugins import (boss_dmg, calender, clan_battle, gacha, homepage,
jjc_consult, login, marionette, push_news, settings,
switcher, templating, updater, web_util, ybdata,
yobot_msg, custom, miner)
yobot_msg, custom, miner, group_leave)
# 本项目构建的框架非常粗糙,不建议各位把时间浪费本项目上
# 如果想开发自己的机器人,建议直接使用 nonebot 框架
......@@ -33,8 +33,8 @@ else:
class Yobot:
Version = "[v3.6.2_beta]"
Version_id = 177
Version = "[v3.6.2_beta_2]"
Version_id = 182
# "git rev-list --count HEAD"
def __init__(self, *,
......@@ -221,6 +221,7 @@ class Yobot:
# load new plugins
self.plug_new = [
miner.Miner(**kwargs),
group_leave.GroupLeave(**kwargs),
custom.Custom(**kwargs),
]
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册