diff options
Diffstat (limited to 'AyaBot/plugins/other.py')
-rw-r--r-- | AyaBot/plugins/other.py | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/AyaBot/plugins/other.py b/AyaBot/plugins/other.py index 2b2cac1..c5dda41 100644 --- a/AyaBot/plugins/other.py +++ b/AyaBot/plugins/other.py @@ -1,23 +1,13 @@ import os import random +import nonebot from nonebot import on_command, CommandSession, permission as perm, on_request -from datetime import datetime -from typing import Optional -import pytz -from pandas import Timestamp +bot = nonebot.get_bot() +master = bot.config.SUPERUSERS +bangroup = [] #推送屏蔽群名单 -CST = 'Asia/Shanghai' - -def get_beijing_time(freq: Optional[str] = None) -> datetime: - now = datetime.now(pytz.timezone(CST)) - if freq is not None: - now = Timestamp(now).round(freq) - return now - -def beijing_from_timestamp(timestamp: int) -> datetime: - return datetime.fromtimestamp(timestamp, pytz.timezone(CST)) @on_command('阿这', only_to_me=False) @@ -54,4 +44,19 @@ async def _(session: CommandSession): await session.send('获取数据时出问题,请重试') return - await session.send(f'本群目前共有{len(seach_group_member)}人')
\ No newline at end of file + await session.send(f'本群目前共有{len(seach_group_member)}人') + +@on_command('send_all_group', aliases=['公告', '群发', '推送'], only_to_me=False) +async def send_all_group(session: CommandSession): + if session.ctx['user_id'] in master: + msg=session.current_arg.strip() + if not msg: + msg = session.get('message', prompt='请键入内容') + group_list = await session.bot.get_group_list() + for group in group_list: + if group['group_id'] not in bangroup: + try: + await bot.send_group_msg( group_id=group['group_id'], message='ADMIN推送:\n' + msg) + except: + pass + await session.send('推送完成')
\ No newline at end of file |