Exemple #1
0
	def __init__(self):
		self.initconfig()
		self.client = FinitClient()
		self.root = tk.Tk()
		self.root.title("FinitPy - Sign in")
		self.app = FinitPyLogin(master=self.root, on_login=self.on_login)
		self.app.mainloop()
Exemple #2
0
class FinitApp:
	def __init__(self):
		self.initconfig()
		self.client = FinitClient()
		self.root = tk.Tk()
		self.root.title("FinitPy - Sign in")
		self.app = FinitPyLogin(master=self.root, on_login=self.on_login)
		self.app.mainloop()
	def initconfig(self):
		if os.path.isfile('config.ini') is False:
			config['MAIN'] = {'displacement': 0}
			with open('config.ini', 'w') as configfile:
				config.write(configfile)
		config.read('config.ini')
	def on_login(self, email, pwd):
		if self.client.login(email, pwd):
			self.root.destroy()
			self.root = tk.Tk()
			self.root.title("FinitPy")
			self.app = FiniyPyMain(master=self.root, conn=self.client)
			self.app.mainloop()
		else:
			self.app.set_error("Wrong credentials")
Exemple #3
0
class FinitApp:
	def __init__(self):
		self.initconfig()
		self.client = FinitClient()
		self.root = tk.Tk()
		self.root.title("FinitPy - Sign in")
		self.app = FinitPyLogin(master=self.root, on_login=self.on_login)
		self.app.mainloop()
	def initconfig(self):
		def extend(a, b):
			for k in b:
				if k not in a:
					a[k] = b[k]
		default_options = {'displacement': 0, 'username in title': 'True', 'email': ''}
		default_colors = {'admin': 'red', 'mod': 'blue', 'op': 'lime green',
			'std': 'black', 'fg': 'black', 'bg': 'white'}
		if os.path.isfile('config.ini') is False:
			config['MAIN'] = default_options
			config['COLOR'] = default_colors
			with open('config.ini', 'w') as configfile:
				config.write(configfile)
		config.read('config.ini')
		if not 'MAIN' in config: config['MAIN'] = {}
		extend(config['MAIN'], default_options)
		if not 'COLOR' in config: config['COLOR'] = {}
		extend(config['COLOR'], default_colors)
		with open('config.ini', 'w') as configfile:
			config.write(configfile)
	def on_login(self, email, pwd):
		if self.client.login(email, pwd):
			self.root.destroy()
			self.root = tk.Tk()
			self.root.title("FinitPy")
			self.app = FiniyPyMain(master=self.root, conn=self.client)
			self.app.mainloop()
		else:
			self.app.set_error("Wrong credentials or network error")
Exemple #4
0
		pass # useless, only for seeing which friends are online
	elif data["event"] == "client-disconnected":
		#{"event":"client-disconnected","userId":2052}
		#print("\033[1G", data, end="\n> ")
		pass # useless, only for seeing which friends are online
	else:
		# We didn't recognize this event
		#print("\033[1G", data, end="\n> ")
		pass

def on_error(conn, e):
	print("ERROR:", e)
	sys.exit()

if __name__ == "__main__":
	c = FinitClient()
	c.on_login = on_login
	c.on_message = on_message
	c.on_logout = on_logout
	c.on_error = on_error
	c.login(input("Email> "), getpass("Password> "))
	try:
		last_room = None
		while True:
			cmd = input("> ")
			orig_cmd = cmd
			cmd = cmd.strip().split(maxsplit=1)
			if len(cmd) > 0:
				cmd[0] = cmd[0].upper()
			if len(cmd) > 0 and cmd[0] == "/HELP":
				print("Available commands:")
Exemple #5
0
        #{"event":"client-disconnected","userId":2052}
        #print("\033[1G", data, end="\n> ")
        pass  # useless, only for seeing which friends are online
    else:
        # We didn't recognize this event
        #print("\033[1G", data, end="\n> ")
        pass


def on_error(conn, e):
    traceback.print_exc()
    sys.exit()


if __name__ == "__main__":
    c = FinitClient()
    c.on_login = on_login
    c.on_message = on_message
    c.on_logout = on_logout
    c.on_error = on_error
    c.login(input("Email> "), getpass("Password> "))
    try:
        last_room = None
        while True:
            cmd = input("> ")
            orig_cmd = cmd
            cmd = cmd.strip().split(maxsplit=1)
            if len(cmd) > 0:
                cmd[0] = cmd[0].upper()
            if len(cmd) > 0 and cmd[0] == "/HELP":
                print("Available commands:")