use var env instead of file

This commit is contained in:
Mickael 2019-08-18 21:49:58 +02:00
parent 9fe47559a7
commit 9486431450

View file

@ -18,16 +18,11 @@ def main():
recent_date = datetime.now() - monthdelta() recent_date = datetime.now() - monthdelta()
rocket = RocketChat(None, None, auth_token=cfg.rocket['auth_token'], user_id=cfg.rocket['user_id'], server_url=cfg.rocket['server']) rocket = RocketChat(os.environ['ROCKETCHAT_USER'], os.environ['ROCKETCHAT_PWD'], server_url=cfg.rocket['server'])
print("Check users") print("Check users")
users = getAllUsers(rocket) users = rocket.users_list().json()
crapauds_total = len(users) crapauds_total = users["total"]
for user in users:
date = user["createdAt"]
user_date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ")
if user_date > recent_date:
crapauds_recent += 1
print("Check channels") print("Check channels")
channels = getAllChannels(rocket) channels = getAllChannels(rocket)
@ -42,7 +37,10 @@ def main():
channels_list.append(channel["name"]) channels_list.append(channel["name"])
print("Check messages for channels {}".format(channel['name'])) print("Check messages for channels {}".format(channel['name']))
messages = rocket.channels_history(channel["_id"], oldest= recent_date, count= 10000).json() messages = rocket.channels_history(channel["_id"], oldest= recent_date, count= 10000).json()
if messages["success"]:
messages_recent += len(messages["messages"]) messages_recent += len(messages["messages"])
else:
print("Error : {}".format(messages["error"]))
info = { info = {
"crapauds": { "crapauds": {