def SimpleReply(command: str, reply_content: List[GraiaMessageElementType]): async def srr_wrapper(app: GraiaMiraiApplication, group: Group): await app.sendGroupMessage(group, MessageChain.create(reply_content)) bcc.receiver(GroupMessage, dispatchers=[Kanata([CommandMatch(command, False)])])(srr_wrapper)
lsps = Group_save.get('data/lsps.json') ultra_admin = [] apikey = '' def ero_check(group: Group): if ero_setting.get_item(group.id).get('status') is not True: raise ExecutionStop() bcc = get.bcc() @bcc.receiver(GroupMessage, headless_decorators=[judge.config_check(__name__)], dispatchers=[Kanata([FullMatch('涩图来'), OptionalParam('tag')])]) async def ero_pic(app: GraiaMiraiApplication, group: Group, member: Member, tag): global ero_f, apikey g_setting = ero_setting.get_item(group.id) getup = datetime.fromisoformat(date.today().isoformat() + "T06:30") sleep = datetime.fromisoformat(date.today().isoformat() + "T23:00") lsp = lsps.get_item(group.id, member.id, date.today()) if not g_setting.get('status'): msg = '我们这个群是正经群,不搞这些玩意的' elif member.id in g_setting.get('black_list', []): msg = '黑名单人是没有涩图看的' elif not getup < datetime.now() < sleep and not g_setting.get('compel'): msg = '我要睡觉,不要打扰我' elif lsp.get('t', [0])[-1] >= time.time() - g_setting.get('group_frame', 0):
from lxml import etree headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' \ 'Chrome/81.0.4044.69 Safari/537.36 Edg/81.0.416.34'} channel = Channel.current() channel.name("BaiduSearch") channel.description("发送'百科 [词语]'获取拜读百科词条\n发送热点获取百度热点Top10") channel.author("I_love_study") @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Kanata([FullMatch('百科'), RequireParam(name='tag')]) ])) async def bdbk(app: GraiaMiraiApplication, group: Group, member: Member, tag: MessageChain): tags = tag.asDisplay().strip().split(' ', 1) bdurl = f'https://baike.baidu.com/item/{urllib.parse.quote(tags[0])}?force=1' async with aiohttp.request("GET", bdurl, headers=headers, allow_redirects=True) as r: if str(r.url) == 'https://baike.baidu.com/error.html': await app.sendGroupMessage( group, MessageChain.create([Plain('sorry,百科并没有相关信息')])) return reponse = await r.text()
from io import BytesIO import numpy as np np.seterr(divide="ignore", invalid="ignore") channel = Channel.current() channel.name("GhostTank") channel.description("发送'ghost_tank [图][图]'获取幻影坦克黑白图") channel.author("I_love_study") @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Kanata([FullMatch('ghost_tank'), RequireParam('para')]) ])) async def ghost_tank(app: GraiaMiraiApplication, group: Group, member: Member, para: MessageChain): if len(p := messages.get(Image)) == 2: pics = asyncio.gather(*[i.http_to_bytes() for i in p]) b = bytesIO() gray_car(*pics).save(b, format='PNG') await app.sendGroupMessage( group, MessageChain.create([Image.fromUnsafeBytes(b.getvalue())])) else: await app.sendGroupMessage( group, MessageChain.create([Plain('你这图,数量不对啊kora')])) # 感谢老司机
import numpy as np from io import BytesIO __plugin_name__ = '新冠病毒查看' __plugin_usage__ = '"COVID-19"' channel = Channel.current() channel.name("COVID-19") channel.description("发送'COVID-19'获取新冠确诊病例排名前20的国家") channel.author("I_love_study") @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('COVID-19')])])) async def COVID(app: GraiaMiraiApplication, group: Group): back = await get_COVID_19() await app.sendGroupMessage( group, MessageChain.create([ Plain("新型冠状病毒前10:\n" + "\n".join(back[0])), Image.fromUnsafeBytes(back[1]) ])) async def get_COVID_19(Pic=True): country_get = [] headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' \ 'Chrome/81.0.4044.69 Safari/537.36 Edg/81.0.416.34'} async with aiohttp.request(
headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' \ 'Chrome/81.0.4044.69 Safari/537.36 Edg/81.0.416.34'} channel = Channel.current() channel.name("DDSystem") channel.description('''输入 '直播 [Hololive/Hanayori/Paryi_hop]' 或者 监控室 [Hololive/Hanayori/Paryi_hop]''') channel.author("I_love_study") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('直播 '), RequireParam('tag')])])) async def dd_watch(app: GraiaMiraiApplication, group: Group, member: Member, tag: MessageChain): dd_data = yaml.safe_load( (Path(__file__).parent / 'dd_info.yml').read_text(encoding='UTF-8')) name = tag.asDisplay().strip() if name not in dd_data: await app.sendGroupMessage(group, MessageChain.create([Plain('未发现你要D的组织')])) return status_api = "https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=" conn = aiohttp.TCPConnector(limit=5) #防爆毙 async with aiohttp.ClientSession(connector=conn) as session: tasks = [ fench(session, f'{status_api}{live_id}') for live_id in dd_data[name]['room_id']
from graia.application.message.elements.internal import At, Plain from graia.application.message.parser.kanata import Kanata from graia.application.message.parser.signature import FullMatch from graia.saya import Channel, Saya from graia.saya.builtins.broadcast.schema import ListenerSchema import random saya = Saya.current() channel = Channel.current() @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch("随机禁言")])], )) async def jy(app: GraiaMiraiApplication, group: Group, member: Member): randint = random.randint(1, 60) await app.sendGroupMessage( group, MessageChain.create( [At(member.id), Plain(f" 恭喜{member.name}获得{randint}秒的禁言时间!")]), ) try: await app.mute(group, member, randint) except PermissionError: await app.sendGroupMessage( group, MessageChain.create([At(member.id), Plain(" 没管理禁nm")]))
# 插件信息 __name__ = "ZhihuHotSearch" __description__ = "获取当前知乎热搜" __author__ = "SAGIRI-kawaii" __usage__ = "在群内发送 知乎 即可" saya = Saya.current() channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:{__usage__}") channel.author(__author__) @channel.use(ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('知乎')])])) async def group_message_listener(app: GraiaMiraiApplication, group: Group): try: await app.sendGroupMessage( group, await get_zhihu_hot() ) except AccountMuted: pass async def get_zhihu_hot() -> MessageChain: zhihu_hot_url = "https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=50&desktop=true" async with aiohttp.ClientSession() as session: async with session.get(url=zhihu_hot_url) as resp: data = await resp.json()
IMG.ANTIALIAS) gif_frame = IMG.new('RGB', (112, 112), (255, 255, 255)) gif_frame.paste(reprofile, (spec[0], spec[1])) gif_frame.paste(hand, (0, int(squish * squish_translation_factor[i])), hand) gifs.append(gif_frame) ret = BytesIO() gifs[0].save(ret, format='gif', save_all=True, append_images=gifs, duration=0.05, transparency=0) return ret.getvalue() @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('摸头'), OptionalParam('para')])])) async def petpet(app: GraiaMiraiApplication, group: Group, message: MessageChain, member: Member, para): user = para.get(At)[0].target if para and para.has(At) else member.id profile_url = f"http://q1.qlogo.cn/g?b=qq&nk={user}&s=640" async with aiohttp.request("GET", profile_url) as r: profile = BytesIO(await r.read()) gif = make_petpet(profile) await app.sendGroupMessage( group, MessageChain.create([Image.fromUnsafeBytes(gif)]))
saya = Saya.current() channel = Channel.current() bcc = saya.broadcast inc = InterruptControl(bcc) channel.name(__name__) channel.description(f"{__description__}\n使用方法:{__usage__}") channel.author(__author__) # 填入你的saucenao_cookie saucenao_cookie = "" @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('搜图')])])) async def pixiv_image_searcher(app: GraiaMiraiApplication, member: Member, group: Group): image_get: bool = False message_received = None try: await app.sendGroupMessage( group, MessageChain.create( [At(member.id), Plain("请在30秒内发送要搜索的图片呐~(仅支持pixiv图片搜索呐!)")])) except AccountMuted: return None @Waiter.create_using_function([GroupMessage])
__name__ = "BangumiInfoSearcher" __description__ = "一个可以搜索番剧信息的插件" __author__ = "SAGIRI-kawaii" __usage__ = "发送 `番剧 番剧名` 即可" saya = Saya.current() channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:{__usage__}") channel.author(__author__) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([RegexMatch('番剧 .*')])])) async def bangumi_info_searcher(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member): keyword = message.asDisplay()[3:] try: if keyword: await app.sendGroupMessage( group, await get_bangumi_info(keyword, member.id)) else: await app.sendGroupMessage( group, MessageChain.create([Plain(text="请输入你要搜索的关键词")])) except AccountMuted: pass
except (ClientResponseError, PermissionError): await app.sendGroupMessage( group, MessageChain.create([ Plain(text="检测到敏感词,发生错误: 无权限"), Plain(text="\n过滤后:\n"), Plain(text=DFA.replace_filter_word(message_text)) ]), quote=message[Source][0]) except AccountMuted: pass @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([RegexMatch("(打开|关闭)敏感词过滤")])])) async def switch_modify(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member): if member.id == HostQQ: switch = 1 if message.asDisplay()[:2] == "开启" else 0 await set_group_switch(group.id, switch) try: await app.sendGroupMessage( group, MessageChain.create( [Plain(text=f"敏感词过滤已{message.asDisplay()[:2]}")])) except AccountMuted: pass else: try: await app.sendGroupMessage(
await app.sendGroupMessage( group, MessageChain.create([Plain(text=f"{function}图功能尚未开启~")])) else: sql = f"SELECT {function} FROM setting WHERE groupId='{group.id}'" if (await execute_sql(sql))[0][0]: await app.sendGroupMessage(group, await get_pic(function)) else: await app.sendGroupMessage( group, MessageChain.create([Plain(text=f"{function}图功能尚未开启~")])) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([RegexMatch("(打开|关闭).*功能")])])) async def switch_control(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member): legal_config = ("setu", "setu18", "real", "realHighq", "bizhi", "sketch") config = re.findall(r"(.*?)功能", message.asDisplay()[2:], re.S)[0] if message.asDisplay().startswith("打开"): new_setting_value = 1 else: new_setting_value = 0 try: if config in legal_config: admins = await get_admin(group.id) if member.id in admins: await update_setting(group.id, config, new_setting_value) await app.sendGroupMessage( group,
channel.author(__author__) # 账号信息 _account_path = "./modules/AutoPix/pixiv_account.json" # 图片保存路径 _img_save_path = "./pixiv_img" # 代理(可无) _proxy = "socks5://192.168.0.60:2089" # 手动更新命令 _commond = ".pixup" pix = Pix(_account_path, _img_save_path, proxy=_proxy) @channel.use( ListenerSchema(listening_events=[FriendMessage], inline_dispatchers=[Kanata([FullMatch(_commond)])])) async def pix_update(app: GraiaMiraiApplication, friend: Friend): logger.info("收到手动更新请求,正在处理") msg_list = await pix.run(friend.id) if not msg_list: await app.sendFriendMessage( friend, MessageChain.create([Plain("无更新哟~再等一会吧~~")])) elif isinstance(msg_list, list): async def send_msg_list(m_list): for msg in m_list: await app.sendFriendMessage(master_id, MessageChain.create(msg)) await asyncio.sleep(1) await app.sendFriendMessage(master_id, MessageChain.create([Plain("结束")]))
from graia.application.event.messages import GroupMessage from graia.application.message.elements.internal import * from graia.application.message.chain import MessageChain from graia.application.message.parser.kanata import Kanata from graia.application.message.parser.signature import FullMatch, RequireParam from graia.application.group import Group, Member from graia.saya import Channel from graia.saya.builtins.broadcast.schema import ListenerSchema channel = Channel.current() data_path = Path(__file__).parent / 'dd_info.yml' @channel.use(ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('组织添加 '), RequireParam('tag')])] )) async def dd_group_add(app: GraiaMiraiApplication, group: Group, member: Member, tag: MessageChain): name = tag.asDisplay().strip() dd_data = yaml.safe_load(data_path.read_text(encoding = 'UTF-8')) dd_data.append(name) data_path.write_text(yaml.safe_dump(dd_data), encoding = 'UTF-8') await app.sendGroupMessage(group, MessageChain.create([Plain(f'增加团队"{name}"成功')])) @channel.use(ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('组织删除 '), RequireParam('tag')])] )) async def dd_group_del(app: GraiaMiraiApplication, group: Group, member: Member, tag: MessageChain): name = tag.asDisplay().strip() dd_data = yaml.safe_load(data_path.read_text(encoding = 'UTF-8'))
__name__ = "SteamGameSearcher" __description__ = "一个通过关键词搜索steam游戏的插件" __author__ = "SAGIRI-kawaii" __usage__ = "在群内发送 `steam 游戏名` 即可" saya = Saya.current() channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:{__usage__}") channel.author(__author__) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([RegexMatch('steam .*')])])) async def steam_game_searcher(app: GraiaMiraiApplication, message: MessageChain, group: Group): keyword = message.asDisplay()[6:] try: if keyword: await app.sendGroupMessage(group, await get_steam_game_search(keyword)) else: await app.sendGroupMessage( group, MessageChain.create([Plain(text="请输入你要搜索的关键词(英文更管用哦~)")])) except AccountMuted: pass
Image.fromLocalFile('./images/browser.png'), Plain(tF.browser) ]) SimpleReply('ygg.client.refresh', [ Image.fromLocalFile('./images/ygg-client-refresh.png'), Plain(tF.client_refresh) ]) SimpleReply('ygg.url', [ Plain('https://littlesk.in'), Image.fromLocalFile('./images/ygg-url.png') ]) SimpleReply('clfcsl', [Plain(tF.clfcsl)]) @bcc.receiver(GroupMessage, dispatchers=[ Kanata([KeywordsMatch(tF.question_keywords)]) ]) async def new_question_nofication(app: GraiaMiraiApplication, group: Group, msg: MessageChain): enable_in_groups: List[int] = [qq.littleskin_main] if group.id in enable_in_groups: 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) @bcc.receiver(MemberJoinEvent)
__name__ = "PornhubStyleLogoGenerator" __description__ = "一个可以生成 pornhub style logo 的插件" __author__ = "SAGIRI-kawaii" __usage__ = "发送 `ph text1 text2` 即可" saya = Saya.current() channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:{__usage__}") channel.author(__author__) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([RegexMatch('5000兆 .* .*')])])) async def pornhub_style_logo_generator(app: GraiaMiraiApplication, message: MessageChain, group: Group): try: _, left_text, right_text = message.asDisplay().split(" ") try: try: genImage(word_a=left_text, word_b=right_text).save("./modules/5000zhao/test.png") except TypeError: await app.sendGroupMessage( group, MessageChain.create([Plain(text="不支持的内容!不要给我一些稀奇古怪的东西!")])) return None await app.sendGroupMessage( group,
import aiohttp from datetime import date, datetime from PIL import Image as IMG, ImageDraw, ImageFont from io import BytesIO channel = Channel.current() channel.name("AnimeTimeSchedule") channel.description("发送anime/anime tomorrow/anime yesterday获取昨/今/明的番剧时刻表") channel.author("I_love_study") @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[ Kanata([FullMatch('anime'), OptionalParam('para')]) ])) async def anime(app: GraiaMiraiApplication, group: Group, message: MessageChain, member: Member, para): today = int(datetime.fromisoformat(date.today().isoformat()).timestamp()) date2ts = { 'yesterday': today - 86400, '': today, 'tomorrow': today + 86400 } d = para.asDisplay().strip() if isinstance(para, MessageChain) else '' if d in date2ts: date_ts = date2ts[d] else: await app.sendGroupMessage(group, MessageChain.create([Plain('未知时间')]))
group, MessageChain.create([Plain("开始执行.")])) return event # await asyncio.wait_for(waiter, 60) try: await asyncio.wait_for(inc.wait(waiter), timeout=10) except asyncio.TimeoutError: await app.sendGroupMessage( group, MessageChain.create([Plain("命令超时")])) await app.sendGroupMessage(group, MessageChain.create([Plain("执行完毕.")])) @bcc.receiver( "GroupMessage", dispatchers=[Kanata([FullMatch("/"), RequireParam(name="command")])]) # 配置工具 async def group_settings(message: MessageChain, app: GraiaMiraiApplication, group: Group, member: Member, command: MessageChain): if member.id == Admin: commands = command.asDisplay().split(" ") # await app.sendGroupMessage(group, MessageChain.create([Plain("执行命令ing")])) if commands[0] == "reload": global settings, ScheduleGroup, TestGroup settings = json.load(open("./Settings.json", encoding='utf-8')) ScheduleGroup = [] TestGroup = [] for i in settings["Group"]: if i["function"]["Schedule"]: ScheduleGroup.append(i["id"]) if i["function"]["test"]: TestGroup.append(i["id"])
from utils import messagechain_to_img # 插件信息 __name__ = "TraceMoeImageSearcher" __description__ = "TraceMoe以图搜番" __author__ = "SAGIRI-kawaii" __usage__ = "发送搜番后发送图片即可" platform = SagiriGraiaPlatformCore.get_platform_instance() loop = platform.get_loop() bcc = platform.get_bcc() inc = InterruptControl(bcc) app: GraiaMiraiApplication = platform.get_app() @bcc.receiver(GroupMessage, dispatchers=[Kanata([FullMatch('搜番')])]) async def tracemoe_image_searcher(app: GraiaMiraiApplication, member: Member, group: Group): image_get: bool = False message_received = None try: await app.sendGroupMessage( group, MessageChain.create([At(member.id), Plain("请在30秒内发送要搜索的图片呐~")])) except AccountMuted: return None @Waiter.create_using_function([GroupMessage])
_commond = ".帮助" saya = Saya.current() bcc = saya.broadcast channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:\n\u3000{__usage__}") channel.author(__author__) @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch("cy5"), RequireParam("text")])])) async def send_img(app: GraiaMiraiApplication, group: Group, text: MessageChain): text_list = text.asDisplay().strip().split() logger.info(text_list) if len(text_list) == 2: logger.info(f"触发cy5:[{text_list[0]},{text_list[1]}]") url = f"https://api.dihe.moe/5000choyen/?upper={text_list[0]}&lower={text_list[1]}" async with aiohttp.request("GET", url) as res: img_bytes = await res.read() await app.sendGroupMessage( group.id, MessageChain.create([Image.fromUnsafeBytes(img_bytes)])) else: await app.sendGroupMessage(group.id, MessageChain.create([Plain("输入参数不合法")]))
from sagiri_core.core import SagiriGraiaPlatformCore # 插件信息 __name__ = "PluginsManager" __description__ = "SagiriGraiaPlatform的插件管理器(目前还没啥功能)" __author__ = "SAGIRI-kawaii" __usage__ = "" platform: SagiriGraiaPlatformCore = SagiriGraiaPlatformCore.get_platform_instance( ) loop = platform.get_loop() bcc = platform.get_bcc() app: GraiaMiraiApplication = platform.get_app() @bcc.receiver("GroupMessage", dispatchers=[Kanata([FullMatch('plugins')])]) async def plugins_manager(app: GraiaMiraiApplication, group: Group): plugins = platform.get_plugins() text = "SagiriGraiaPlatform\n\n目前已加载插件:" serial_number = 1 for plugin in plugins: text += f"\n\n{serial_number}. {plugin['name']}:" text += f"\n{plugin['description']}" serial_number += 1 text += "\n\n你可输入 'pluginHelp 插件序号' 命令来查看插件详情" await app.sendGroupMessage(group, MessageChain.create([Plain(text=text)])) @bcc.receiver("GroupMessage", dispatchers=[Kanata([RegexMatch('pluginHelp ([0-9]*)')])]) async def plugins_manager(app: GraiaMiraiApplication, group: Group,
__name__ = "HeadSplicer" __description__ = "一个接头霸王插件,修改自 https://github.com/pcrbot/plugins-for-Hoshino/tree/master/shebot/conhead" __author__ = "SAGIRI-kawaii" __usage__ = "群内发送 `接头[图片]` 即可" saya = Saya.current() channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:{__usage__}") channel.author(__author__) signal: int = 0 @channel.use(ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([RegexMatch("接头.*")])])) async def head_splicer(app: GraiaMiraiApplication, message: MessageChain, member: Member, group: Group): print(globals()["signal"]) if not os.path.exists("./modules/HeadSplicer/temp/"): os.mkdir("./modules/HeadSplicer/temp/") if "".join([plain.text for plain in message.get(Plain)]).strip() == "接头": if globals()["signal"] >= 2: try: await app.sendGroupMessage(group, MessageChain.create([Plain(text=f"目前有{signal}个任务正在处理,请稍后再试!")])) except AccountMuted: pass return None globals()["signal"] += 1 if message.get(Image):
from graia.saya import Saya, Channel from graia.saya.builtins.broadcast.schema import ListenerSchema from graia.template import Template from graiax import silkcoder from expand import Netease from expand import transcode channel = Channel.current() channel.name("BarMusic") channel.description("发送'bar_music [歌曲名]'获取语音音乐") channel.author("I_love_study") @channel.use(ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('bar_music'), RequireParam(name = 'tag')])] )) async def bar_music(app: GraiaMiraiApplication, group: Group, member: Member, tag: MessageChain): if tag.asDisplay().strip() == '': await app.sendGroupMessage(group, Template('点啥歌?').render()) return search_data = await Netease.search(tag.asDisplay().strip()) try: download = await Netease.download_song(search_data[0]['id']) except Exception as e: await app.sendGroupMessage(group, Template('不知道为什么,但是我就是放不了').render()) return music_b = await silkcoder.encode(download, rate=80000, ss=0, t=60) await app.sendGroupMessage(group, MessageChain.create([await app.uploadVoice(music_b)]))
from PIL import Image as IMG, ImageDraw from io import BytesIO import shlex words2img = EmojiWriter().text2pic channel = Channel.current() channel.name("PornHubStyleWord") channel.description("发送'ph [字] [字]'获取熟悉的ph图标") channel.author("I_love_study") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('ph'), RequireParam('para')])])) async def pornhub(app: GraiaMiraiApplication, group: Group, member: Member, para: MessageChain, message: MessageChain): if len(tag := shlex.split(para.asDisplay())) == 2: pic = make_porn_logo(*tag, 109) #必须是109(emoji) msg = [Image.fromUnsafeBytes(pic)] else: msg = [Plain('消息有误,请重试')] await app.sendGroupMessage(group, MessageChain.create(msg)) def make_porn_logo(left: str, right: str, font_size: int): gap = int(font_size / 4) right_font = words2img(right, (0, 0, 0), font_size) r_wide, r_height = right_font.size yellow_color = '#F7971D'
__description__ = "获取酷安酷图" __author__ = "purofle" __usage__ = "在群内发送 酷图 即可" saya = Saya.current() channel = Channel.current() channel.name(__sayamname__) channel.author(__author__) channel.description(f"{__description__}\n使用方法:{__usage__}") @channel.use( ListenerSchema( listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch("酷安酷图")])], )) async def coolapk(app: GraiaMiraiApplication, group: Group, member: Member): await app.sendGroupMessage( group, MessageChain.create([At(member.id), Plain(" 图片发送较慢,请稍等...")])) n = await request( "https://api.coolapk.com/v6/page/dataList?url=%2Ffeed%2FcoolPictureList%3FfragmentTemplate%3Dflex&title=&subTitle=&page=1" ) choice_dict = random.choice(n) url = choice_dict["pic"] username = choice_dict["username"] tag = choice_dict["tags"]
__usage__ = "发送'.帮助'即可" _commond = ".帮助" saya = Saya.current() bcc = saya.broadcast channel = Channel.current() channel.name(__name__) channel.description(f"{__description__}\n使用方法:\n\u3000{__usage__}") channel.author(__author__) @channel.use( ListenerSchema(listening_events=[FriendMessage], inline_dispatchers=[Kanata([FullMatch(_commond)])])) async def friend_listener(app: GraiaMiraiApplication, friend: Friend): out = table.img_bytes await app.sendFriendMessage( friend, MessageChain.create([Img.fromUnsafeBytes(out.getvalue())])) @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch(_commond)])])) async def group_listener(app: GraiaMiraiApplication, group: Group): out = table.img_bytes await app.sendGroupMessage( group, MessageChain.create([Img.fromUnsafeBytes(out.getvalue())]))
loop = asyncio.get_event_loop() bcc = Broadcast(loop=loop) ''' kanata 是匹配对话框中的第一个元素。当且仅当发送的消息中第一个元素为文本时可用。 FullMatch是从第一个文本开始进行匹配的 RegexMatch使用正则进行匹配,返回匹配的部分的后面剩余的部分。 RequireParm 是指定前一个匹配结果的名称,没有就不满足条件 OptionalParam 是指定前一个匹配结果的名称,是一个可选条件。不满足时为None ''' @bcc.receiver( "GroupMessage", dispatchers=[ Kanata( [FullMatch("test full match:"), RequireParam("full_match_result")], stop_exec_if_fail=True) ]) def test_full_match(full_match_result, event: GroupMessage): print(full_match_result) @bcc.receiver("GroupMessage", dispatchers=[ Kanata([ RegexMatch(r"test regex match:(.*)"), RequireParam("regex_match_result") ], stop_exec_if_fail=True) ]) def test_regex_match(regex_match_result, event: GroupMessage):
from graia.saya import Saya, Channel from graia.saya.builtins.broadcast.schema import ListenerSchema from graia.template import Template import random channel = Channel.current() channel.name("Material") channel.description("发送'learn'获取学❤习❤资❤料") channel.author("I_love_study") #这些都是厚大法考的学习资料 @channel.use( ListenerSchema(listening_events=[GroupMessage], inline_dispatchers=[Kanata([FullMatch('learn')])])) async def learn(app: GraiaMiraiApplication, group: Group, message: MessageChain, member: Member): learning_urls = [ 'http://oss.fk.houdask.com/sys/v/19/10/f64809ee7ccd44319ffddf74c8c8abf7.rar', 'http://oss.fk.houdask.com/sys/v/19/10/3f036ac7d1fc4912b2a11331c3ef33c5.rar', 'http://oss.fk.houdask.com/sys/v/19/10/461c32c3904e44f08b721600fcf32fb7.rar', 'http://oss.fk.houdask.com/sys/v/19/10/192c231fc56c4ca09bffe69856dba705.rar', 'http://oss.fk.houdask.com/sys/v/20/01/5cdc62ab47e1460789a0cd691b572415.zip', 'http://oss.fk.houdask.com/sys/v/20/01/24901a9ebeab4ac5a8bc551572af8c24.zip', 'http://oss.fk.houdask.com/sys/v/20/01/e48ea55b6c8147a9ac90ced8ef3bc80e.rar', 'http://oss.fk.houdask.com/sys/v/20/01/10ebebeae4d14f6aa786537b3adc374d.zip', 'http://oss.fk.houdask.com/sys/v/20/01/51dc2a25b3474022b982191174dda41c.zip', 'http://oss.fk.houdask.com/sys/v/20/01/1043c2175f84478baa8be09ed92aac7c.zip', 'http://oss.fk.houdask.com/sys/v/20/01/d15be5ac6027461794e399402bb8ddec.rar', 'http://oss.fk.houdask.com/sys/v/20/01/0dd665e49ec24999b772475fbf78a65a.zip'