#!/usr/bin/env python
"""
Pokemon Showdown! Unregistered Account finder.
Written by DoW, heavily inspired by the work of Sebastian D. (https://github.com/vlaridus/PS-AccountChecker/blob/master/)
Copyright (c) 2017 DoW
License: MIT License
"""
#include "bodge.h" //used throughout
import Tkinter, time, requests
root = Tkinter.Tk()
frame = Tkinter.Frame(root)
frame.grid()
intro_text = """Welcome to the Showdown Namefinder!
Input preferences then click 'find'."""
message = Tkinter.Message(root, text = intro_text, width = 250, padx = 10, pady = 5)
message.grid(row = 0, column = 0)
var = Tkinter.StringVar(root)
var.set('All words')
options = Tkinter.OptionMenu(root, var, 'All words', 'Everything up to _ letters', 'Words beginning with _', 'Words containing _')
options.grid(row = 1, column = 0)
e = Tkinter.Entry(root)
e.grid(row = 2, column = 0)
out_label = Tkinter.Message(root, text = "Available usernames: ", width = 200, padx = 50, pady = 5)
out_label.grid(row = 0, column = 1)
out_box = Tkinter.Text(root, width = 30, height = 10)
out_box.grid(row = 1, column = 1, rowspan = 2)
stopped = False
def check_names():
global stopped
stopped = False
mode = var.get()
check = e.get()
if len(check) > 18 and '_' in mode:
print("Can't search for names of length > 18. Exiting.")
exit() #should probably change this to putting a warning on tkinter and looping back, owell
found = []
filename = time.strftime("%Y_%m_%d_")
if mode == 'All words': filename += '1.txt'
elif mode == 'Words beginning with _': filename += '2.txt'
elif mode == 'Words containing _': filename += '3.txt'
else: filename += '4.txt'
if mode in ['All words', 'Words beginning with _', 'Words containing _']:
f = open('words.txt','r'); words = f.read().split('\n'); f.close()
try:
for i in words:
if stopped: break
try:
a = int(i)
continue
except KeyboardInterrupt: raise
except: pass
if mode == 'Words beginning with _' and i[:len(check)] != check: continue
if mode == 'Words containing _' and check not in i: continue
if not requests.get('https://pokemonshowdown.com/users/%s.json'%i).json()['registertime']:
found.append(i)
out_box.insert(Tkinter.END, i + '\n')
root.update()
except KeyboardInterrupt:
f = open(filename, 'w')
to_write = 'Unregistered usernames:'
for i in found: to_write += '\n' + i
f.write(to_write)
f.close()
print('Wrote output to ' + filename)
else:
try:
check = int(check)
if check > 3:
print('Warning: this process may take a while. Use CTRL+C to abort the process.') #probably want this warning on the GUI at all times tbh
except:
check = 5
all_chars = []
for i in range(0,10):
all_chars.append(str(i))
for i in range(97,123):
all_chars.append(chr(i))
i = 0
try:
while i < 36**check and not stopped:
j = i
this_str = all_chars[j%36] #>tfw no do while
j = int(j/36) #rounds down. Gotta keep code valid for python3
while j:
this_str += all_chars[j%36]
j = int(j/36)
try:
this_str = int(this_str)
i += 1
continue
except KeyboardInterrupt: raise
except: pass
if not requests.get('https://pokemonshowdown.com/users/%s.json'%this_str).json()['registertime']:
found.append(this_str)
out_box.insert(Tkinter.END, this_str + '\n')
root.update()
i += 1
except KeyboardInterrupt:
f = open(filename, 'w')
to_write = 'Unregistered usernames:'
for i in found: to_write += '\n' + i
f.write(to_write)
f.close()
print('Wrote output to ' + filename)
f = open(filename, 'w')
to_write = 'Unregistered usernames:'
for i in found:
to_write += '\n' + i
f.write(to_write)
f.close()
print('Wrote output to ' + filename)
find_button = Tkinter.Button(root, text = 'Find', command = check_names)
find_button.grid(row = 3, column = 0)
def stop():
global stopped
stopped = True
stop_button = Tkinter.Button(root, text = 'Stop', command = stop)
stop_button.grid(row = 3, column = 1)
root.mainloop()