-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslackDailyBot.py
More file actions
63 lines (50 loc) · 1.54 KB
/
slackDailyBot.py
File metadata and controls
63 lines (50 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from slackclient import SlackClient
import schedule
import time
from datetime import date
from datetime import datetime, timedelta
import requests
from common.util import utils
from manager import db_manager
import json
with open('./key/conf.json') as conf_json:
conf = json.load(conf_json)
token = conf["slack"]["token_daily"]
slackClient = SlackClient(token)
def getdate(dateString):
dateObject = datetime.strptime(dateString, "Date(%Y,%m,%d,%H,%M,%S)")
return dateObject.strftime("%H:%M")
def job():
# regit = utils.fetch_all_json(
# db_manager.query(
# "select count(*) as users from USER where created > date_sub(now(), interval 1 day)"
# ,
# (
# )
# )
# )
account = utils.fetch_all_json(
db_manager.query(
"select count(*) as users from USERACCOUNT where create_datetime > date_sub(now(), interval 1 day); "
,
(
)
)
)
text = (
# ":coffee: 어제의 가입자수 : " + str(regit[0]['users']) +
"\n:coffee: 어제의 등록 계정수 : " + str(account[0]['users'])
)
slackClient.api_call(
"chat.postMessage",
channel="#admin_daily_alert",
text=text,
username='dailyBot',
icon_emoji=':octopus:'
)
return 0
schedule.every().day.at("09:00").do(job)
job()
while True:
schedule.run_pending()
time.sleep(1)