凭借飞书机器人,让信息主动来找我

凭借飞书机器人,让信息主动来找我

开发者广场内容精选NaN-NaN-NaN
解决方案
作者:李坤雨
推荐理由
通过飞书机器人,让信息主动找我,而不是我去寻找信息。让信息自动管理,而不是我去管理信息。
我现在常用的机器人如下,更多想法还在探索中。欢迎交流。
我的机器人
1、【日落时分bot】每天早晨推送北京当天的日落时间和天气,我不想错过每天的日落。
2、【feeds呀bot】关注的一些信息源,如段子笑话、金句、读书碎片会自动按一定频率推送给我。
3、【粉丝变化bot】小小效率、生活博主,会更新B站、抖音、公众号等社交媒体,每天会自动统计我的粉丝变化,然后各平台的数据一起推送给我
4、【个人信息管理bot】 ,这个是我最强的机器人,打通了IM和多维表格。实现了个人记账、写日记、收藏文档、操作远端服务器的需求。另有一篇单独的文档分享妙用飞书机器人让信息管理效率翻倍
机器人效果图如下(非最新版)
机器人搭建过程参考
获取机器人webhook地址
邀请机器人进群,获取webhook地址:
webhook_url = "webhook地址" (为了安全,不要泄漏)
Python脚本
两个文件,weather.py:用于获取天气,feishu_robot.py:用于发送信息到机器人。
import requestsimport timeclass Whether: @staticmethod def getData(): # 用的第三方接口获取天气:和风天气 https://www.qweather.com/ url = "xxx自己申请的接口地址" payload = {} headers = {} response = requests.request("GET", url, headers=headers, data=payload) whether = (response.json())["daily"][0] context = "日期:" + whether["fxDate"] + "\n" + "天气:" + whether["textDay"] + "--" + whether[ "textNight"] + "\n" + "温度:" + whether["tempMin"] + " ~ " + whether["tempMax"] + "\n" + "日出:" + whether[ "sunrise"] + "\n" + "日落:" + whether["sunset"] + "\n" return { "message": context }if __name__ == "__main__": print(Whether.getData()) ''' 打印结果: {'message': '日期:2022-03-02\n天气:晴--晴\n温度:1 ~ 14\n日出:06:47\n日落:18:07\n'} '''''''
# Python 3.9import jsonimport requestsimport sysimport osimport timesys.path.append(os.path.abspath(os.path.dirname(__file__)) + "/..")from feishu.juzi import JuZifrom feishu.dushe import DuShefrom feishu.whether import Whetherclass FeishuRobot: @staticmethod def send_message(data, wehook_url): headers = { 'Content-Type': 'application/json' } payload_message = { "msg_type": "text", "content": { "text": data["message"] } } response = requests.request("POST", wehook_url, headers=headers, data=json.dumps(payload_message)) print(response.text) @staticmethod def get_time_stamp(str_time): timelist = time.strptime(time.strftime('%Y-%m-%d ') + str_time, "%Y-%m-%d %H:%M:%S") time_stamp = int(time.mktime(timelist)) return time_stampif __name__ == "__main__": # 每天7点推送天气到机器人 if (FeishuRobot.get_time_stamp("7:0:0") <= time.time()) and (time.time() <= FeishuRobot.get_time_stamp("8:00:0")): webook_url_whether = "xxx自己的飞书机器人地址" FeishuRobot.send_message(Whether.getData(), webook_url_whether)))))
Jenkins执行自动化任务
在本地电脑上,通过Jenkins配置,在白天每1小时执行1次Python脚本:feishu.robot.py
先进生产力和业务协同平台
联系我们立即试用

先进团队,先用飞书

欢迎联系我们,飞书效能顾问将为您提供全力支持
分享先进工作方式
输送行业最佳实践
全面协助组织提效
联系我们立即试用