mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2025-12-13 11:12:40 +00:00
* move phoronlock define * t * force rename * nuke unneeded things * don't do that * tgui sync? * changes * unit testing module * backend * tools update * aaah * go and stay go * path replace * move everything * toss out more stuff * remove * fine those can stay * dependencies.sh * ruin datum move + rename * level assets why did you guys put the turfs in my atmosphers folder grr * more moving * basemap, force stuff * fix that desync meme * move more stuff * move those too * repath * get rid of useless initializers * hacky patchy * reservations * alright * tgui * changelog example * checksum * md5 * errors * more * turf empty * stop * fix * bad kwarg * let's get those in again * alright * rid of that * huh * newlines * newlines * folder * mood * woops * readme * might as well trim now * let's go * fuck it tether isn't being used anyways lol * ok * empty files go * tether is demoted * sorry but this goes too * okay * make that work too * ok * wow. * whew * Fix * fixes * ok * sigh * fix * fix * aah. * rust_g logging * update rust g file * fix * funny * Fix * map issues * fix * initialize hints * solves some problems * those too * ok * pills * let's do that. * hit that too * runtime * add that too * alright * fix * fix * fix * Fix * add * fix * wildwest, what have they done to you... * do that too' git push * fixes * fixes * fixes * pack this tightly * let's not have empty files * sigh * fix * FUCK OFF * fix icon * rip old mapmerge * zz * woo yeah woo yeah * logging * fix * better logs * GRRRRRR * last commit?? * awful
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
# Script to role discord members who have already associated their BYOND account
|
|
# Author: AffectedArc07
|
|
|
|
# From Discord API:
|
|
# Clients are allowed 120 events every 60 seconds, meaning you can send on average at a rate of up to 2 events per second.
|
|
|
|
# So lets send every 0.6 seconds to ensure we arent rate capped
|
|
|
|
####### CONFIG ######
|
|
|
|
# Discord section. Make sure the IDs are strings to avoid issues with IDs that start with a 0
|
|
botToken = "Put your discord bot token here"
|
|
guildID = "000000000000000000"
|
|
roleID = "000000000000000000"
|
|
|
|
# SS13 Database section
|
|
dbHost = "127.0.0.1"
|
|
dbUser = "root"
|
|
dbPass = "your password here"
|
|
dbDatabase = "tg_db"
|
|
|
|
##### DO NOT TOUCH ANYTHING BELOW HERE UNLESS YOURE FAMILIAR WITH PYTHON #####
|
|
import requests, mysql.connector, time
|
|
|
|
# Connect to DB
|
|
dbCon = mysql.connector.connect(
|
|
host = dbHost,
|
|
user = dbUser,
|
|
passwd = dbPass,
|
|
database = dbDatabase
|
|
)
|
|
cur = dbCon.cursor()
|
|
|
|
# Grab all users who need to be processed
|
|
cur.execute("SELECT byond_key, discord_id FROM player WHERE discord_id IS NOT NULL")
|
|
usersToProcess = cur.fetchall()
|
|
|
|
# We dont need the DB anymore, so close it up
|
|
dbCon.close()
|
|
|
|
# Calculate a total for better monitoring
|
|
total = len(usersToProcess)
|
|
count = 0
|
|
print("Found "+str(total)+" accounts to process.")
|
|
|
|
# Now the actual processing
|
|
for user in usersToProcess:
|
|
count += 1 # Why the fuck does python not have ++
|
|
# user[0] = ckey, user[1] = discord ID
|
|
print("Processing "+str(user[0])+" (Discord ID: " + str(user[1]) + ") | User "+str(count)+"/"+str(total))
|
|
url = "https://discord.com/api/guilds/"+str(guildID)+"/members/"+str(user[1])+"/roles/"+str(roleID)
|
|
response = requests.put(url, headers={"Authorization": "Bot "+str(botToken)})
|
|
# Adding a role returns a code 204, not a code 200. Dont ask
|
|
if response.status_code != 204:
|
|
print("WARNING: Returned non-204 status code. Request used: PUT "+str(url))
|
|
|
|
# Sleep for 0.6. This way we stay under discords rate limiting.
|
|
time.sleep(0.6)
|
|
|