-
Notifications
You must be signed in to change notification settings - Fork 0
/
organise.py
67 lines (61 loc) · 3.33 KB
/
organise.py
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
64
65
66
67
import json
import time
import discord
# Organise.py
# Any function that handles text/json organisation or formatting for discord is stored here
#
#Organise someone's location
def organiseLocation(data):
if data is None:
return
name = str(data["firstName"]) + "'s current location is: ```"
long = "\nLongitude: " + str(data['location']['longitude'])
lat = "\nLatitude: " + str(data['location']['latitude'])
#acc = "\nAccuracy: " + str(text['location']['accuracy'])
place = "\nPlace: " + str(data['location']['address1'])
since = "\nSince " + str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data['location']['since'])))
gmap = "https://maps.google.com/?q=" + str(data['location']['latitude']) + "," + str(data['location']['longitude'])
location = name + lat + long + place + since + "``` " +gmap
return location
#Organise someone's location (with discord embed)
def organiseLocationEmbed(data):
#embed=discord.Embed(title=str(data["firstName"]) + " " + str(data["lastName"]), url="https://maps.google.com/?q=" + str(data['location']['latitude']) + "," + str(data['location']['longitude']), description="", color=0x8aa0d5)
#embed=discord.Embed(title=str(data["firstName"]) + " " + str(data["lastName"]), url="", description="", color=0x8aa0d5)
if data["location"] != None:
embed=discord.Embed(title=str(data["firstName"]) + " " + str(data["lastName"]), url="https://maps.google.com/?q=" + str(data['location']['latitude']) + "," + str(data['location']['longitude']), description="", color=0x8aa0d5)
location = data.get('location', {})
embed.add_field(name="Place", value=location.get("name", 'Unknown'), inline=True)
since_timestamp = location.get("since", None)
if since_timestamp != None:
embed.add_field(name="Since", value=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(since_timestamp)), inline=True)
else:
embed.add_field(name="Since", value="Unknown", inline=True)
else:
embed=discord.Embed(title=str(data["firstName"]) + " " + str(data["lastName"]), url="", description="", color=0x8aa0d5)
embed.add_field(name="Location", value="Location Services are disabled for this user", inline=True)
embed.set_thumbnail(url=data["avatar"])
embed.add_field(name="Phone", value=data["loginPhone"], inline=True)
embed.add_field(name="Email", value=data["loginEmail"], inline=True)
return embed
#Organise Userlist
def oragniseUserlist(data):
if data is None:
return
list = "Here is all " + data['memberCount'] + " members of " + data['name'] + "```"
for member in data['members']:
list += "\n\nName: " + str(member["firstName"]) + " " + str(member["lastName"])
list += "\nID: " + str(member["id"])
if member["location"] != None:
location = member.get('location', {})
place = f"\nPlace: {location.get('name', 'Unknown')}"
since_timestamp = location.get("since", None)
if since_timestamp:
since = "\nSince: " + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(since_timestamp))
else:
since = "\nSince: Unknown"
list += place + since
else:
list += "\nLocation Services are disabled for this user (bitch)"
list += "```"
return list
#Organise Leaderboard