Discord
Vars | |
common_words | Common words list, used to generate one time tokens |
---|---|
enabled | Is TGS enabled (If not we won't fire because otherwise this is useless) |
notify_file | The file where notification status is saved |
notify_members | People to save to notify file |
notify_members_cache | Copy of previous list, so the SS doesnt have to fire if no new members have been added |
people_to_notify | People to notify on roundstart |
reverify_cache | People who have tried to verify this round already |
Procs | |
find_discord_link_by_ckey | Find discord link entry by the passed in user ckey |
find_discord_link_by_discord_id | Find discord link entry by the passed in user ckey |
find_discord_link_by_token | Find discord link entry by the passed in user token |
generate_one_time_token | Generate a timebound token for discord verification |
lookup_ckey | Given a discord id as a string, look up the ckey attached to that account, if any |
lookup_id | Given a ckey, look up the discord user id attached to the user, if any |
Var Details
common_words
Common words list, used to generate one time tokens
enabled
Is TGS enabled (If not we won't fire because otherwise this is useless)
notify_file
The file where notification status is saved
notify_members
People to save to notify file
notify_members_cache
Copy of previous list, so the SS doesnt have to fire if no new members have been added
people_to_notify
People to notify on roundstart
reverify_cache
People who have tried to verify this round already
Proc Details
find_discord_link_by_ckey
Find discord link entry by the passed in user ckey
This will look into the discord link table and return the first entry that matches the given ckey
Remember, multiple entries can exist
Arguments:
- ckey the users ckey as a string
- timebound should we search only in the last 4 hours
Returns a /datum/discord_link_record
find_discord_link_by_discord_id
Find discord link entry by the passed in user ckey
This will look into the discord link table and return the first entry that matches the given ckey
Remember, multiple entries can exist
Arguments:
- discord_id The users discord id (string)
- timebound should we search only in the last 4 hours
Returns a /datum/discord_link_record
find_discord_link_by_token
Find discord link entry by the passed in user token
This will look into the discord link table and return the first entry that matches the given one time token
Remember, multiple entries can exist, as they are only guaranteed to be unique for their validity period
Arguments:
- one_time_token the string of words representing the one time token
- timebound A boolean flag, that specifies if it should only look for entries within the last 4 hours, off by default
Returns a /datum/discord_link_record
generate_one_time_token
Generate a timebound token for discord verification
This uses the common word list to generate a six word random token, this token can then be fed to a discord bot that has access to the same database, and it can use it to link a ckey to a discord id, with minimal user effort
It returns the token to the calling proc, after inserting an entry into the discord_link table of the following form
(unique_id, ckey, null, the current time, the one time token generated)
the null value will be filled out with the discord id by the integrated discord bot when a user verifies
Notes:
- The token is guaranteed to unique during it's validity period
- The validity period is currently set at 4 hours
- a token may not be unique outside it's validity window (to reduce conflicts)
Arguments:
- ckey_for a string representing the ckey this token is for
Returns a string representing the one time token
lookup_ckey
Given a discord id as a string, look up the ckey attached to that account, if any
This gets the most recent entry from the discord_link table that is associated with this discord id snowflake
Arguments:
- lookup_id The discord id as a string
lookup_id
Given a ckey, look up the discord user id attached to the user, if any
This gets the most recent entry from the discord link table that is associated with the given ckey
Arguments:
- lookup_ckey A string representing the ckey to search on