mirror of
https://github.com/chev2/tf2-voice-ban-bots.git
synced 2025-10-30 08:12:33 +00:00
Add support for wgetJane's list, code changes
This commit is contained in:
parent
74cfa815fa
commit
f30fba788b
1 changed files with 40 additions and 27 deletions
|
|
@ -3,50 +3,63 @@ import os #path/file opening
|
||||||
import re #regex
|
import re #regex
|
||||||
import requests #http requests
|
import requests #http requests
|
||||||
|
|
||||||
tf2_playerlist_url = "https://raw.githubusercontent.com/PazerOP/tf2_bot_detector/master/staging/cfg/playerlist.official.json" #Pazer's list of bots
|
tf2_botlist_urls = {
|
||||||
tf2_playerlist_url_2 = "https://raw.githubusercontent.com/chev2/tf2-voice-ban-bots/master/voice_ban_users.json" #My list of bots
|
"Pazer": "https://raw.githubusercontent.com/PazerOP/tf2_bot_detector/master/staging/cfg/playerlist.official.json", #Pazer's list of bots
|
||||||
|
"Chev": "https://raw.githubusercontent.com/chev2/tf2-voice-ban-bots/master/voice_ban_users.json", #My list of bots
|
||||||
|
"wgetJane": "https://gist.githubusercontent.com/wgetJane/0bc01bd46d7695362253c5a2fa49f2e9/raw/fefb98e0e10bbab8ff1b38e96adbaabf4a8db94f/bot_list.txt" #wgetJane's list of bots
|
||||||
|
}
|
||||||
github_headers = {
|
github_headers = {
|
||||||
'User-Agent': 'tf2-voice-ban-bots/1.0 (Python script - written by github.com/chev2)'
|
'User-Agent': 'tf2-voice-ban-bots/1.0 (Python script - written by github.com/chev2)'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
steamID64IDEnt = 76561197960265728
|
||||||
steamid3_regex = r'(\[U:1:\d+\])'
|
steamid3_regex = r'(\[U:1:\d+\])'
|
||||||
|
wgetjane_list_regex = r'\n(\d+)'
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
players = []
|
players = []
|
||||||
|
|
||||||
|
def SteamID64To3(id):
|
||||||
|
id3base = int(id) - steamID64IDEnt
|
||||||
|
return "[U:1:{0}]".format(id3base)
|
||||||
|
|
||||||
print("Attempting connection to bots list...")
|
print("Attempting connection to bots list...")
|
||||||
|
for url in tf2_botlist_urls:
|
||||||
|
cur_players = []
|
||||||
|
|
||||||
|
print(f"Attempting connection to {url}'s bot list...")
|
||||||
|
r = requests.get(tf2_botlist_urls[url], headers=github_headers)
|
||||||
|
if r.status_code != 200:
|
||||||
|
print(f"HTTP Error {r.status_code} to {url}'s list has occurred.")
|
||||||
|
else:
|
||||||
|
print(f"Connection to bot {url}'s bot list successful.")
|
||||||
|
|
||||||
#Pazer's bot list
|
if url == "Pazer":
|
||||||
r = requests.get(tf2_playerlist_url, headers=github_headers)
|
js = r.json()
|
||||||
|
|
||||||
if r.status_code != 200:
|
for player in js["players"]:
|
||||||
print(f"HTTP Error {r.status_code} to Pazer's bot list has occured.")
|
cur_players.append(player["steamid"])
|
||||||
else:
|
|
||||||
print("Connection to Pazer's bot list successful.")
|
|
||||||
|
|
||||||
json_info = r.json()
|
players += cur_players
|
||||||
|
elif url == "Chev":
|
||||||
|
js = r.json()
|
||||||
|
|
||||||
for player in json_info["players"]:
|
for player in js:
|
||||||
players.append(player["steamid"])
|
cur_players.append(player)
|
||||||
|
players += cur_players
|
||||||
|
elif url == "wgetJane":
|
||||||
|
txt = r.content
|
||||||
|
|
||||||
print("{0} bots found in Pazer's list.".format(len(players)))
|
for player64 in re.finditer(wgetjane_list_regex, txt.decode('UTF-8')):
|
||||||
|
player = SteamID64To3(player64.group(1))
|
||||||
|
cur_players.append(player)
|
||||||
|
|
||||||
|
players += cur_players
|
||||||
|
|
||||||
#My bot list
|
print(f"{format(len(cur_players), ',d')} bots found in {url}'s list.")
|
||||||
r = requests.get(tf2_playerlist_url_2, headers=github_headers)
|
|
||||||
|
|
||||||
if r.status_code != 200:
|
players = list(set(players)) #remove duplicates in case there are multiple of the same ID in any list
|
||||||
print(f"HTTP Error {r.status_code} to Chev's bot list has occured.")
|
|
||||||
else:
|
|
||||||
print("Connection to Chev's bot list successful.")
|
|
||||||
|
|
||||||
json_info = r.json()
|
print(f"{format(len(players), ',d')} bots found in total.")
|
||||||
|
|
||||||
for player in json_info:
|
|
||||||
players.append(player)
|
|
||||||
|
|
||||||
print("{0} bots found in Chev's list.".format(len(json_info)))
|
|
||||||
|
|
||||||
print("{0} bots found in total.".format(len(players)))
|
|
||||||
|
|
||||||
mergefilequery = None
|
mergefilequery = None
|
||||||
path = None
|
path = None
|
||||||
|
|
@ -76,7 +89,7 @@ players = set(players) #remove duplicates in case of merging
|
||||||
|
|
||||||
players_as_string = "\x01\0\0\0" + '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'.join(players) + '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' #this is how the voice_ban.dt file is patterned
|
players_as_string = "\x01\0\0\0" + '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'.join(players) + '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' #this is how the voice_ban.dt file is patterned
|
||||||
|
|
||||||
print("{0} muted players in total. Removed {1} duplicates.".format(len(players), dupe_number))
|
print(f"{format(len(players), ',d')} muted players in total. Removed {dupe_number} duplicates.")
|
||||||
|
|
||||||
writetofile = None
|
writetofile = None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue