mirror of https://github.com/hak5/ToorChat.git
Working updates
parent
0db444ac72
commit
9cdd51111a
|
@ -12,6 +12,7 @@ class ToorChatProtocol():
|
||||||
''' This is used to send a simple message over the toorchat protocol '''
|
''' This is used to send a simple message over the toorchat protocol '''
|
||||||
msg = ToorChatMessage(message, user)
|
msg = ToorChatMessage(message, user)
|
||||||
self.device.RFxmit(msg.to_string())
|
self.device.RFxmit(msg.to_string())
|
||||||
|
return msg
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_message(cls, raw_message):
|
def parse_message(cls, raw_message):
|
||||||
|
|
25
toorchat.py
25
toorchat.py
|
@ -51,26 +51,19 @@ class Visualizer():
|
||||||
self.screen_max_y, self.screen_max_x = self.screen.getmaxyx()
|
self.screen_max_y, self.screen_max_x = self.screen.getmaxyx()
|
||||||
self.__draw_frame__()
|
self.__draw_frame__()
|
||||||
self.screen.refresh()
|
self.screen.refresh()
|
||||||
last_message_index = 0
|
self.last_message_index = 0
|
||||||
while True:
|
while True:
|
||||||
self.screen_max_y, self.screen_max_x = self.screen.getmaxyx()
|
self.screen_max_y, self.screen_max_x = self.screen.getmaxyx()
|
||||||
self.screen.addstr(0, 1, "[S] Send Message [U] Set User Name")
|
self.screen.addstr(0, 1, "[S] Send Message [U] Set User Name")
|
||||||
if len(self.message_queue) > 0:
|
self.__add_message_to_screen__()
|
||||||
message = self.message_queue[len(self.message_queue)-1]
|
|
||||||
message_string = str(message.user)+":"+ str(message.data)
|
|
||||||
self.screen.addstr(last_message_index+3,1, message_string + " "*(self.screen_max_x-(2+len(message_string))))
|
|
||||||
print self.screen_max_x
|
|
||||||
last_message_index +=1
|
|
||||||
self.message_queue.pop()
|
|
||||||
if last_message_index > self.screen_max_y-5:
|
|
||||||
last_message_index = 0
|
|
||||||
entry = self.screen.getch()
|
entry = self.screen.getch()
|
||||||
if entry == curses.KEY_RESIZE:
|
if entry == curses.KEY_RESIZE:
|
||||||
self.__draw_frame__()
|
self.__draw_frame__()
|
||||||
if entry == ord('s'):
|
if entry == ord('s'):
|
||||||
self.screen.nodelay(0)
|
self.screen.nodelay(0)
|
||||||
user_input = self.screen.getstr(1, 1, 60)
|
user_input = self.screen.getstr(1, 1, 60)
|
||||||
self.protocol.send_message(user_input, self.user)
|
old_message = self.protocol.send_message(user_input, self.user)
|
||||||
|
self.message_queue.append(old_message)
|
||||||
self.screen.nodelay(1)
|
self.screen.nodelay(1)
|
||||||
self.screen.addstr(1,1," "*(self.screen_max_x-3))
|
self.screen.addstr(1,1," "*(self.screen_max_x-3))
|
||||||
if entry == ord('u'):
|
if entry == ord('u'):
|
||||||
|
@ -84,6 +77,16 @@ class Visualizer():
|
||||||
self.exit = True
|
self.exit = True
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
def __add_message_to_screen__(self):
|
||||||
|
if len(self.message_queue) > 0:
|
||||||
|
message = self.message_queue[len(self.message_queue)-1]
|
||||||
|
message_string = str(message.user)+":"+ str(message.data)
|
||||||
|
self.screen.addstr(self.last_message_index+3,1, message_string + " "*(self.screen_max_x-(2+len(message_string))))
|
||||||
|
self.last_message_index +=1
|
||||||
|
self.message_queue.pop()
|
||||||
|
if self.last_message_index > self.screen_max_y-5:
|
||||||
|
self.last_message_index = 0
|
||||||
|
|
||||||
def __draw_frame__(self):
|
def __draw_frame__(self):
|
||||||
self.screen.clear()
|
self.screen.clear()
|
||||||
self.screen.border(0)
|
self.screen.border(0)
|
||||||
|
|
Loading…
Reference in New Issue