Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions torchat/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def isWindows():
("gui", "color_nick_buddy") : "#c00000",
("gui", "color_text_back") : "#ffffff",
("gui", "color_text_fore") : "#000000",
("gui", "color_actions") : "#220000",
("gui", "color_text_use_system_colors") : 1,
("gui", "chat_font_name") : "Arial",
("gui", "chat_font_size") : 10,
Expand Down
47 changes: 43 additions & 4 deletions torchat/src/tc_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import time
import subprocess
import textwrap
import random
import version
import dlg_settings
import translations
import tc_notification
import string
import array
lang = translations.lang_en
tb = config.tb
tb1 = config.tb1
Expand Down Expand Up @@ -1095,6 +1098,12 @@ def setStatus(self, status):


class ChatWindow(wx.Frame):
pings = {}

def pid(self, sizestr=6, charstouse=string.ascii_uppercase + string.digits):
return ''.join(random.choice(charstouse) for x in range(sizestr))


def __init__(self, main_window, buddy, message="",
hidden=False,
notify_offline_sent=False):
Expand Down Expand Up @@ -1326,8 +1335,30 @@ def process(self, message):
name = self.buddy.name
else:
name = self.buddy.address
self.writeColored(config.get("gui", "color_nick_buddy"), name, message)
self.notify(name, message)

if message.startswith("/ping ") and len(message) == 12:
#This was a triumph
#I'm making a note here, huge success
#It's hard to overstate my satisfaction
randchars = message.split(" ")
self.buddy.sendChatMessage("/PONG " + randchars[1])
self.writeColored(config.get("gui", "color_actions"), "", "[PING]")
elif message.startswith("/PONG") and len(message) == 12:
timeg = time.time()
randchars = message.split(" ")
onetimepid = randchars[1]
gtimefdict = self.pings[onetimepid][0]
self.pings[onetimepid] = [gtimefdict, timeg]
timetotal = self.pings[onetimepid][1] - self.pings[onetimepid][0]
#print "Time sent[PING]: " + str(self.pings[onetimepid][0])
#print "Time received[PONG]: " + str(self.pings[onetimepid][1])
#print "Total Time: " + str(timetotal)
#print "Total Time / 2(One msg?)" + str(timetotal / 2)
self.buddy.sendChatMessage("[PONG] (" + str(round(timetotal / 2, 2)) + "s)")
self.writeColored(config.get("gui", "color_actions"), "", "[PONG] (" + str(round(timetotal / 2, 2)) + "s)")
else:
self.writeColored(config.get("gui", "color_nick_buddy"), name, message)
self.notify(name, message)

def onActivate(self, evt):
self.unread = 0
Expand Down Expand Up @@ -1370,8 +1401,16 @@ def onSend(self, evt):
self.txt_out.SetValue("")

if self.buddy.status not in [tc_client.STATUS_OFFLINE, tc_client.STATUS_HANDSHAKE]:
self.buddy.sendChatMessage(text)
self.writeColored(config.get("gui", "color_nick_myself"),
if text == "/ping":
onetimepid = self.pid()
self.buddy.sendChatMessage("/ping " + str(onetimepid))
self.pings[onetimepid] = [time.time()]
self.writeColored(config.get("gui", "color_actions"),
",
"[PING]")
else:
self.buddy.sendChatMessage(text)
self.writeColored(config.get("gui", "color_nick_myself"),
"myself",
text)
else:
Expand Down