Commit b591a4a6 authored by Paco's avatar Paco
Browse files

Update code style

parent 087b2137
#!/usr/bin/env python
#/usr/bin/env python
import requests
import time
......@@ -13,10 +13,10 @@ baseUrl = "https://team.picasoft.net/api/v4/"
def get_auth():
return {"Authorization": "Bearer " + token}
return {"Authorization": f"Bearer {token}"}
r = requests.post(baseUrl + "users/login", json={"login_id": username, "password": ""})
r = requests.post(f"{baseUrl}users/login", json={"login_id": username, "password": ""})
token = r.headers["Token"]
......@@ -24,7 +24,7 @@ all_users = []
i = 0
while True:
users = requests.get(
baseUrl + "users",
f"{baseUrl}users",
params={"per_page": "200", "page": str(i)},
headers=get_auth(),
).json()
......@@ -36,27 +36,27 @@ while True:
me = requests.post(
baseUrl + "users/usernames", json=[username], headers=get_auth()
f"{baseUrl}users/usernames", json=[username], headers=get_auth()
).json()[0]
for user in all_users:
sessions = requests.get(
baseUrl + "users/" + user["id"] + "/sessions", headers=get_auth()
f"{baseUrl}users/{user['id']}/sessions", headers=get_auth()
).json()
for session in sessions:
if int(oldTime) < int(session["last_activity_at"]):
r = requests.post(
baseUrl + "channels/direct",
f"{baseUrl}channels/direct",
json=[user["id"], me["id"]],
headers=get_auth(),
)
r = requests.post(
baseUrl + "posts",
f"{baseUrl}posts",
json={
"channel_id": r.json()["id"],
"message": "### Salut " + user["username"] + " ! :D \n" + message,
"message": f"### Salut {user['username']} ! :D \n{message}",
},
headers=get_auth(),
)
print("Message sent to " + user["username"])
print(f"Message sent to {user['username']}")
break
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment