如何解决Slack事件适配器:如何在我的Python脚本中从Slack Channel打印URL?
我使用Python中的Slack Events API进行操作,并希望打印在我发布机器人的频道中的传入消息中检测到的URL(并将其保存到JSON文件)。这是我在ngrok的检查器上看到的输出:
ok": true,"oldest": "0000000010.000000","messages": [{
"type": "message","subtype": "bot_message","text": "","ts": "1593973316.000100","bot_id": "B016C8R3STD","attachments": [{
"author_name": "Ariana Grande","fallback": "should\u2019ve stapled these to my eyelids when i had the chance. \nmiss n love u guys.\n*Score* -1.64x | *Likes* 83,508 (-136,902) | *Comments* 4,969 (+1,921)\n_Posted on Sunday,July 5 at 8:19 PM CEST <https:\/\/www.instagram.com\/p\/CCRSzmNF8O3\/|(Instagram)>_\n_Received via Viral Alert_","text": "should\u2019ve stapled these to my eyelids when i had the chance. \nmiss n love u guys.\n*Score* -1.64x | *Likes* 83,"id": 1,...
现在,我想在Python脚本中打印instagram-URL,例如:
# Example save insta-shortcode from message
@slack_events_adapter.on("message")
def handle_message(event_data):
message = event_data["event"]
# If the incoming message contains "www.instagram.com/p/",then save string after "/p/" (or complete link) to JSON-file
if message.get("subtype") == "bot_message" and "www.instagram.com/p/" in message.get('text'):
print(string_after_/p/)
+
save_url_to_json_file (???)
实际上,它没有检测到insta字符串,我也不知道如何进入“附件”列表来获取它。也许有人编码建议?多谢!克里斯西(Chrissi)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。