izuemon commited on
Commit
2bcf4f9
·
verified ·
1 Parent(s): fb481fa

Update jihou.py

Browse files
Files changed (1) hide show
  1. jihou.py +10 -4
jihou.py CHANGED
@@ -2,6 +2,7 @@ import time
2
  import requests
3
  import os
4
  from datetime import datetime, timedelta
 
5
 
6
  BASE_URL = "https://desk-api.channel.io/desk/channels/200605"
7
  TARGET_GROUP_CHAT_ID = "463667"
@@ -11,6 +12,9 @@ HEADERS = {
11
  "x-account": os.getenv("dmsendertoken")
12
  }
13
 
 
 
 
14
 
15
  def post_group_message(chat_id, body):
16
  url = f"{BASE_URL}/groups/{chat_id}/messages"
@@ -20,7 +24,7 @@ def post_group_message(chat_id, body):
20
 
21
 
22
  def create_time_signal_body():
23
- now = datetime.now()
24
  hour = now.hour
25
 
26
  if hour < 12:
@@ -49,9 +53,11 @@ def create_time_signal_body():
49
 
50
 
51
  def wait_until_next_hour():
52
- now = datetime.now()
53
- next_hour = (now.replace(minute=0, second=0, microsecond=0)
54
- + timedelta(hours=1))
 
 
55
  sleep_seconds = (next_hour - now).total_seconds()
56
  time.sleep(sleep_seconds)
57
 
 
2
  import requests
3
  import os
4
  from datetime import datetime, timedelta
5
+ from zoneinfo import ZoneInfo
6
 
7
  BASE_URL = "https://desk-api.channel.io/desk/channels/200605"
8
  TARGET_GROUP_CHAT_ID = "463667"
 
12
  "x-account": os.getenv("dmsendertoken")
13
  }
14
 
15
+ # 日本時間(JST)
16
+ JST = ZoneInfo("Asia/Tokyo")
17
+
18
 
19
  def post_group_message(chat_id, body):
20
  url = f"{BASE_URL}/groups/{chat_id}/messages"
 
24
 
25
 
26
  def create_time_signal_body():
27
+ now = datetime.now(JST) # 日本時間
28
  hour = now.hour
29
 
30
  if hour < 12:
 
53
 
54
 
55
  def wait_until_next_hour():
56
+ now = datetime.now(JST) # 日本時間
57
+ next_hour = (
58
+ now.replace(minute=0, second=0, microsecond=0)
59
+ + timedelta(hours=1)
60
+ )
61
  sleep_seconds = (next_hour - now).total_seconds()
62
  time.sleep(sleep_seconds)
63