{"id":1318,"date":"2022-02-26T23:18:25","date_gmt":"2022-02-26T15:18:25","guid":{"rendered":"https:\/\/www.lanxy.ink\/?p=1318"},"modified":"2022-02-27T11:21:14","modified_gmt":"2022-02-27T03:21:14","slug":"hoshino-bot%e5%90%88%e5%b9%b6%e8%bd%ac%e5%8f%91%e5%8a%9f%e8%83%bd%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.lanxy.ink\/?p=1318","title":{"rendered":"Hoshino Bot\u5408\u5e76\u8f6c\u53d1\u529f\u80fd\u7684\u5b9e\u73b0"},"content":{"rendered":"\n<p>hoshino\u91cc\u652f\u6301\u8f6c\u53d1\u6d88\u606f\uff0c\u4f46\u662f\u591a\u6761\u6d88\u606f\u8f6c\u53d1\u5c31\u9700\u8981\u5408\u5e76\u6210\u5230\u4e00\u4e2a\u5217\u8868\u91cc\u518d\u7528send_group_forward_msg()\u65b9\u6cd5\u8f6c\u53d1\u3002\u5f00\u4e00\u4e2a\u6587\u7ae0\u505a\u4e2a\u603b\u7ed3\u65b9\u4fbf\u4ee5\u540e\u76f4\u63a5\u5f15\u7528\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u7528\u5230\u7684\u6a21\u5757\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from hoshino.config import NICKNAME\nfrom hoshino.typing import CQEvent<\/code><\/pre>\n\n\n\n<p>\u53d1\u9001\u8005\u7684\u6635\u79f0\u663e\u793a\uff0c\u8f6c\u4e3a\u5217\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if type(NICKNAME) == str:\n    NICKNAME = &#91;NICKNAME]<\/code><\/pre>\n\n\n\n<p>\u5b9a\u4e49\u56de\u590d\u94fe\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>async def chain_reply(bot, ev, chain, msg):\n    if ev.detail_type == 'guild':  # \u9891\u9053\u91cc\u7531gsend()\u53d1\u9001\u9891\u9053\u6d88\u606f\n        await gsend(ev, msg)\n        return chain\n    if not CHAIN_REPLY: # \u662f\u5426\u4e0d\u542f\u7528\u5408\u5e76\u8f6c\u53d1\n        await bot.send(ev, msg)\n        return chain\n    else:  # \u5408\u5e76\u8f6c\u53d1\u6d88\u606f\u8282\u70b9\uff08\u6309 Onebot v11 \u6587\u6863\u8bf4\u660e, data \u5e94\u5168\u4e3a\u5b57\u7b26\u4e32\uff09\n        data = {\n            \"type\": \"node\",\n            \"data\": {\n                    \"name\": str(NICKNAME&#91;0]), # \u53d1\u9001\u8005\u663e\u793a\u540d\u5b57\n                    \"user_id\": str(ev.self_id), # \u53d1\u9001\u8005QQ\u53f7\n                    \"content\": str(msg) # \u5177\u4f53\u6d88\u606f\n            }\n        }\n        chain.append(data)\n        return chain<\/code><\/pre>\n\n\n\n<p>\u51c6\u5907\u5de5\u4f5c\u5b8c\u5de5\u3002\u4ee5\u4e0b\u4e3a\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>async def function(bot, ev):\n    chain = &#91;] # \u521b\u5efa\u4e00\u4e2a\u7a7a\u5217\u8868\n    message_1 = '1' # \u6d88\u606f1\n    chain = await chain_reply(bot, ev, chain, message_1) # \u6d88\u606f1\u52a0\u5165\u8f6c\u53d1\u6d88\u606f\u8282\u70b9\u4e2d\n    message_2 = '2'\n    chain = await chain_reply(bot, ev, chain, message_1) # \u6d88\u606f2\u52a0\u5165\u8f6c\u53d1\u6d88\u606f\u8282\u70b9\u4e2d\n<em>--\u4e2d\u95f4\u7701\u7565--<\/em> \n    await bot.send_group_forward_msg(group_id=ev&#91;'group_id'], messages=chain) # \u5408\u5e76\u8f6c\u53d1\u6d88\u606f\uff0cgroup_id\u4e3a\u4f2a\u9020\u6d88\u606f\u6765\u6e90\u7684\u7fa4\u804a\u53f7<\/code><\/pre>\n\n\n\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\u3002<\/p>\n\n\n\n<p>\u987a\u5e26\uff0c\u5408\u5e76\u8f6c\u53d1\u91cc\u597d\u50cf\u5e76\u4e0d\u80fd\u518d\u5957\u5165\u5408\u5e76\u8f6c\u53d1&#8230;&#8230;(\u7981\u6b62\u5957\u5a03)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5408\u5e76\u8f6c\u53d1\u771f\u9999<\/p>\n","protected":false},"author":311,"featured_media":1320,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1318","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-common"],"_links":{"self":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/1318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/users\/311"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1318"}],"version-history":[{"count":3,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/1318\/revisions"}],"predecessor-version":[{"id":1325,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/1318\/revisions\/1325"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/media\/1320"}],"wp:attachment":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}