WeChat notification, send good morning, love words, poems, weather information, etc. to your girlfriend every day
The core link of WeChat notification capability has been completed, and there is no limit on message content. Based on this, various private customizations can be completed according to personal needs.
Support this project by starring and sharing it. Follow me to see what other cool projects I'm working on.
It is recommended to check the config.yml configuration file directly, which contains detailed configuration function description~
Send good morning and earthy love messages to your girlfriend every day
星河耿耿,不如你眼眸璀璨,晚风习习,不如你温柔绮丽。
你闻到空气中有烧焦的味道吗?那是我的心在为你燃烧。
『苏轼《水调歌头》』有悲欢离合,月有阴晴圆缺,此事古难全。
『ONE杂志』爱情无非是年轻人一起喝酒做梦。
『网易云音乐热评』你相信吗 也许在另一个平行时空 有一个跟你长得很像很像的人 正在热烈得爱着那个你爱不到的人——想见你想见你想见你
『一言』你的眼中,明暗交杂,一笑生花。
『每日英语(Jan 9, 2022』In case I don't see you… Good afternoon, good evening, and good night.
Here we can choose a third-party open API or customize it ourselves
At present, the interface data capabilities are mainly provided by Tianxing Data. You can just register as an account member without any threshold.
Tianxing data: https://www.tianapi.com/
Note: If you use this interface, you need to add Key
variable value TIAN_API_KEY
in the step of adding environment variables as a required parameter when using the Tianxing data interface.
Free open source interfaces need to consider service stability!
The Tianxing data interface currently used in this project can be found in src/api/loveMsg
remind :
Weather data API interface: https://www.tianqiapi.com/ is no longer free for use. For testing purposes, new users can register for free 2,000 times.
There are also non-paid interfaces, but the functions seem to be limited at present (the free interface is easy to use like this, but it won’t work?)
For the sake of stability, we decided not to use the free interface for the time being. This function uses the interface API provided by Tianxing Data.
Brief description:
For other non-weather interfaces, registered members can call it 100 times a day for free, which is enough for personal use. An independent billing model is adopted for special interfaces such as weather, but the price is cheap enough, 1 yuan for 10,000 times, and 500 will be given immediately after applying for the interface. Second-rate.
Preparation :
Key
If you need to use Git functions, you also need to install Git
Configuration file :
The project relies on 2 core configuration files:
.env
: used to configure environment variable values, such as: enterprise ID, application ID, Tianxing key, sending message type as morning, middle and evening, etc.
.env.example
file, rename it to .env
, and fill in the corresponding variable values as required # 鱼崽小铃铛:应用ID
WX_APP_ID = 1000003
# 发送消息类型(不填默认为早晨)
MESSAGE_TYPE = goodMorning
config.yml
: used to configure various information about your girlfriend, as well as anniversary reminders, etc. All functions are configured in this file
# 卡片标题信息(加粗显示):今天是我们相恋的第 {day} 天,这里的 {day} 为固定替换相恋多久
start_stamp_message : 今天是我们相恋的第 {day} 天
# 女朋友所在城市(不要带‘市’),天气接口需要使用
city_name : 蚌埠
# 女朋友的爱称
girl_name : 鱼崽
YML syntax is more concise, easier to read and simpler than JSON, Ruan Yifeng YAML language tutorial
4 ways :
GitHub Action
to automatically send messages for free (click here to see)It should be pointed out that the impact of the security update of Enterprise WeChat account 2022.6.20 is as follows :
Students who have registered the application before 2022.6.20 will not be affected for the time being.
For users who use
GitHub Action
, because the IP of the running server of Action is not fixed and changes frequently, no suitable solution has been found so far.For users who send messages through local debugging, you can copy the local IP that reported the error and fill it in the trusted IP in the application background to temporarily solve the problem. This method is mainly used for debugging (the IP may change after the computer is restarted) , the problem of trusted domain names will still exist
For the above problems, the corresponding solutions are as follows :
docs/可信域名.docx
)In general, the lowest cost and most efficient way to use it is to use a cloud function deployment solution.
WX_COMPANY_ID= 企业ID
WX_APP_ID= 应用ID
WX_APP_SECRET= 应用 Secret
TIAN_API_KEY= 天行数据 key
Use your computer to open the official corporate WeChat website and register a company. You can register with your mobile phone number, no business license required! No business license required! No business license required!
After successful registration, click "Manage Enterprise" to enter the management interface, select "Application Management" → "Self-Build" → "Create Application"
Fill in the application name as you like, and select the company name for the visible range (or specify an organization or individual. It is recommended to select all, and then specify the user in the code).
Specify member or organization
After the creation is completed, enter the application details page and you can get the application ID (agentid)① and the application Secret (secret)②.
Enter the "My Business" page and scroll to the bottom to get the business ID③.
Enter "My Business" → "WeChat Plug-in", scroll down and scan the QR code, and follow it to receive push messages.
PS: If接口请求正常,企业微信接受消息正常,个人微信无法收到消息
:
Go to "My Business" → "WeChat Plug-in", scroll to the bottom, and check "Allow members to receive and reply to chat messages in the WeChat plug-in"
Turn off the "Only accept messages in Business WeChat" restriction in the Business WeChat client "Me" → "Settings" → "New Message Notification"
You can star the project first to give support, and then directly fork the project => clone it locally.
Copy the .env.example
file, rename it to .env
, and fill in the corresponding variable values as required
Install dependencies
# 推荐使用pnpm(如果未安装,可先全局安装`npm install -g pnpm`)
pnpm install
# or
npm install
Execute script
# 推荐使用这种方式
pnpm start
# or
npm start
or
# 先build构建再执行脚本
# 1. build构建生成js文件
pnpm build
# 2. node执行js文件
node dist/index.js
Note: This project is not released as a package, so build is not considered for the time being. Just run it directly through the script. The github service has been configured with a cache, so there is no need to worry about installation performance issues.
If you want to use it through GitHub Action
, you need to add variables one by one in Secrets
, and the script will run automatically. Of course, you can also adjust it according to your own needs, see .github/workflows/goodMorning.yml
GitHub Action is automatically executed at 7:30 every day. The script configuration is as follows: ci.yml
schedule :
# `分 时 天 月 周` 时按照标准时间 北京时间=标准时间+8 18表示北京时间早上2点
# 早上 7:30
- cron : ' 30 23 * * * '
Use pm2 to implement localized deployment of automated scripts. When using this method, you only need to configure the time to send messages and then start the service?
If you have the following equipment, please note:
The logic of using the server deployment service is the same as that of local development. You need to clone the project first => install dependencies => execute the script.
How to start the service:
npm run depoly:start
How to stop the service:
npm run depoly:stop
How to view services:
# 查看服务状态
npm run depoly:status
# 查看服务日志
npm run depoly:log
It is convenient and fast to directly use pay-as-you-go Serverless cloud functions, including Tencent Cloud Functions, Alibaba Cloud Functions, Huawei Cloud Functions, etc.~
It supports specifying fixed IPs, which can effectively solve the problem of trusted IPs . Tutorials based on Tencent Cloud and Huawei Cloud are currently provided, as follows:
README.md
has operation steps.feat/weather
You can follow my official account (front-end Xiaoshuai), and then add me on WeChat to communicate, or directly add the communication group to communicate and learn together~
GPLv3 Agreement : Anyone who uses this project, its code must be made public; if there are paid services derived from this project, end users must be informed in advance of the reason why this project can be obtained for free and charged; after forking and modifying the code based on this project, The GPLv3 protocol must be adopted ( please indicate the author and project address when reprinting and citing )
Thanks to the students who have always supported this project and provided many ideas and suggestions for the development of this project~❤
If you think this project is good or helpful to you, you can choose to invite the author for coffee☕~
You can note your name when tipping, and I will add you to the tipping list (if there is anything missing, please contact me to add it)
If there is no comment, I will name it after coffee? Thank you again for your support?~
Donor | Donation amount | Donation date |
---|---|---|
Raw Coconut Latte | 6.66 yuan | 2022-11-15 |
cappuccino | 20 yuan | 2022-10-31 |
A? | 5 yuan | 2022-01-07 |
Your star is my greatest support