mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
35 lines
845 B
Python
Executable file
35 lines
845 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# https://discord.com/developers/docs/reference#snowflakes
|
|
|
|
import sys
|
|
import colorama
|
|
import time
|
|
|
|
|
|
DISCORD_EPOCH = 1420070400000 # milliseconds
|
|
|
|
user_snowflake = int(sys.argv[1])
|
|
|
|
|
|
def print_field(name, value):
|
|
print(
|
|
"{}{}:{} {}".format(colorama.Style.BRIGHT, name.rjust(21), colorama.Style.RESET_ALL, value)
|
|
)
|
|
|
|
|
|
creation_time = (user_snowflake >> 22) + DISCORD_EPOCH
|
|
internal_worker_id = (user_snowflake >> 17) & 0x1F
|
|
internal_process_id = (user_snowflake >> 12) & 0x1F
|
|
increment = user_snowflake & 0xFFF
|
|
|
|
print_field(
|
|
"Created at",
|
|
"{}.{}".format(
|
|
time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(creation_time // 1000)),
|
|
creation_time % 1000,
|
|
),
|
|
)
|
|
print_field("Internal worker ID", internal_worker_id)
|
|
print_field("Internal process ID", internal_process_id)
|
|
print_field("Increment", increment)
|