{"id":20524094,"url":"https://github.com/kimi0230/gogopowerkimibot","last_synced_at":"2025-04-14T03:23:51.862Z","repository":{"id":43709441,"uuid":"375280421","full_name":"kimi0230/gogopowerkimibot","owner":"kimi0230","description":"LINE Bot, LINE Notify. 使用 Django, Django Q 排程, GraphQL, PostgreSQL, GitHub Active 自動部署至 Heroku / Fly.io","archived":false,"fork":false,"pushed_at":"2023-12-06T01:46:34.000Z","size":15237,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T17:21:33.908Z","etag":null,"topics":["bot","coin","django","flyio","graphql-client","heroku","linebot","postgresql","python","python3","shopee"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kimi0230.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-06-09T08:21:56.000Z","updated_at":"2024-11-21T19:29:18.000Z","dependencies_parsed_at":"2023-12-06T03:06:07.977Z","dependency_job_id":"8d06c976-5e16-4e65-ae7c-c7900ce13542","html_url":"https://github.com/kimi0230/gogopowerkimibot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2Fgogopowerkimibot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2Fgogopowerkimibot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2Fgogopowerkimibot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kimi0230%2Fgogopowerkimibot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kimi0230","download_url":"https://codeload.github.com/kimi0230/gogopowerkimibot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248814306,"owners_count":21165742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","coin","django","flyio","graphql-client","heroku","linebot","postgresql","python","python3","shopee"],"created_at":"2024-11-15T22:47:49.147Z","updated_at":"2025-04-14T03:23:51.836Z","avatar_url":"https://github.com/kimi0230.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoGoPowerKimi\n[![Wake Up Heroku](https://github.com/kimi0230/gogopowerkimibot/actions/workflows/wakeupheroku.yml/badge.svg)](https://github.com/kimi0230/gogopowerkimibot/actions/workflows/wakeupheroku.yml)\n\nLINE Bot, LINE Notify.\n使用 Django, Django Q 排程, PostgreSQL, GraphQL, GitHub Active 自動部署至 Heroku\n發票, 天氣, 天文, 匯率, 常春藤, 股市, 疫情, ptt 爬蟲, [Cambridge Dictionary](https://dictionary.cambridge.org/zht)爬蟲\n中油油價漲幅 notify, 每日英文單字 notify, Shopee自動打卡簽到 等\n\n![line bot](https://github.com/kimi0230/gogopowerkimibot/raw/main/images/gif/bot.gif)\n![line notify](https://github.com/kimi0230/gogopowerkimibot/raw/main/images/gif/notify.gif)\n## Commands\n\n- `發票 {數字N}`: N:代表前 N 期的發票(optinal) ex. `發票 1`\n- ~~`天氣 {地區}`: 地區:縣市區(required) ex. 天氣汐止~~\n- `疫情`: 台灣疫情資訊\n- `匯率 {幣別}`: ex. 匯率 美金\n- `卡比請客`\n- `穩`\n- `笑鼠人`\n- `吱吱`\n- `壞`\n- `蔡章章戶頭`\n- `t:{英文單字}`: 取得翻譯 音標 詞性\n- `te:{英文單字}`: 取得翻譯 音標 詞性 中英例句\n- `td:`: 取得每日一單字\n- `ls` : 顯示所有指令\n- `天文`: 當天天文景象+圖片\n- `天文月`: 當月天文景象 https://www.nmns.edu.tw/learn/feature/star/2021/202109/\n- `樂透`: 威力彩, 大樂透\n- `三大`: 三大法人買賣\n- `外資{數字N}`: 外資買賣 N:代表前N名 ex. `外資1`\n- `event`: 永豐一週財經大事\n\n\n## Install package\n\n```shell\npip3 install -r requirements.txt\n```\n\n## Apply for LINE dev account\n\nhttps://developers.line.biz/en/\n\n## Migration\n\n```shell\n# create\npython3 manage.py makemigrations\n\n# sync\npython3 manage.py migrate\n```\n\n## Set up Https by ngrok\n\nLINE bot user webhook url as a link to server. 1. require url not IP address. 2. must https.\n\nhttps://ngrok.com/download\n\n## Run server\n\n```shell\n# 將靜態文件收集到STATIC_ROOT中\npython3 manage.py collectstatic\npython3 manage.py runserver\n./ngrok http 8000\n```\n\n## Allow hosts\n\n`linebot_practise/settings.py`\n\n```python\nALLOWED_HOSTS = ['127.0.0.1', '20af8c34126e.ngrok.io']\n```\n\n## Add Webhook URL\n\n![ngrok](https://github.com/kimi0230/linebot_practise/blob/master/screenshot/ngrok.png)\n![webhook](https://github.com/kimi0230/linebot_practise/blob/master/screenshot/webhook.png)\n\n## Heroku\n\n1. runtime.txt\n2. Procfile : 告訴 Heroku 伺服器種類及主程式名稱\n3. gogopowerkimibot/prod_settings.py\n\n### Heroku 免費限制 \n1. 每 30 分鐘沒使用就會停機\n    * Django Q 排程, 設定每25分鐘, 呼叫一次api避免休眠\n2. 免費 550 小時\n    * 可以驗證信用卡增加 450 小時\n    * 因為加了排程會導致時間使用超過, 可以設定凌晨時不呼叫排成,讓他停機. 然後使用 github的workflows, 建立排程在早上喚醒\n\n```shell\n## install\npip3 install virtualenv\n\n## create env\nvirtualenv herokuenv\n\ncd herokuenv\n## start env\nsource bin/activate\n## stop env\ndeactivate\n\npip3 install dj-database-url dj-static gunicorn psycopg2-binary\npip freeze \u003e requirements.txt\n\nheroku config:set DJANGO_SETTINGS_MODULE=gogopowerkimibot.prod_settings\nheroku config:set DISABLE_COLLECTSTATIC=1\nheroku config:add TZ=\"Asia/Taipei\"\nheroku git:remote -a gogopowerkimibot\n\n# bash\nheroku run bash\n\n# log\nheroku login\nheroku logs --tail\n```\n\n## Apply for notify token\n\nhttps://notify-bot.line.me/my/\n\n## Schedule tool: Django Q\n\n1. `pip3 install django-q`\n2. settings.py \u003e INSTALLED_APPS \u003e add `django_q`\n3. `python3 manage.py migrate`\n4. settings.py \u003e INSTALLED_APPS \u003e add `Q_CLUSTER` :https://django-q.readthedocs.io/en/latest/configure.html#orm-configuration\n\n```python\n# settings.py example\nQ_CLUSTER = {\n    'name': 'myproject',\n    'workers': 8,\n    'recycle': 500,\n    'timeout': 60,\n    'compress': True,\n    'save_limit': 250,\n    'queue_limit': 500,\n    'cpu_affinity': 1,\n    'label': 'Django Q',\n    'redis': {\n        'host': '127.0.0.1',\n        'port': 6379,\n        'db': 0, }\n}\n\nQ_CLUSTER = {\n    'name': 'gogopowerkimibot',\n    'workers': 1,\n    'timeout': 600,\n    'retry': 1200,\n    'queue_limit': 50,\n    'bulk': 10,\n    'orm': 'default'\n}\n```\n\n5. `python3 manage.py qcluster`\n\n\n## GraphQL Client\n`pip3 install --pre 'gql[all]'`\n\n## Reference\n\n- https://github.com/henriquebastos/python-decouple\n- https://ithelp.ithome.com.tw/articles/10209644\n- [中央氣象局 opendata](https://opendata.cwb.gov.tw/index)\n- [中央氣象局 opendata 資料代碼](https://opendata.cwb.gov.tw/opendatadoc/MFC/ForecastElement.pdf)\n- [統一發票](https://invoice.etax.nat.gov.tw/invoice.xml)\n- https://django-q.readthedocs.io/en/latest/cluster.html\n- https://github.com/chubin/wttr.in\n- [Thread 用法](https://www.thepythoncode.com/article/using-threads-in-python)\n- [Surge](https://apps.apple.com/tw/app/surge-5/id1442620678)\n- [蘋果生態圈的網路神器 Surge 4 for iOS 簡易入門教學](https://www.jkg.tw/p3330/)\n- [iOS Surge 5 專用模組列表](https://kinta.ma/surge/)\n\n## memo\n\n```\npython3 manage.py createsuperuser\npython3 manage.py showmigrations\npython3 manage.py migrate django_q zero\npython3 -B -m services.linenotifyservice\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimi0230%2Fgogopowerkimibot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkimi0230%2Fgogopowerkimibot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkimi0230%2Fgogopowerkimibot/lists"}