pip install PYfeishuBot
You may change the default endpoint to using Lark.
import feishuBot
bot = feishuBot.Bot("app_id", "app_secret", "verification_token","encrypt_key",feishu_url="https://open.feishu.cn")
-
Setup the verification token and encryption key in Feishu/Lark Event Subscribe Settings;
-
The Server needs a public IP address for setup, then use this command to expose the local server.
-
Using the script below to listen a port, if you want to use https webhook, please configure the reserved proxy yourself.
import feishuBot bot = feishuBot.Bot("app_id", "app_secret", "verification_token","encrypt_key") bot.runserver("0.0.0.0",80,is_sign = True,is_encrypt = True) # The configuration setting should match your webook setting in feishu/lark.
-
Then setup the url in webhook in Feishu/Lark Event Subscribe.
import feishuBot
bot = feishuBot.Bot(app_id, app_secret, verification_token,encrypt_key)
# Register the listen event function
@bot.register_handler("im.message.receive_v1",message_type="text")
def auto_reply(message):
text = utils.get_message_text(message)
bot.send_message(message["sender"]["sender_id"]["open_id"],text)
# this function would send the text you sent back to you.
bot.runserver("0.0.0.0",80,is_encrypt=True,is_sign=True)
# this function would start the webhook listener
# IMPORTANT! The settings should be the same when you setup webhook in Feishu/Lark.
Todo