mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-12 17:11:20 +01:00
Remove all time sleep 0 to test
This commit is contained in:
parent
db1643595f
commit
883a5d27b7
@ -9,7 +9,6 @@ from titanembeds.decorators import timeit
|
||||
|
||||
class Gateway(Namespace):
|
||||
def teardown_db_session(self):
|
||||
time.sleep(0)
|
||||
db.session.commit()
|
||||
db.session.remove()
|
||||
|
||||
@ -18,7 +17,6 @@ class Gateway(Namespace):
|
||||
|
||||
@timeit
|
||||
def on_identify(self, data):
|
||||
time.sleep(0)
|
||||
guild_id = data["guild_id"]
|
||||
if not guild_accepts_visitors(guild_id) and not check_user_in_guild(guild_id):
|
||||
disconnect()
|
||||
@ -33,7 +31,6 @@ class Gateway(Namespace):
|
||||
channels = get_guild_channels(guild_id, forced_role=forced_role)
|
||||
join_room("GUILD_"+guild_id)
|
||||
for chan in channels:
|
||||
time.sleep(0)
|
||||
if chan["read"]:
|
||||
join_room("CHANNEL_"+chan["channel"]["id"])
|
||||
if session.get("unauthenticated", True) and guild_id in session.get("user_keys", {}):
|
||||
@ -51,7 +48,6 @@ class Gateway(Namespace):
|
||||
self.teardown_db_session()
|
||||
|
||||
def on_disconnect(self):
|
||||
time.sleep(0)
|
||||
if "user_keys" not in session:
|
||||
self.teardown_db_session()
|
||||
return
|
||||
@ -77,13 +73,11 @@ class Gateway(Namespace):
|
||||
else:
|
||||
name = name + username + "#" + str(session["discriminator"])
|
||||
for webhook in guild_webhooks:
|
||||
time.sleep(0)
|
||||
if webhook["name"] == name:
|
||||
discord_api.delete_webhook(webhook["id"], webhook["token"])
|
||||
self.teardown_db_session()
|
||||
|
||||
def on_heartbeat(self, data):
|
||||
time.sleep(0)
|
||||
if "socket_guild_id" not in session:
|
||||
disconnect()
|
||||
return
|
||||
@ -97,7 +91,6 @@ class Gateway(Namespace):
|
||||
return
|
||||
if session["unauthenticated"]:
|
||||
key = session["user_keys"][guild_id]
|
||||
time.sleep(0)
|
||||
status = update_user_status(guild_id, session["username"], key)
|
||||
if status["revoked"] or status["banned"]:
|
||||
emit("revoke")
|
||||
@ -115,7 +108,6 @@ class Gateway(Namespace):
|
||||
self.teardown_db_session()
|
||||
|
||||
def on_channel_list(self, data):
|
||||
time.sleep(0)
|
||||
if "socket_guild_id" not in session:
|
||||
disconnect()
|
||||
return
|
||||
@ -136,7 +128,6 @@ class Gateway(Namespace):
|
||||
self.teardown_db_session()
|
||||
|
||||
def on_current_user_info(self, data):
|
||||
time.sleep(0)
|
||||
if "socket_guild_id" not in session:
|
||||
disconnect()
|
||||
return
|
||||
@ -161,28 +152,23 @@ class Gateway(Namespace):
|
||||
guild_roles = redisqueue.get_guild(guild_id)["roles"]
|
||||
guildroles_filtered = {}
|
||||
for role in guild_roles:
|
||||
time.sleep(0)
|
||||
guildroles_filtered[role["id"]] = role
|
||||
member_roleids = member["roles"]
|
||||
member_roles = []
|
||||
for roleid in member_roleids:
|
||||
time.sleep(0)
|
||||
role = guildroles_filtered.get(str(roleid))
|
||||
if not role:
|
||||
continue
|
||||
member_roles.append(role)
|
||||
member_roles = sorted(member_roles, key=lambda k: k['position'])
|
||||
for role in member_roles:
|
||||
time.sleep(0)
|
||||
if role["color"] != 0:
|
||||
color = '{0:02x}'.format(role["color"])
|
||||
while len(color) < 6:
|
||||
time.sleep(0)
|
||||
color = "0" + color
|
||||
return color
|
||||
|
||||
def on_lookup_user_info(self, data):
|
||||
time.sleep(0)
|
||||
if "socket_guild_id" not in session:
|
||||
disconnect()
|
||||
return
|
||||
@ -200,7 +186,6 @@ class Gateway(Namespace):
|
||||
"avatar_url": None,
|
||||
"discordbotsorgvoted": False,
|
||||
}
|
||||
time.sleep(0)
|
||||
member = redisqueue.get_guild_member_named(guild_id, "{}#{}".format(name, discriminator))
|
||||
if member:
|
||||
usr["id"] = str(member["id"])
|
||||
|
@ -53,7 +53,6 @@ class DiscordREST:
|
||||
data = json.dumps(data)
|
||||
|
||||
for tries in range(5):
|
||||
time.sleep(0)
|
||||
curepoch = time.time()
|
||||
if self._get_bucket("global_limited") == "True":
|
||||
time.sleep(int(float(self._get_bucket("global_limit_expire"))) - curepoch)
|
||||
|
@ -66,7 +66,6 @@ def get_user_managed_servers():
|
||||
guilds = json.loads(fetched)
|
||||
filtered = []
|
||||
for guild in guilds:
|
||||
time.sleep(0)
|
||||
permission = guild['permissions'] # Manage Server, Ban Members, Kick Members
|
||||
if guild['owner'] or user_has_permission(permission, 5) or user_has_permission(permission, 2) or user_has_permission(permission, 1):
|
||||
filtered.append(guild)
|
||||
@ -83,7 +82,6 @@ def get_user_managed_servers_id():
|
||||
guilds = get_user_managed_servers_safe()
|
||||
ids=[]
|
||||
for guild in guilds:
|
||||
time.sleep(0)
|
||||
ids.append(guild['id'])
|
||||
return ids
|
||||
|
||||
@ -94,7 +92,6 @@ def check_user_can_administrate_guild(guild_id):
|
||||
def check_user_permission(guild_id, id):
|
||||
guilds = get_user_managed_servers_safe()
|
||||
for guild in guilds:
|
||||
time.sleep(0)
|
||||
if guild['id'] == guild_id:
|
||||
return user_has_permission(guild['permissions'], id) or guild['owner']
|
||||
return False
|
||||
|
@ -17,7 +17,6 @@ class RedisQueue:
|
||||
}
|
||||
loop_count = 0
|
||||
while (not data and data != "") and loop_count < 50:
|
||||
time.sleep(0)
|
||||
if loop_count % 25 == 0:
|
||||
redis_store.publish("discord-api-req", json.dumps(payload))
|
||||
time.sleep(0.1)
|
||||
@ -30,7 +29,6 @@ class RedisQueue:
|
||||
data = list(data)
|
||||
data_parsed = []
|
||||
for d in data:
|
||||
time.sleep(0)
|
||||
if d != "":
|
||||
data_parsed.append(json.loads(d))
|
||||
return data_parsed
|
||||
@ -49,7 +47,6 @@ class RedisQueue:
|
||||
snowflakes = []
|
||||
guild_members = {}
|
||||
for x in q:
|
||||
time.sleep(0)
|
||||
if x["id"] in snowflakes or int(x["id"]) <= int(after_snowflake):
|
||||
continue
|
||||
snowflakes.append(x["id"])
|
||||
@ -78,7 +75,6 @@ class RedisQueue:
|
||||
message["author"]["discriminator"] = member["discriminator"]
|
||||
message["author"]["username"] = member["username"]
|
||||
for mention in message["mentions"]:
|
||||
time.sleep(0)
|
||||
if mention["id"] not in guild_members:
|
||||
author = self.get_guild_member(guild_id, mention["id"])
|
||||
guild_members[mention["id"]] = author
|
||||
@ -112,7 +108,6 @@ class RedisQueue:
|
||||
member_ids = self.get(key, "list_guild_members", {"guild_id": guild_id}, data_type="set")
|
||||
members = []
|
||||
for member_id in member_ids:
|
||||
time.sleep(0)
|
||||
usr_id = member_id["user_id"]
|
||||
member = self.get_guild_member(guild_id, usr_id)
|
||||
if member:
|
||||
|
@ -116,7 +116,6 @@ def checkUserBanned(guild_id, ip_address=None):
|
||||
banned = False
|
||||
else:
|
||||
for usr in dbUser:
|
||||
time.sleep(0)
|
||||
if usr.lifter_id is not None:
|
||||
banned = False
|
||||
else:
|
||||
@ -185,11 +184,9 @@ def get_online_embed_user_keys(guild_id="*", user_type=None):
|
||||
user_type = [user_type]
|
||||
usrs = {}
|
||||
for utype in user_type:
|
||||
time.sleep(0)
|
||||
usrs[utype] = []
|
||||
keys = redis_store.keys("MemberPresence/{}/{}/*".format(guild_id, utype))
|
||||
for key in keys:
|
||||
time.sleep(0)
|
||||
client_key = key.split("/")[-1]
|
||||
usrs[utype].append(client_key)
|
||||
return usrs
|
||||
@ -208,7 +205,6 @@ def get_member_roles(guild_id, user_id):
|
||||
roles = q["roles"]
|
||||
role_converted = []
|
||||
for role in roles:
|
||||
time.sleep(0)
|
||||
role_converted.append(str(role))
|
||||
return role_converted
|
||||
|
||||
@ -232,7 +228,6 @@ def get_guild_channels(guild_id, force_everyone=False, forced_role=0):
|
||||
guild_owner = guild["owner_id"]
|
||||
result_channels = []
|
||||
for channel in guild_channels:
|
||||
time.sleep(0)
|
||||
if channel['type'] in ["text", "category"]:
|
||||
result = get_channel_permission(channel, guild_id, guild_owner, guild_roles, member_roles, str(session.get("user_id")), force_everyone)
|
||||
bot_result = get_channel_permission(channel, guild_id, guild_owner, guild_roles, bot_member_roles, config["client-id"], False)
|
||||
@ -330,16 +325,13 @@ def bot_can_create_webhooks(guild):
|
||||
guild_roles = guild["roles"]
|
||||
# @everyone
|
||||
for role in guild_roles:
|
||||
time.sleep(0)
|
||||
if role["id"] == guild["id"]:
|
||||
perm |= role["permissions"]
|
||||
continue
|
||||
member_roles = get_member_roles(guild["id"], config["client-id"])
|
||||
# User Guild Roles
|
||||
for m_role in member_roles:
|
||||
time.sleep(0)
|
||||
for g_role in guild_roles:
|
||||
time.sleep(0)
|
||||
if g_role["id"] == m_role:
|
||||
perm |= g_role["permissions"]
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user