"Untitled" By gando (https://pastebin.com/u/gando) URL: https://pastebin.com/pb1s0hvg Created on: Wednesday 7th of September 2011 04:51:04 PM CDT Retrieved on: Saturday 31 of October 2020 07:58:02 AM UTC #!/usr/bin/python import re from urllib import urlopen dashes = "------------" url = 'http://74.63.239.234/banlist.txt' ban_list = urlopen(url).readlines() #clean shit from beginning of banlist.txt ban_list = ban_list[37:] #init the ban list BANS = [] for line in ban_list: #place holders ban_nicks = [] ban_ids = [] ban_length = "" ban_msg = [] #get ban time ban_time = ' '.join(line.split()[:2]) #test for validity if len(line.split('STEAM')) < 3: continue # split the line with whitespace as delim tmp_list = line.split()[2:] #another validity test if len(tmp_list) < 11: continue #loop twice(2 STEAM id's) for z in range(0,2): for i in range(0,len(tmp_list)): #match steam id if re.match('STEAM_[0-1]:[0-1]:\d+', tmp_list[i]): #append id to place holder list ban_ids.append(tmp_list[i]) #append everything before id to nick place holder list ban_nicks.append(' '.join(tmp_list[:i])) #if ban_length not set, it's right after 1st steam ID if len(ban_length) == 0: ban_length = tmp_list[i+1] #slice everything already looped away tmp_list = tmp_list[i+2:] #break to next parent loop break #loop trough what's left in tmp_list (the ban msg and the extra at end) for i in tmp_list: #if we encounter '(' stop if i.startswith('('): break ban_msg.append(i) #join the ban message back together ban_msg = ' '.join(ban_msg) #print shit # print "----------" # print "Ban timestamp: " + str(ban_time) # print "Banned user: " + str(ban_nicks[0]) +' / '+ str(ban_ids[0]) # print "Ban message: " + str(ban_msg) # print "Ban length: " + str(ban_length) # print "Set by: " + str(ban_nicks[1]) +' / '+ str(ban_ids[1]) # print "----------" #use tmp_list again to parse everything back together tmp_list = [str(ban_time),str(ban_nicks[0]),str(ban_ids[0]),str(ban_length),str(ban_nicks[1]),str(ban_ids[1]),str(ban_msg)] #append the list to the global ban list BANS.append(tmp_list) #from now on, you can manipulate BANS easily and extract info from them #ie. this would print all banned nicks #for i in BANS: # print i[1] #ie. to get unique bans next = input("What do you want to know?\nPress 1 to print the amount of total bans and unique bans.\n\ Press 2 to look up all of the bans of a specific SteamID.\nPress 3 to view all former aliases of a SteamID.\nPress 4 to view the total ban time of a SteamID.\nPress 5 to view general information about a SteamID. > ") print dashes print "\n" if next == 1: unique_list = [] unique_tmp = [] for i in BANS: if i[2] not in unique_tmp: unique_tmp.append(i[2]) unique_list.append(i) print "Unique bans: " + str(len(unique_list)) print "Total bans: " + str(len(BANS)) if next == 2: id_list = [] id_tmp = [] id_compare = raw_input("What SteamID do you want to view bans for? > ") for i in BANS: # print i[2] if i[2] == id_compare: id_tmp.append(i) print "----------" print "Ban timestamp: " + str(i[0]) print "Banned user: " + str(i[1]) +' / '+ str(i[2]) print "Ban message: " + str(i[6]) print "Ban length: " + str(i[3]) print "Set by: " + str(i[4]) +' / '+ str(i[5]) print "----------" # print id_list if next == 3: id_nicks = [] id_compare = raw_input("What SteamID do you want to view past nicknames for? > ") for i in BANS: if i[2] == id_compare: print dashes print str(i[0]) + ": " + str(i[1]) if next == 4: id_time = [] id_compare = raw_input("What SteamID do you want to view total ban time for? > ") for i in BANS: if i[2] == id_compare: id_time.append(int(i[3])) print dashes print id_compare+" has been banned for a total of " + str(sum(id_time)) + " minutes, total amount of bans: "+str(len(id_time)) print dashes if next == 5: id_compare = raw_input("What SteamID do you want to view general information for? > ") print dashes print "\n" print id_compare id_lastknown = [] for i in BANS: if i[2] == id_compare: id_lastknown.append(str(i[1])) print "Last known as: "+id_lastknown[-1] print "Total bans of "+id_compare+": "+str(len(id_lastknown)) print "\n" print "What do you want to know about "+id_compare+"?" nextnext = input("Press 1 to view all bans for "+id_compare+".\nPress 2 to view past nicknames for "+id_compare+".\nPress 3 to view total ban time for "+id_compare+".\n\n$> ") print dashes print "\n" if nextnext == 1: print "All bans for "+id_compare+":" for i in BANS: if i[2] == id_compare: print "----------" print "Ban timestamp: " + str(i[0]) print "Banned user: " + str(i[1]) +' / '+ str(i[2]) print "Ban message: " + str(i[6]) print "Ban length: " + str(i[3]) print "Set by: " + str(i[4]) +' / '+ str(i[5]) print "----------" if nextnext == 2: for i in BANS: if i[2] == id_compare: print dashes print str(i[0]) + ": " + str(i[1]) if nextnext == 3: id_time = [] for i in BANS: if i[2] == id_compare: id_time.append(int(i[3])) print dashes print id_compare+" has been banned for a total of " + str(sum(id_time)) + " minutes, total amount of bans: "+str(len(id_time)) print dashes #['03/02/10 12:55:09', 'Unknown', 'STEAM_0:1:9420667', '1440', 'Sinavestos', 'STEAM_0:0:26672860', 'repeated spawnkill, next time will be perma']