update to post only once a note which post when samsung's stock is 80000 won

This commit is contained in:
sunwoo1524 2024-02-11 22:09:00 +09:00
parent 713410827f
commit a0a2beb1e1
2 changed files with 12 additions and 4 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
venv/ venv/
.env .env
eightyk

13
main.py
View file

@ -21,7 +21,13 @@ def postStatus():
status = "" status = ""
if int(price) >= 80000: if int(price) >= 80000:
status = f"현재 삼성전자의 주가는 {price}원 입니다.\n드디어 팔만전자를 달성했습니다!" try:
open("eightyk", "r")
status = f"현재 삼성전자의 주가는 {price}원 입니다."
except:
status = f"현재 삼성전자의 주가는 {price}원 입니다.\n드디어 팔만전자를 달성했습니다!"
open("eightyk", "x")
else: else:
delta_to_80000 = 80000 - int(price) delta_to_80000 = 80000 - int(price)
status = f"현재 삼성전자의 주가는 {price}원 입니다.\n팔만전자까지 {delta_to_80000}원 남았습니다." status = f"현재 삼성전자의 주가는 {price}원 입니다.\n팔만전자까지 {delta_to_80000}원 남았습니다."
@ -38,6 +44,7 @@ def postStatus():
if __name__ == "__main__": if __name__ == "__main__":
sched = BlockingScheduler() sched = BlockingScheduler()
# sched.add_job(postStatus, "cron", hour="15", minute="8", id="job1") sched.add_job(postStatus, "cron", hour="10,12,16", day_of_week="0-4", id="job1")
sched.add_job(postStatus, "cron", hour="10,12,16", id="job1")
sched.start() sched.start()
print("The bot is started!")