31 lines
888 B
Python
31 lines
888 B
Python
import datetime
|
|
import requests
|
|
import logging
|
|
|
|
|
|
logging.basicConfig(filename='/root/develop/log/dotabot.log', level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def convert_seconds_to_hms(total_seconds):
|
|
hours, remainder = divmod(total_seconds, 3600)
|
|
minutes, seconds = divmod(remainder, 60)
|
|
return hours, minutes, seconds
|
|
|
|
def is_workday():
|
|
return datetime.datetime.today().weekday() < 5
|
|
|
|
def is_game_time():
|
|
# game time is workday 21:00 - 1:00, weekend 10:00 - 1:00
|
|
if is_workday():
|
|
return datetime.datetime.now().hour >= 21 or datetime.datetime.now().hour < 1
|
|
else:
|
|
return datetime.datetime.now().hour >= 10 or datetime.datetime.now().hour < 1
|
|
|
|
|
|
def heartbeat():
|
|
try:
|
|
resp = requests.get('https://up.tunpok.com/api/push/BDb4MJWDVh?status=up&msg=OK&ping=')
|
|
except:
|
|
logger.error('fail to heartbeat, resp status: %s' % resp.status_code)
|
|
pass
|