-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
68 lines (51 loc) · 1.51 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import asyncio
from nonebot.adapters.onebot.v11 import Bot
# 解禁
async def ban_say(bot: Bot, group, qq):
# 禁言20min
await bot.set_group_ban(
group_id=int(group),
user_id=int(qq),
duration=20 * 60,
)
# 禁言
async def unban_say(bot: Bot, group, qq):
await bot.set_group_ban(
group_id=int(group),
user_id=int(qq),
duration=0,
)
# 群聊
async def send_gm(bot: Bot, group, says):
await bot.send_group_msg(group_id=group, message=says)
await asyncio.sleep(1)
# 私聊
async def private_say(bot: Bot, qq, group, says):
await bot.send_private_msg(
user_id=int(qq),
group_id=int(group),
message=str(says),
)
await asyncio.sleep(1)
# 改卡片名称
async def group_card(bot:Bot, group, qq, wt):
await bot.set_group_card(
group_id=int(group),
user_id=int(qq),
card=str(wt),
)
# 获取卡片名称
async def get_member_card_name(bot: Bot, group, qq) -> str:
j = await bot.get_group_member_info(group_id=group, user_id=qq)
return j["card"]
# 成员是否为管理员
async def get_member_permission(bot: Bot, group, qq) -> bool:
j = await bot.get_group_member_info(group_id=group, user_id=qq)
return j["card"] in ["owner", "admin"]
# 返回好友列表
async def friend_list(bot: Bot) -> list:
lj = await bot.get_friend_list()
l = []
for j in lj:
l.append(j["user_id"])
return l