.BANCHO. Add logHelper

This commit is contained in:
Nyo
2016-06-02 21:50:10 +02:00
parent 611216fea2
commit 3100853903
4 changed files with 53 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ from objects import glob
from objects import fokabot
from constants import exceptions
from constants import messageTemplates
from time import gmtime, strftime
from helpers import generalFunctions
def handle(userToken, packetData):
"""
@@ -51,7 +51,7 @@ def handle(userToken, packetData):
# Log to file
with open(".data/chatlog_private.txt", "a") as f:
f.write("[{date}] {fro} -> {to}: {message}\n".format(date=strftime("%Y-%m-%d %H:%M:%S", gmtime()), fro=username, to=packetData["to"], message=str(packetData["message"].encode("utf-8"))[2:-1]))
f.write("[{date}] {fro} -> {to}: {message}\n".format(date=generalFunctions.getTimestamp(), fro=username, to=packetData["to"], message=str(packetData["message"].encode("utf-8"))[2:-1]))
except exceptions.tokenNotFoundException:
# Token not found, user disconnected
consoleHelper.printColored("[!] {} tried to send a message to {}, but their token couldn't be found".format(username, packetData["to"]), bcolors.RED)