channel.name("RandomFood") channel.author("nullqwertyuiop") channel.description("随机餐点") with open(str(Path(__file__).parent.joinpath("food.json")), "r", encoding="utf-8") as r: food = json.loads(r.read()) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ RegexMatch(r"[随隨][机機]"), UnionMatch("早餐", "午餐", "晚餐") @ "option" ]) ], decorators=[ FrequencyLimit.require("random_food", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add( UserCalledCountControl.FUNCTIONS) ])) async def random_meal(app: Ariadne, message: MessageChain, group: Group, option: MatchResult): option = option.result.asDisplay() main_amount = 1 if option == "早餐" else 2 dish = [] if randrange(101) < 5:
FONT_BASE_PATH = f"{os.getcwd()}/statics/fonts/" IMAGE_BASE_PATH = f"{os.getcwd()}/statics/memes/" THUMB_BASE_PATH = f"{os.getcwd()}/statics/memes/" DEFAULT_FONT = 'SourceHanSansSC-Regular.otf' OVER_LENGTH_MSG = '文字长度过长,请适当缩减' BREAK_LINE_MSG = '文字长度过长,请手动换行或适当缩减' @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ UnionMatch("nokia", "鲁迅说", "王境泽", "喜报", "记仇", "狂爱", "狂粉", "低语", "别说了", "一巴掌", "为所欲为", "馋身子", "切格瓦拉", "谁反对", "连连看", "压力大爷", "你好骚啊", "食屎啦你", "五年", "滚屏") @ "prefix", RegexMatch(r"[\s\S]+") @ "content" ]) ], decorators=[ FrequencyLimit.require("memes", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def memes(app: Ariadne, message: MessageChain, group: Group, prefix: RegexResult, content: RegexResult): prefix = prefix.result.asDisplay().strip() content = [content.result.asDisplay()] result = None
channel.author("SAGIRI-kawaii") channel.description("一个可以以图搜图的插件,在群中发送 `搜图` 后,等待回应在30s内发送图片即可(多张图片只会搜索第一张)") core = AppCore.get_core_instance() bcc = core.get_bcc() config = core.get_config() proxy = config.proxy if config.proxy != "proxy" else '' SAUCENAO_API_KEY = config.functions.get("saucenao_api_key", None) @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ UnionMatch("搜图", "识图", "以图搜图"), RegexMatch(r"[\s]+", optional=True), ElementMatch(Image, optional=True) @ "image" ]) ], decorators=[ FrequencyLimit.require("image_searcher", 3), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ] ) ) async def image_searcher(app: Ariadne, message: MessageChain, group: Group, member: Member, image: ElementResult): @Waiter.create_using_function(listening_events=[GroupMessage])
gw = GithubWatcher() @channel.use(SchedulerSchema(timer=timers.every_minute())) async def github_schedule(app: Ariadne): try: await gw.github_schedule(app=app, manual=False) except: pass twilight = Twilight([ FullMatch("/github-watch "), UnionMatch("disable", "add", "remove", "check", "cache"), WildcardMatch() ]) @channel.use( ListenerSchema(listening_events=[FriendMessage], # inline_dispatchers=[twilight] )) async def github_watcher_friend_handler(app: Ariadne, message: MessageChain, friend: Friend): if result := await gw.real_handle(app, message, friend=friend): await MessageSender(result.strategy).send(app, result.message, message, friend, friend)
async def get_gacha_info(app: Ariadne, group: Group): gid = group.id if gid in group_pool: info = gacha_info(group_pool[gid]) else: info = gacha_info() await app.sendMessage(group, info) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ UnionMatch("原神卡池切换", "原神切换卡池"), RegexMatch(r".+") @ "pool_name" ]) ], decorators=[ Function.require(channel.module), BlackListControl.enable() ])) async def set_pool(app: Ariadne, group: Group, message: MessageChain, member: Member, pool_name: RegexResult): if not await user_permission_require(group, member, 2): await app.sendMessage(group, MessageChain('只有群管理才能切换卡池'), quote=message.getFirst(Source)) return
channel = Channel.current() channel.name("LeetcodeInfo") channel.author("SAGIRI-kawaii") channel.description( "一个可以获取Leetcode信息的插件\n" "在群中发送 `leetcode userslug` 可查询个人资料(userslug为个人主页地址最后的唯一识别代码)\n" "在群中发送 `leetcode每日一题` 可查询每日一题") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ UnionMatch("leetcode", "力扣"), RegexMatch("每日一题$", optional=True) @ "daily_question", RegexMatch(r"\S+", optional=True) @ "user_slug" ]) ], decorators=[ FrequencyLimit.require("leetcode_info", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def leetcode_info(app: Ariadne, group: Group, daily_question: RegexResult, user_slug: RegexResult): if not daily_question.matched and not user_slug.matched or daily_question.matched and user_slug.matched: return if daily_question.matched:
limit_text = { "download": "今天已经达到每日下载上限啦~\n明天再来吧~\n❤你❤这❤个❤小❤色❤批❤~", "search": "今天已经达到每日搜索上限啦~\n明天再来吧~\n想找本子的话,自己去下载个哔咔好咯~", "random": "今天已经达到每日随机本子上限啦~\n明天再来吧~\n你这个人对本子真是挑剔呢~", "rank": "今天已经达到每日排行榜查询上限啦~\n明天再来吧~\n排行榜一次还看不够嘛~" } @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("pica"), UnionMatch("download", "search", "random", "rank", "init") @ "operation", ArgumentMatch("-forward", action="store_true", optional=True) @ "forward_type", ArgumentMatch("-message", action="store_true", optional=True) @ "message_type", UnionMatch("-H24", "-D7", "-D30", optional=True) @ "rank_time", RegexMatch(r".+", optional=True) @ "content" ]) ], decorators=[ FrequencyLimit.require("pica_function", 3), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def pica_function(app: Ariadne, message: MessageChain, group: Group,
channel.description("一个获取热搜的插件\n" "在群中发送 `微博热搜` 即可查看微博热搜\n" "在群中发送 `知乎热搜` 即可查看知乎热搜\n" "在群中发送 `github热搜` 即可查看github热搜") core = AppCore.get_core_instance() config = core.get_config() proxy = config.proxy if config.proxy != "proxy" else '' @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight( [UnionMatch("微博热搜", "知乎热搜", "github热搜") @ "trending_type"]) ], decorators=[ FrequencyLimit.require("trending", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def trending(app: Ariadne, group: Group, trending_type: RegexResult): trending_type = trending_type.result.asDisplay() if trending_type == "微博热搜": await app.sendGroupMessage(group, await Trending.get_weibo_trending()) elif trending_type == "知乎热搜": await app.sendGroupMessage(group, await Trending.get_zhihu_trending()) elif trending_type == "github热搜": await app.sendGroupMessage(group, await Trending.get_github_trending())
channel = Channel.current() channel.name("GroupWordCloudGenerator") channel.author("SAGIRI-kawaii") channel.description("群词云生成器," "在群中发送 `[我的|本群][日|月|年]内总结` 即可查看个人/群 月/年词云(群词云需要权限等级2)") loop = AppCore.get_core_instance().get_loop() @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight( [ UnionMatch("我的", "本群") @ "scope", UnionMatch("年内", "月内", "日内", "今日", "本月", "本年", "年度", "月度") @ "period", UnionMatch("总结", "词云"), RegexMatch(r"[0-9]+", optional=True) @ "topK", RegexMatch(r"[\s]", optional=True), ElementMatch(Image, optional=True) @ "mask", RegexMatch(r"[\s]", optional=True) ] ) ], decorators=[ FrequencyLimit.require(channel.meta["name"], 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS), ],