exposed noob
This commit is contained in:
parent
f578811e25
commit
3fccca1012
@ -8,23 +8,37 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "init.hpp"
|
#include "init.hpp"
|
||||||
|
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace chatlog {
|
namespace chatlog {
|
||||||
|
|
||||||
CatVar enabled(CV_SWITCH, "chat_log", "0", "Chat log", "Log chat to file");
|
CatVar enabled(CV_SWITCH, "chat_log", "0", "Chat log", "Log chat to file");
|
||||||
CatVar message_template(CV_STRING, "chat_log_template", "[U:1:%u] %n: %m", "Log template", "%u - SteamID\n%n - name\n%m - message");
|
CatVar message_template(CV_STRING, "chat_log_template", "[%t] [U:1:%u] %n: %m", "Log template", "%u - SteamID\n%n - name\n%m - message\n%t - time");
|
||||||
CatVar dont_log_spam(CV_SWITCH, "chat_log_nospam", "1", "No Spam", "Don't log your messages if spam is active");
|
CatVar dont_log_spam(CV_SWITCH, "chat_log_nospam", "1", "No Spam", "Don't log your messages if spam is active");
|
||||||
|
|
||||||
class RAIILog {
|
class RAIILog {
|
||||||
public:
|
public:
|
||||||
RAIILog() {
|
RAIILog() {
|
||||||
stream.open("cathook/chat.log", std::ios::out | std::ios::app);
|
open();
|
||||||
}
|
}
|
||||||
~RAIILog() {
|
~RAIILog() {
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
|
void open() {
|
||||||
|
logging::Info("Trying to open log file");
|
||||||
|
uid_t uid = geteuid();
|
||||||
|
struct passwd *pw = getpwuid(uid);
|
||||||
|
std::string uname = "";
|
||||||
|
if (pw) {
|
||||||
|
uname = std::string(pw->pw_name);
|
||||||
|
}
|
||||||
|
stream.open("cathook/chat-" + uname + ".log", std::ios::out | std::ios::app);
|
||||||
|
}
|
||||||
void log(const std::string& msg) {
|
void log(const std::string& msg) {
|
||||||
if (stream.bad()) {
|
if (stream.bad()) {
|
||||||
logging::Info("[ERROR] RAIILog stream is bad!");
|
logging::Info("[ERROR] RAIILog stream is bad!");
|
||||||
|
open();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stream << msg << "\n";
|
stream << msg << "\n";
|
||||||
@ -54,7 +68,14 @@ void LogMessage(int eid, std::string message) {
|
|||||||
for (auto& x : message) {
|
for (auto& x : message) {
|
||||||
if (x < 32) x = '*';
|
if (x < 32) x = '*';
|
||||||
}
|
}
|
||||||
|
time_t current_time;
|
||||||
|
struct tm * time_info;
|
||||||
|
char timeString[9];
|
||||||
|
time(¤t_time);
|
||||||
|
time_info = localtime(¤t_time);
|
||||||
|
strftime(timeString, sizeof(timeString), "%H:%M:%S", time_info);
|
||||||
std::string msg(message_template.GetString());
|
std::string msg(message_template.GetString());
|
||||||
|
ReplaceString(msg, "%t", std::string(timeString));
|
||||||
ReplaceString(msg, "%u", std::to_string(info.friendsID));
|
ReplaceString(msg, "%u", std::to_string(info.friendsID));
|
||||||
ReplaceString(msg, "%n", name);
|
ReplaceString(msg, "%n", name);
|
||||||
ReplaceString(msg, "%m", message);
|
ReplaceString(msg, "%m", message);
|
||||||
|
@ -29,8 +29,9 @@ CatCommand debug_startsearch("debug_startsearch", "DEBUG StartSearch", []() {
|
|||||||
logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(4));
|
logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(4));
|
||||||
});
|
});
|
||||||
CatCommand debug_casual("debug_casual", "DEBUG Casual", []() {
|
CatCommand debug_casual("debug_casual", "DEBUG Casual", []() {
|
||||||
logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(6));
|
g_IEngine->ExecuteClientCmd("OpenMatchmakingLobby casual");
|
||||||
g_TFGCClientSystem->LoadSearchCriteria();
|
g_TFGCClientSystem->LoadSearchCriteria();
|
||||||
|
//logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(6));
|
||||||
});
|
});
|
||||||
|
|
||||||
CatCommand debug_readytosearch("debug_gcstate", "DEBUG GCState", []() {
|
CatCommand debug_readytosearch("debug_gcstate", "DEBUG GCState", []() {
|
||||||
@ -60,7 +61,7 @@ void UpdateSearch() {
|
|||||||
} else if (g_TFGCClientSystem->GetState() == 5) {
|
} else if (g_TFGCClientSystem->GetState() == 5) {
|
||||||
g_IEngine->ExecuteClientCmd("OpenMatchmakingLobby casual");
|
g_IEngine->ExecuteClientCmd("OpenMatchmakingLobby casual");
|
||||||
g_TFGCClientSystem->LoadSearchCriteria();
|
g_TFGCClientSystem->LoadSearchCriteria();
|
||||||
logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(6));
|
//logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
last_check = std::chrono::system_clock::now();
|
last_check = std::chrono::system_clock::now();
|
||||||
|
@ -29,8 +29,14 @@ void logging::Info(const char* fmt, ...) {
|
|||||||
vsprintf(buffer, fmt, list);
|
vsprintf(buffer, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
size_t length = strlen(buffer);
|
size_t length = strlen(buffer);
|
||||||
char* result = new char[length + 9];
|
char* result = new char[length + 24];
|
||||||
sprintf(result, "[CAT] %s\n", buffer);
|
time_t current_time;
|
||||||
|
struct tm * time_info = nullptr;
|
||||||
|
char timeString[10];
|
||||||
|
time(¤t_time);
|
||||||
|
time_info = localtime(¤t_time);
|
||||||
|
strftime(timeString, sizeof(timeString), "%H:%M:%S", time_info);
|
||||||
|
sprintf(result, "%% [%s] %s\n", timeString, buffer);
|
||||||
fprintf(logging::handle, "%s", result);
|
fprintf(logging::handle, "%s", result);
|
||||||
fflush(logging::handle);
|
fflush(logging::handle);
|
||||||
#ifndef TEXTMODE
|
#ifndef TEXTMODE
|
||||||
|
Reference in New Issue
Block a user