LINE Bot, LINE Notify. 使用 Django, Django Q 排程, PostgreSQL, GraphQL, GitHub Active 自動部署至 Heroku 發票, 天氣, 天文, 匯率, 常春藤, 股市, 疫情, ptt 爬蟲, Cambridge Dictionary爬蟲 中油油價漲幅 notify, 每日英文單字 notify, Shopee自動打卡簽到 等
發票 {數字N}: N:代表前 N 期的發票(optinal) ex.發票 1天氣 {地區}: 地區:縣市區(required) ex. 天氣汐止疫情: 台灣疫情資訊匯率 {幣別}: ex. 匯率 美金卡比請客穩笑鼠人吱吱壞蔡章章戶頭t:{英文單字}: 取得翻譯 音標 詞性te:{英文單字}: 取得翻譯 音標 詞性 中英例句td:: 取得每日一單字ls: 顯示所有指令天文: 當天天文景象+圖片天文月: 當月天文景象 https://www.nmns.edu.tw/learn/feature/star/2021/202109/樂透: 威力彩, 大樂透三大: 三大法人買賣外資{數字N}: 外資買賣 N:代表前N名 ex.外資1event: 永豐一週財經大事
pip3 install -r requirements.txthttps://developers.line.biz/en/
# create
python3 manage.py makemigrations
# sync
python3 manage.py migrateLINE bot user webhook url as a link to server. 1. require url not IP address. 2. must https.
# 將靜態文件收集到STATIC_ROOT中
python3 manage.py collectstatic
python3 manage.py runserver
./ngrok http 8000linebot_practise/settings.py
ALLOWED_HOSTS = ['127.0.0.1', '20af8c34126e.ngrok.io']- runtime.txt
- Procfile : 告訴 Heroku 伺服器種類及主程式名稱
- gogopowerkimibot/prod_settings.py
- 每 30 分鐘沒使用就會停機
- Django Q 排程, 設定每25分鐘, 呼叫一次api避免休眠
- 免費 550 小時
- 可以驗證信用卡增加 450 小時
- 因為加了排程會導致時間使用超過, 可以設定凌晨時不呼叫排成,讓他停機. 然後使用 github的workflows, 建立排程在早上喚醒
## install
pip3 install virtualenv
## create env
virtualenv herokuenv
cd herokuenv
## start env
source bin/activate
## stop env
deactivate
pip3 install dj-database-url dj-static gunicorn psycopg2-binary
pip freeze > requirements.txt
heroku config:set DJANGO_SETTINGS_MODULE=gogopowerkimibot.prod_settings
heroku config:set DISABLE_COLLECTSTATIC=1
heroku config:add TZ="Asia/Taipei"
heroku git:remote -a gogopowerkimibot
# bash
heroku run bash
# log
heroku login
heroku logs --tailhttps://notify-bot.line.me/my/
pip3 install django-q- settings.py > INSTALLED_APPS > add
django_q python3 manage.py migrate- settings.py > INSTALLED_APPS > add
Q_CLUSTER:https://django-q.readthedocs.io/en/latest/configure.html#orm-configuration
# settings.py example
Q_CLUSTER = {
'name': 'myproject',
'workers': 8,
'recycle': 500,
'timeout': 60,
'compress': True,
'save_limit': 250,
'queue_limit': 500,
'cpu_affinity': 1,
'label': 'Django Q',
'redis': {
'host': '127.0.0.1',
'port': 6379,
'db': 0, }
}
Q_CLUSTER = {
'name': 'gogopowerkimibot',
'workers': 1,
'timeout': 600,
'retry': 1200,
'queue_limit': 50,
'bulk': 10,
'orm': 'default'
}python3 manage.py qcluster
pip3 install --pre 'gql[all]'
- https://github.com/henriquebastos/python-decouple
- https://ithelp.ithome.com.tw/articles/10209644
- 中央氣象局 opendata
- 中央氣象局 opendata 資料代碼
- 統一發票
- https://django-q.readthedocs.io/en/latest/cluster.html
- https://github.com/chubin/wttr.in
- Thread 用法
- Surge
- 蘋果生態圈的網路神器 Surge 4 for iOS 簡易入門教學
- iOS Surge 5 專用模組列表
python3 manage.py createsuperuser
python3 manage.py showmigrations
python3 manage.py migrate django_q zero
python3 -B -m services.linenotifyservice