saya = Saya.current() channel = Channel.current() channel.name("MarketingContentGenerator") channel.author("SAGIRI-kawaii") channel.description("一个营销号内容生成器插件,在群中发送 `营销号#事件主体#事件内容#事件另一种说法` 即可") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("营销号#"), RegexMatch(r"[^\s]+") @ "somebody", FullMatch("#"), RegexMatch(r"[^\s]+") @ "something", FullMatch("#"), RegexMatch(r"[^\s]+") @ "other_word" ]) ], decorators=[ FrequencyLimit.require("marketing_content_generator", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def marketing_content_generator(app: Ariadne, message: MessageChain, group: Group, somebody: RegexResult, something: RegexResult, other_word: RegexResult): somebody = somebody.result.asDisplay()
saya = Saya.current() channel = Channel.current() channel.name("GithubInfo") channel.author("SAGIRI-kawaii") channel.description("可以搜索Github项目信息的插件,在群中发送 `/github [-i] {项目名}`") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("/github"), ArgumentMatch("-i", "-image", action="store_true", optional=True) @ "image", RegexMatch(r"[^\s]+") @ "keyword" ]) ], decorators=[ FrequencyLimit.require("github_info", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ] ) ) async def github_info(app: Ariadne, message: MessageChain, group: Group, image: ArgResult, keyword: RegexResult): image = image.matched keyword = keyword.result.asDisplay() url = "https://api.github.com/search/repositories?q="
saya = Saya.current() channel = Channel.current() channel.name("AvatarFunPic") channel.author("SAGIRI-kawaii") channel.description("一个可以生成头像相关趣味图的插件,在群中发送 `[摸|亲|贴|撕|丢|爬|精神支柱|吞] [@目标|目标qq|目标图片]` 即可") @channel.use(ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ RegexMatch("(摸|亲|贴|撕|丢|爬|精神支柱|吞)") @ "cmd", ElementMatch(At, optional=True) @ "at1", ElementMatch(At, optional=True) @ "at2", RegexMatch(r"[0-9]+", optional=True) @ "qq1", RegexMatch(r"[0-9]+", optional=True) @ "qq2", ElementMatch(Image, optional=True) @ "img1", ElementMatch(Image, optional=True) @ "img2" ]) ] )) async def avatar_fun_pic( app: Ariadne, message: MessageChain, group: Group, member: Member, cmd: RegexResult, at1: ElementResult, at2: ElementResult, qq1: RegexResult,
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)
channel.name("DailyNewspaper") channel.author("SAGIRI-kawaii") channel.description("一个定时发送每日日报的插件\n" "主人私聊bot发送 `发送早报` 可在群中发送早报\n" "在群中发送 `今日早报` 可在群中发送早报") @channel.use(SchedulerSchema(crontabify("30 8 * * *"))) async def something_scheduled(app: Ariadne): await send_newspaper(app) @channel.use( ListenerSchema(listening_events=[FriendMessage], inline_dispatchers=[Twilight([FullMatch("发送早报")])])) async def main(app: Ariadne, friend: Friend): if not friend.id == host_qq: return None await send_newspaper(app) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Twilight([FullMatch("今日早报")])])) async def main(app: Ariadne, group: Group): await app.sendMessage(group, MessageChain([Image(data_bytes=await get_image())])) async def send_newspaper(app: Ariadne):
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]) async def image_waiter(
def __init__(self, group: Union[int, Group], member: Union[int, Member]): self.group = group if isinstance(group, int) else group.id self.member = (member if isinstance(member, int) else member.id) if member else None async def detected_event(self, app: Ariadne, group: Group, member: Member, message: MessageChain): if group.id == self.group and member.id == self.member: return True if re.match(r"[是否]", message.asDisplay()) else False add_keyword_twilight = Twilight([ FullMatch(r"添加"), FullMatch("群组", optional=True) @ "group_only", RegexMatch(r"(模糊|正则)", optional=True) @ "op_type", FullMatch("回复关键词#"), RegexMatch(r"[^\s]+") @ "keyword", FullMatch("#"), WildcardMatch().flags(re.DOTALL) @ "response" ]) delete_keyword_twilight = Twilight([ FullMatch(r"删除"), FullMatch("群组", optional=True) @ "group_only", RegexMatch(r"(模糊|正则)", optional=True) @ "op_type", FullMatch("回复关键词#"), RegexMatch(r"[^\s]+") @ "keyword" ]) @channel.use(
channel.author("SAGIRI-kawaii") 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())
"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, member: Member, operation: RegexResult, message_type: ArgResult, forward_type: ArgResult,
saya = Saya.current() channel = Channel.current() channel.name("WolframAlpha") channel.author("SAGIRI-kawaii") channel.description("一个接入WolframAlpha的插件,在群中发送 `/solve {content}` 即可") api_key = AppCore.get_core_instance().get_config().functions.get( "wolfram_alpha_key", None) @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([FullMatch("/solve"), RegexMatch(".+") @ "content"]) ], decorators=[ FrequencyLimit.require("wolfram_alpha", 4), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def wolfram_alpha(app: Ariadne, message: MessageChain, group: Group, content: RegexResult): question = content.result.asDisplay() if not api_key or api_key == "wolfram_alpha_key": return MessageItem( MessageChain.create([Plain(text="尚未配置wolfram_alpha_key!")]), QuoteSource()) url = f"https://api.wolframalpha.com/v1/simple?i={question.replace('+', '%2B')}&appid={api_key}"
channel.author("SAGIRI-kawaii") channel.description("一个生成笑话的插件,在群中发送 `来点{keyword|法国|苏联|美国}笑话`") joke_non_replace = { "法国": french_jokes, "美国": america_jokes, "苏联": soviet_jokes } @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("来点"), RegexMatch(r"[^\s]+") @ "keyword", FullMatch("笑话") ]) ], decorators=[ FrequencyLimit.require("joke", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add( UserCalledCountControl.FUNCTIONS) ])) async def joke(app: Ariadne, group: Group, keyword: RegexResult): keyword = keyword.result.asDisplay() if keyword in joke_non_replace.keys(): await app.sendGroupMessage( group, MessageChain(random.choice(joke_non_replace[keyword])))
saya = Saya.current() channel = Channel.current() channel.name("AbstractMessageTransformer") channel.author("SAGIRI-kawaii") channel.description("一个普通话转抽象话的插件,在群中发送 `/抽象 文字` 即可") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("/抽象 "), RegexMatch(r".*").help("要转抽象的内容") @ "content" ]) ], decorators=[ FrequencyLimit.require("abstract_message_transformer", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ] ) ) async def abstract_message_transformer(app: Ariadne, message: MessageChain, group: Group, content: RegexResult): result = "" content = content.result.asDisplay() length = len(content) index = 0
def SimpleReply(command: str, reply_content: List[Element]): async def srr_wrapper(app: Ariadne, group: Group): await app.sendGroupMessage(group, MessageChain.create(reply_content)) bcc.receiver(GroupMessage, dispatchers=[Twilight(Sparkle([CommandMatch(command, False)]))])(srr_wrapper)
Image(path='./images/browser.png'), Plain(tF.browser) ]) SimpleReply('ygg.client.refresh', [ Image(path='./images/ygg-client-refresh.png'), Plain(tF.client_refresh) ]) SimpleReply('ygg.url', [ Plain('https://littlesk.in'), Image(path='./images/ygg-url.png') ]) SimpleReply('clfcsl', [Plain(tF.clfcsl)]) @bcc.receiver(GroupMessage, dispatchers=[ Twilight(Sparkle([KeywordsMatch(tF.question_keywords)])) ]) async def new_question_nofication(app: Ariadne, group: Group, member: Member, msg: MessageChain): enable_in_groups: List[int] = [qq.littleskin_main] admins = await app.getMemberList(qq.notification_channel) admins_id = [m.id for m in admins] if group.id in enable_in_groups and member.id not in admins_id: await app.sendGroupMessage(qq.notification_channel, MessageChain.create( [Plain(tF.new_question_nofication)]), quote=msg[Source][0].id) await app.sendGroupMessage(group, MessageChain.create( [Plain(tF.new_question_sent)]), quote=msg[Source][0].id)
channel = Channel.current() channel.name("CPGenerator") channel.author("SAGIRI-kawaii") channel.description("生成CP文的插件,在群中发送 `/cp {攻名字} {受名字}`") with open(f"{os.getcwd()}/statics/cp_data.json", "r", encoding="utf-8") as r: cp_data = json.loads(r.read()) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("/cp"), RegexMatch(r"[^\s]+") @ "attack", RegexMatch(r"[^\s]+") @ "defence" ]) ], decorators=[ FrequencyLimit.require("cp_generator", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add( UserCalledCountControl.FUNCTIONS) ])) async def cp_generator(app: Ariadne, message: MessageChain, group: Group, attack: RegexResult, defence: RegexResult): attack = attack.result.asDisplay() defence = defence.result.asDisplay() template = random.choice(cp_data["data"])
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: await app.sendGroupMessage(group, await get_leetcode_daily_question())
core = AppCore.get_core_instance() config = core.get_config() proxy = config.proxy if config.proxy != "proxy" else "" image_cache = config.data_related.get("lolicon_image_cache") data_cache = config.data_related.get("lolicon_data_cache") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight( [ FullMatch("来点"), RegexMatch(r"[^\s]+") @ "keyword", RegexMatch(r"[色涩瑟]图$"), ] ) ], decorators=[ FrequencyLimit.require("lolicon_keyword_searcher", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.SETU), ], ) ) async def lolicon_keyword_searcher( app: Ariadne, message: MessageChain, group: Group, keyword: RegexResult ):
"即可 [@目标]") core = AppCore.get_core_instance() config = core.get_config() @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("我"), RegexMatch(r"有一?个", optional=True), FullMatch("朋友"), RegexMatch( r"(想问问|说|让我问问|想问|让我问|想知道|让我帮他问问|让我帮他问|让我帮忙问|让我帮忙问问|问)"), FullMatch(" ", optional=True), FullMatch("-dark", optional=True) @ "dark", ElementMatch(At, optional=True) @ "target", RegexMatch(".+", optional=True) @ "content" ]) ], decorators=[ FrequencyLimit.require("i_have_a_friend", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def i_have_a_friend(app: Ariadne, message: MessageChain, group: Group, member: Member, content: RegexResult, target: ElementResult, dark: RegexResult):
saya = Saya.current() channel = Channel.current() channel.name("XsList") channel.author("SAGIRI-kawaii") channel.description("一个简查老师的插件,发送 `/查老师 {作品名/老师名/图片}` 即可") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("/查老师"), RegexMatch(r"[\s]+", optional=True), ElementMatch(Image, optional=True) @ "image", WildcardMatch(optional=True) @ "keyword" ]) ], decorators=[ FrequencyLimit.require("xslist", 3), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ] ) ) async def xslist_handler(app: Ariadne, group: Group, keyword: RegexResult, image: ElementResult): if image.matched: await app.sendGroupMessage(group, await search(data_bytes=await image.result.get_bytes())) elif keyword.matched:
channel.author("SAGIRI-kawaii") channel.description("查看系统状态") image_path = AppCore.get_core_instance().get_config().image_path @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("/sys"), ArgumentMatch("-a", "-all", optional=True, action="store_true") @ "all_info", ArgumentMatch( "-i", "-info", optional=True, action="store_true") @ "info", ArgumentMatch( "-s", "-storage", optional=True, action="store_true") @ "storage", ]) ], decorators=[Permission.require(Permission.SUPER_ADMIN)])) async def system_status(app: Ariadne, group: Group, all_info: ArgResult, info: ArgResult, storage: ArgResult): mem = psutil.virtual_memory() memory_message = MessageChain( "内存相关:\n" f" 内存总大小:{round(mem.total / (1024 ** 3), 2)}GB\n" f" 内存使用量:{round(mem.used / (1024 ** 3), 2)}GB / {round(mem.total / (1024 ** 3), 2)}GB ({round(mem.used / mem.total * 100, 2)}%)\n" f" 内存空闲量:{round(mem.free / (1024 ** 3), 2)}GB / {round(mem.total / (1024 ** 3), 2)}GB ({round(mem.free / mem.total* 100, 2)}%)"
from graia.ariadne.message.parser.twilight import Twilight from graia.ariadne.message.parser.twilight import FullMatch from graia.ariadne.event.message import Group, GroupMessage from graia.saya.builtins.broadcast.schema import ListenerSchema from statics.pero_dog_contents import pero_dog_contents from sagiri_bot.control import FrequencyLimit, Function, BlackListControl, UserCalledCountControl saya = Saya.current() channel = Channel.current() channel.name("PeroDog") channel.author("SAGIRI-kawaii") channel.description("一个获取舔狗日记的插件,在群中发送 `舔` 即可") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Twilight([FullMatch("舔")])], decorators=[ FrequencyLimit.require("pero_dog", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ] ) ) async def pero_dog(app: Ariadne, group: Group): await app.sendGroupMessage(group, MessageChain(random.choice(pero_dog_contents).replace('*', '')))
return False @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("/wordle"), ArgumentMatch("-single", action="store_true", optional=True) @ "single_game", ArgumentMatch("-group", action="store_true", optional=True) @ "group_game", RegexMatch(r"-(l|length)=[0-9]+", optional=True) @ "length", RegexMatch(r"-(d|dic)=\w+", optional=True) @ "dic", ArgumentMatch( "-help", "-h", action="store_true", optional=True) @ "get_help", ArgumentMatch( "-giveup", "-g", action="store_true", optional=True) @ "give_up", ArgumentMatch( "-s", "-statistic", action="store_true", optional=True) @ "statistic" ]) ])) async def wordle(app: Ariadne, message: MessageChain, group: Group, member: Member, single_game: ArgResult, dic: RegexResult, length: ArgResult, get_help: ArgResult, give_up: ArgResult, statistic: ArgResult) -> NoReturn: if get_help.matched: await app.sendGroupMessage(
user_data = config.functions["tencent"] cred = credential.Credential(user_data["secret_id"], user_data["secret_key"]) http_profile = HttpProfile() http_profile.endpoint = "tts.tencentcloudapi.com" client_profile = ClientProfile() client_profile.httpProfile = http_profile @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("说").space(SpacePolicy.FORCE), ArgumentMatch("-v", "--voice", type=int, optional=True) @ "voice_type", WildcardMatch().flags(re.DOTALL) @ "content" ]) ], decorators=[ FrequencyLimit.require("speak", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def speak(app: Ariadne, message: MessageChain, group: Group, voice_type: ArgResult, content: RegexResult): text = content.result.asDisplay() voice_type = voice_type.result if voice_type.matched else await group_setting.get_setting( group.id, Setting.voice) if voice_type == "off":
# 检查gid_pool.json是否存在,没有创建空的 if not os.path.exists(os.path.join(FILE_PATH, 'gid_pool.json')): save_group_pool() # 读取gid_pool.json的信息 with open(os.path.join(FILE_PATH, 'gid_pool.json'), 'r', encoding='UTF-8') as f: group_pool = json.load(f) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ RegexMatch(r"原神"), RegexMatch(r"(10|90|180)") @ "count", RegexMatch(r"连?抽?") @ "suffix" ]) ], decorators=[ FrequencyLimit.require("gacha", 1), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add( UserCalledCountControl.FUNCTIONS) ])) @switch() @blacklist() @frequency_limit_require_weight_free(1) async def gacha(app: Ariadne, group: Group, message: MessageChain, member: Member, count: RegexResult):
from graia.saya.builtins.broadcast.schema import ListenerSchema from sagiri_bot.control import FrequencyLimit, Function, BlackListControl, UserCalledCountControl saya = Saya.current() channel = Channel.current() channel.name("RandomWife") channel.author("SAGIRI-kawaii") channel.description("生成随机老婆图片的插件,在群中发送 `[来个老婆|随机老婆]`") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Twilight([RegexMatch(r"(来个老婆|随机老婆)$")])], decorators=[ FrequencyLimit.require("random_wife", 4), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def random_wife(app: Ariadne, message: MessageChain, group: Group): await app.sendGroupMessage( group, MessageChain([ Image( url= f"https://www.thiswaifudoesnotexist.net/example-{random.randint(1, 100000)}.jpg" ) ]),
from sagiri_bot.control import FrequencyLimit, Function, BlackListControl, UserCalledCountControl saya = Saya.current() channel = Channel.current() channel.name("HotWordsExplainer") channel.author("SAGIRI-kawaii") channel.description("一个可以查询热门词的插件,在群中发送 `{keyword}是什么梗`") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[ Twilight([RegexMatch(r"[^\s]+") @ "keyword", FullMatch("是什么梗")]) ], decorators=[ FrequencyLimit.require("hot_words_explainer", 2), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS) ])) async def hot_words_explainer(app: Ariadne, message: MessageChain, group: Group, keyword: RegexResult): await app.sendGroupMessage(group, await get_result(keyword.result.asDisplay()), quote=message.getFirst(Source)) async def get_result(keyword: str) -> MessageChain:
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:
channel.name("BWGrass") channel.author("SAGIRI-kawaii") channel.description("一个生成黑白草图的插件,在群中发送 `黑白[草]图 内容 图片` 即可") core = AppCore.get_core_instance() config = core.get_config() @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("黑白"), FullMatch("草", optional=True), FullMatch("图"), RegexMatch(r".+") @ "content", ElementMatch(Image) @ "image" ]) ])) async def black_white_grass(app: Ariadne, message: MessageChain, group: Group, member: Member, content: RegexResult, image: ElementResult): if result := await BWGrass.handle(app, message, group, member, content, image): await MessageSender(result.strategy).send(app, result.message, message, group, member) class BWGrass(AbstractHandler): __name__ = "BWGrass"
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 if prefix == "nokia":
saya = Saya.current() channel = Channel.current() channel.name("PhantomTank") channel.author("SAGIRI-kawaii") channel.description("一个幻影坦克生成器,在群中发送 `幻影 [显示图] [隐藏图]` 即可") @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Twilight([ FullMatch("彩色", optional=True) @ "colorful", FullMatch("幻影"), RegexMatch(r'[\s]?', optional=True), ElementMatch(Image) @ "img1", RegexMatch(r'[\s]?', optional=True), ElementMatch(Image) @ "img2" ]) ], decorators=[ FrequencyLimit.require("phantom_tank", 3), Function.require(channel.module), BlackListControl.enable(), UserCalledCountControl.add( UserCalledCountControl.FUNCTIONS) ])) async def phantom_tank(app: Ariadne, message: MessageChain, group: Group, colorful: RegexResult, img1: ElementResult, img2: ElementResult): async with get_running(Adapter).session.get(url=img1.result.url) as resp: