From 5487ad601dea57c34d8721e4373db57df2fe6f17 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Wed, 29 Apr 2020 00:05:27 +0800 Subject: =?UTF-8?q?=E5=90=8C=E6=A0=B7=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E7=90=90=E7=A2=8E=E5=B0=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AyaBot/plugins/awsl.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'AyaBot/plugins/awsl.py') diff --git a/AyaBot/plugins/awsl.py b/AyaBot/plugins/awsl.py index 2916d8c..d2f976a 100644 --- a/AyaBot/plugins/awsl.py +++ b/AyaBot/plugins/awsl.py @@ -1,5 +1,25 @@ +import os import random -from nonebot import on_command, CommandSession +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 + + +CST_TIMEZONE = 'Asia/Shanghai' + + +def beijing_now(freq: Optional[str] = None) -> datetime: + now = datetime.now(pytz.timezone(CST_TIMEZONE)) + 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_TIMEZONE)) @on_command('阿这', only_to_me=False) @@ -16,4 +36,28 @@ async def _(session: CommandSession): @on_command('抽签', only_to_me=False) async def _(session: CommandSession): - await session.send(str(random.choice(['大凶', '小凶', '凶', '吉', '小吉', '中吉', '大吉']))) \ No newline at end of file + await session.send(str(random.choice(['大凶', '小凶', '凶', '吉', '小吉', '中吉', '大吉']))) + +@on_command('掷骰子', aliases=['投骰子'], only_to_me=False) +async def _(session: CommandSession): + await session.send(str(random.randint(1,6))) + +@on_command('?', aliases=['?', '❓'], only_to_me=False) +async def _(session: CommandSession): + await session.send('?') + +@on_command('seach_this_group_p', aliases=['本群总人数', '总人数', '群人数'], only_to_me=False, permission=perm.GROUP) +async def _(session: CommandSession): + try: + seach_group_member = await session.bot.get_group_member_list( + group_id=session.ctx['group_id'] + ) + except: + await session.send('获取数据时出问题,请重试') + return + + await session.send(f'本群目前共有{len(seach_group_member)}人') + + + + \ No newline at end of file -- cgit v1.2.3