added requested feature to check game time of any steam ID

This commit is contained in:
jenz 2023-03-24 23:26:54 +01:00
parent 4f5e6a5b3a
commit 00a6f3ce8e

View File

@ -140,6 +140,7 @@ def check_both_steam_connections_types(res):
"""
cur2.execute(sql_statement, [steam_id2])
res_all = cur2.fetchall()
conn2.close()
return res_all, steam_id2, steam_id64
def gen_steam_acount_str(steam_id2_1, steam_id2_2, steam_id64_1, steam_id64_2):
@ -155,6 +156,23 @@ async def on_message(message):
if message.author.bot:
return
if client.user.mentioned_in(message):
if ('#STEAM_') in message.content:
steam_id = message.content.split("#")[1]
with get_connection_playtime() as conn2:
with conn2.cursor(buffered=True) as cur2:
sql_statement = """
select ze_time, mg_time, zr_time, jb_time, discord_allowed from unloze_playtimestats.player_time pt
where pt.steam_id = %s
"""
cur2.execute(sql_statement, [steam_id])
res_all = cur2.fetchall()
conn2.close()
if not res_all:
await message.channel.send("Steam ID not found/valid")
return
ip_counter, total_time_hours, total_time_minutes, ze_time_hours, ze_time_minutes, zr_time_hours, zr_time_minutes, mg_time_hours, mg_time_minutes, jb_time_hours, jb_time_minutes = count_hours(res_all)
await message.channel.send(f"""Steam ID: {steam_id} \nZE playtime: {ze_time_hours} hours {ze_time_minutes} minutes.\nMG playtime: {mg_time_hours} hours {mg_time_minutes} minutes.\nZR playtime: {zr_time_hours} hours {zr_time_minutes} minutes.\nJB playtime: {jb_time_hours} hours {jb_time_minutes} minutes. """)
return
msg = message
discord_id = message.author.id
target_name = message.author.name
@ -190,6 +208,7 @@ async def on_message(message):
first_account = False
first_account = await generate_hours_message(steam_id2_1, steam_id64_1, res_all_1, steam_account, discord_id, res_user_id, target_name, message, first_account, None)
await generate_hours_message(steam_id2_2, steam_id64_2, res_all_2, steam_account, discord_id, res_user_id, target_name, message, first_account, steam_id2_1)
conn.close()
async def update_asn(ipv4, steam_id2_, client, discord_id, member, bad_asn, steam_account, res_user_id, cur2, conn2):
@ -316,6 +335,7 @@ async def check_person_to_allow():
steam_account = gen_steam_acount_str(steam_id2_1, steam_id2_2, steam_id64_1, steam_id64_2)
await verify_player(res_all_1, steam_id2_1, steam_account, member, discord_id, client, res_user_id, bad_asn, None, cur2, conn2)
await verify_player(res_all_2, steam_id2_2, steam_account, member, discord_id, client, res_user_id, bad_asn, steam_id2_1, cur2, conn2)
conn.close()
def main():
check_person_to_allow.start()