Ejemplo n.º 1
0
def login(username):
	os.system("clear")
	c = ChatClient()

	if c.connect(username):
		sys.stdout.write("\x1b]2;%s\x07" % (c.username))
		try:

			while c.connected == 1:
				msg = raw_input()
				msg = msg.strip()
				print "\033[A                             \033[A"
				if(len(msg)==0):
					continue
				try:
					cmd , temp = filter_message(msg)
					if cmd==-2:
						c.disconnect()
						clear_screen("Disconnecting...")
						break
					elif cmd==1:
						if len(msg.split(' ')) == 1:
							print bcolors.warning_message("~ChatUs~ : ") + bcolors.whisper_message("user %s is online" % (temp))
						else:
							print bcolors.whisper_message("<You> : %s" % (msg))
							c.say(msg)
					elif cmd==11:
						c.say(temp)
						print bcolors.whisper_message("<You> : Send file to %s" % (msg))
					elif cmd==-1:
						print bcolors.warning_message("~ChatUs~ : ") + bcolors.fail_message("user %s is offline" % (temp))
					elif cmd==2:
						print_list()
					elif cmd==3:
						if temp != '':
							c.say(temp)
					else:
						if(len(msg)>=1):
							print bcolors.normal_message("<You> : %s" % (msg))
							c.say(msg)
				except:
					break

		except KeyboardInterrupt:
			c.disconnect()
			clear_screen("Disconnecting...")
	else:
		clear_screen("Server is offline")
Ejemplo n.º 2
0
def print_list():
	users = proxy.list_user()
	print bcolors.warning_message("~ChatUs~ :")
	for user in users:
		print bcolors.whisper_message("* %s" % user)
	print bcolors.warning_message("%s user(s) online" % (str(len(users))))
	print bcolors.warning_message("-------------------")