Jump to content

[Brainstorm]Right-click Report Spam


Guest henhouse

Recommended Posts

I've often noticed they report spam feature has never worked; I've been wondering... how hard would it be to program one? I could see it save into a file like Spam.log and you can enable it/disable. Then it could record it something like:

2008-12-21 11:03:19 Character: Tester1 Text: Reported Spam goes here. Reported by: Tester2

Any other ideas, suggestions?

Link to comment
Share on other sites

I've often noticed they report spam feature has never worked; I've been wondering... how hard would it be to program one? I could see it save into a file like Spam.log and you can enable it/disable. Then it could record it something like:

Any other ideas, suggestions?

I wrote small patch for it, maybe you could test it and give report and then maybe post to review

diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 8812701..ca3da21 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1336,7 +1336,10 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
    data << uint8(0);
    SendPacket(&data);

-    sLog.outDebug("REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str());
+    std::string spamer_name;
+    objmgr.GetPlayerNameByGUID(spammer_guid, spamer_name);
+    
+    sLog.outSpam("Spamer: %s (Guid %u) , Message : %s , Reporter : %s", spamer_name.c_str() ,GUID_LOPART(spammer_guid) , description.c_str(), GetPlayerName());
}

void WorldSession::HandleRealmStateRequestOpcode( WorldPacket & recv_data )
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 2c6ca91..c708457 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -251,6 +251,10 @@ AddonChannel = 1
#        Default: 0 - don't include dumping chars to log
#                 1 - include dumping chars to log
#
+#    SpamLogFile
+#        Spam Log file for logging player reported spams
+#        Default: "" (disabled) 
+#
#    GmLogFile
#        GM Log file of gm commands
#        Default: "" (Disable)
@@ -296,6 +300,7 @@ DBErrorLogFile = "DBErrors.log"
CharLogFile = "Char.log"
CharLogTimestamp = 0
CharLogDump = 0
+SpamlogFile = "spam.log"
GmLogFile = ""
GmLogTimestamp = 0
GmLogPerAccount = 0
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
index f5d0513..45c0e1a 100644
--- a/src/shared/Log.cpp
+++ b/src/shared/Log.cpp
@@ -37,7 +37,7 @@ enum LogType
const int LogType_count = int(LogError) +1;

Log::Log() :
-    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
+    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), spamlog(NULL),
    dberLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false)
{
    Initialize();
@@ -228,6 +228,7 @@ void Log::Initialize()

    dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
    raLogfile = openLogFile("RaLogFile",NULL,"a");
+    spamlog = openLogFile("SpamlogFile", NULL, "a");

    // Main log file settings
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
@@ -725,6 +726,38 @@ void Log::outRALog(    const char * str, ... )
    fflush(stdout);
}

+void Log::outSpam( const char * msg, ... )
+{
+    if( !msg ) return;
+
+    if(m_colored)
+        SetColor(false,m_colors[LogError]);
+
+    if(m_includeTime)
+        outTime();
+
+    va_list ap;
+    va_start(ap, msg);
+    vfprintf( stderr, msg, ap );
+    va_end(ap);
+
+    if(m_colored)
+        ResetColor(false);
+
+    fprintf( stderr, "\\n" );
+    if(spamlog)
+    {
+        outTimestamp(spamlog);
+        fprintf(spamlog, "Reported spam:" );
+        va_start(ap, msg);
+        vfprintf(spamlog, msg, ap);
+        fprintf(spamlog, "\\n" );
+        va_end(ap);
+        fflush(spamlog);
+    }
+    fflush(stderr);
+}
+
void outstring_log(const char * str, ...)
{
    if( !str )
diff --git a/src/shared/Log.h b/src/shared/Log.h
index 391a93d..bc071e2 100644
--- a/src/shared/Log.h
+++ b/src/shared/Log.h
@@ -79,6 +79,11 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
        if (raLogfile != NULL)
            fclose(raLogfile);
        raLogfile = NULL;
+        
+           if (spamlog != NULL)
+            fclose(spamlog);
+        raLogfile = NULL;
+
    }
    public:
        void Initialize();
@@ -107,6 +112,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
                                                            // any log level
        void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
        void outRALog( const char * str, ... )       ATTR_PRINTF(2,3);
+        void outSpam( const char * msg, ... )       ATTR_PRINTF(2,3);
+
        void SetLogLevel(char * Level);
        void SetLogFileLevel(char * Level);
        void SetColor(bool stdout_stream, Color color);
@@ -123,6 +130,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
        FILE* openGmlogPerAccount(uint32 account);

        FILE* raLogfile;
+      FILE* spamlog;
        FILE* logfile;
        FILE* gmLogfile;
        FILE* charLogfile;

git apply < patch.diff

Link to comment
Share on other sites

Looks great charlie2025! I'm currently compiling MaNGOS now, I'll write back how it works. (Sorry if I double post).

Oh by the way, I had to use $patch -p1 < patch.diff; $git apply gave lots of errors, mostly the white space errors.

Last patching line said: "patch unexpectedly ends in middle of line" I assume that's okay right?

Link to comment
Share on other sites

Alright I've tested it, it works fine chat wise. A sample report:

2008-12-22 00:19:57 Reported spam:Spamer: Sargarix (Guid 5291) , Message : Type: [1], Channel: [], Player Name: [sargarix], Text: [hwjerwer] , Reporter : Henhouse
Could be cleaned up a little (spaces, etc). But looks good.

So I decided to try Mailbox report spam, this actually logs too! However it's a little different. It returned with:

2008-12-22 00:24:14 Reported spam:Spamer: Henhouse (Guid 2) , Message : , Reporter : Sargarix
As you can see it's confused what happened.

Other than that this is really good! Once it's finished I think it'll get added to the source. Great work charlie2025.

Link to comment
Share on other sites

Alright I've tested it, it works fine chat wise. A sample report:

Could be cleaned up a little (spaces, etc). But looks good.

So I decided to try Mailbox report spam, this actually logs too! However it's a little different. It returned with:

As you can see it's confused what happened.

Other than that this is really good! Once it's finished I think it'll get added to the source. Great work charlie2025.

The empty space in mail report spam is caused by different filling of variables if mail/chat spam, I do something with it.

Here is new patch

diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 8812701..1bf7e14 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1310,6 +1310,10 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
    std::string description = "";
    recv_data >> spam_type;                                 // unk 0x01 const, may be spam type (mail/chat)
    recv_data >> spammer_guid;                              // player guid
+
+    std::string spammer_name;
+    objmgr.GetPlayerNameByGUID(spammer_guid, spammer_name);
+
    switch(spam_type)
    {
        case 0:
@@ -1317,7 +1321,9 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
            recv_data >> unk1;                              // const 0
            recv_data >> unk2;                              // probably mail id
            recv_data >> unk3;                              // const 0
-            break;
+               sLog.outSpam("Mail: ID %u (Owner %u), Reporter : %s", unk2 , spammer_guid, GetPlayerName());
+
+            break;
        case 1:
            CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4+4+1);
            recv_data >> unk1;                              // probably language
@@ -1325,7 +1331,8 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
            recv_data >> unk3;                              // probably channel id
            recv_data >> unk4;                              // unk random value
            recv_data >> description;                       // spam description string (messagetype, channel name, player name, message)
-            break;
+            sLog.outSpam("Chat: Player %s (%u), Reporter: %s, Data: %s ", spammer_name.c_str(), spammer_guid, GetPlayerName(), description.c_str());           
+            break;
    }

    // NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam.
@@ -1335,8 +1342,7 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
    WorldPacket data(SMSG_COMPLAIN_RESULT, 1);
    data << uint8(0);
    SendPacket(&data);
-
-    sLog.outDebug("REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str());
+    
}

void WorldSession::HandleRealmStateRequestOpcode( WorldPacket & recv_data )
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 2c6ca91..c708457 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -251,6 +251,10 @@ AddonChannel = 1
#        Default: 0 - don't include dumping chars to log
#                 1 - include dumping chars to log
#
+#    SpamLogFile
+#        Spam Log file for logging player reported spams
+#        Default: "" (disabled) 
+#
#    GmLogFile
#        GM Log file of gm commands
#        Default: "" (Disable)
@@ -296,6 +300,7 @@ DBErrorLogFile = "DBErrors.log"
CharLogFile = "Char.log"
CharLogTimestamp = 0
CharLogDump = 0
+SpamlogFile = "spam.log"
GmLogFile = ""
GmLogTimestamp = 0
GmLogPerAccount = 0
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
index f5d0513..2c1e9f3 100644
--- a/src/shared/Log.cpp
+++ b/src/shared/Log.cpp
@@ -37,7 +37,7 @@ enum LogType
const int LogType_count = int(LogError) +1;

Log::Log() :
-    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
+    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), spamlog(NULL),
    dberLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false)
{
    Initialize();
@@ -228,6 +228,7 @@ void Log::Initialize()

    dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
    raLogfile = openLogFile("RaLogFile",NULL,"a");
+    spamlog = openLogFile("SpamlogFile", NULL, "a");

    // Main log file settings
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
@@ -725,6 +726,38 @@ void Log::outRALog(    const char * str, ... )
    fflush(stdout);
}

+void Log::outSpam( const char * msg, ... )
+{
+    if( !msg ) return;
+
+    if(m_colored)
+        SetColor(false,m_colors[LogError]);
+
+    if(m_includeTime)
+        outTime();
+
+    va_list ap;
+    va_start(ap, msg);
+    vfprintf( stderr, msg, ap );
+    va_end(ap);
+
+    if(m_colored)
+        ResetColor(false);
+
+    fprintf( stderr, "\\n" );
+    if(spamlog)
+    {
+        outTimestamp(spamlog);
+        fprintf(spamlog, "Reported spam: ");
+        va_start(ap, msg);
+        vfprintf(spamlog, msg, ap);
+        fprintf(spamlog, "\\n" );
+        va_end(ap);
+        fflush(spamlog);
+    }
+    fflush(stderr);
+}
+
void outstring_log(const char * str, ...)
{
    if( !str )
diff --git a/src/shared/Log.h b/src/shared/Log.h
index 391a93d..bc071e2 100644
--- a/src/shared/Log.h
+++ b/src/shared/Log.h
@@ -79,6 +79,11 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
        if (raLogfile != NULL)
            fclose(raLogfile);
        raLogfile = NULL;
+        
+        if (spamlog != NULL)
+            fclose(spamlog);
+        raLogfile = NULL;
+
    }
    public:
        void Initialize();
@@ -107,6 +112,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
                                                            // any log level
        void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
        void outRALog( const char * str, ... )       ATTR_PRINTF(2,3);
+        void outSpam( const char * msg, ... )       ATTR_PRINTF(2,3);
+
        void SetLogLevel(char * Level);
        void SetLogFileLevel(char * Level);
        void SetColor(bool stdout_stream, Color color);
@@ -123,6 +130,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
        FILE* openGmlogPerAccount(uint32 account);

        FILE* raLogfile;
+        FILE* spamlog;
        FILE* logfile;
        FILE* gmLogfile;
        FILE* charLogfile;

Link to comment
Share on other sites

Yeah it looks kinda messed up now. :(

Now should work

diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 54a2ecb..fb6b186 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1392,6 +1392,10 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
    std::string description = "";
    recv_data >> spam_type;                                 // unk 0x01 const, may be spam type (mail/chat)
    recv_data >> spammer_guid;                              // player guid
+
+    std::string spammer_name;
+    objmgr.GetPlayerNameByGUID(spammer_guid, spammer_name);
+
    switch(spam_type)
    {
        case 0:
@@ -1399,6 +1403,8 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
            recv_data >> unk1;                              // const 0
            recv_data >> unk2;                              // probably mail id
            recv_data >> unk3;                              // const 0
+            sLog.outSpam("Mail: ID %u (Owner %u), Reporter : %s", unk2 , GUID_LOPART(spammer_guid), GetPlayer()->GetName());
+
            break;
        case 1:
            CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4+4+1);
@@ -1407,6 +1413,7 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
            recv_data >> unk3;                              // probably channel id
            recv_data >> unk4;                              // unk random value
            recv_data >> description;                       // spam description string (messagetype, channel name, player name, message)
+            sLog.outSpam("Chat: Player %s (%u), Reporter: %s, Data: %s ", spammer_name.c_str(), GUID_LOPART(spammer_guid), GetPlayer()->GetName(), description.c_str());           
            break;
    }

@@ -1418,8 +1425,8 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
    data << uint8(0);
    SendPacket(&data);

-    sLog.outDebug("REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str());
-}
+    
+ }

void WorldSession::HandleRealmStateRequestOpcode( WorldPacket & recv_data )
{
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index c63ef9d..3b99b16 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -251,6 +251,10 @@ AddonChannel = 1
#        Default: 0 - don't include dumping chars to log
#                 1 - include dumping chars to log
#
+#    SpamLogFile
+#        Spam Log file for logging player reported spams
+#        Default: "" (disabled) 
+#
#    GmLogFile
#        GM Log file of gm commands
#        Default: "" (Disable)
@@ -296,6 +300,7 @@ DBErrorLogFile = "DBErrors.log"
CharLogFile = "Char.log"
CharLogTimestamp = 0
CharLogDump = 0
+SpamlogFile = "spam.log"
GmLogFile = ""
GmLogTimestamp = 0
GmLogPerAccount = 0
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
index f5d0513..465a43d 100644
--- a/src/shared/Log.cpp
+++ b/src/shared/Log.cpp
@@ -37,7 +37,7 @@ enum LogType
const int LogType_count = int(LogError) +1;

Log::Log() :
-    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
+    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), spamlog(NULL),
    dberLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false)
{
    Initialize();
@@ -228,6 +228,7 @@ void Log::Initialize()

    dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
    raLogfile = openLogFile("RaLogFile",NULL,"a");
+    spamlog = openLogFile("SpamlogFile", NULL, "a");

    // Main log file settings
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
@@ -725,6 +726,38 @@ void Log::outRALog(    const char * str, ... )
    fflush(stdout);
}

+void Log::outSpam( const char * msg, ... )
+{
+    if( !msg ) return;
+
+    if(m_colored)
+        SetColor(false,m_colors[LogError]);
+
+    if(m_includeTime)
+        outTime();
+
+    va_list ap;
+    va_start(ap, msg);
+    vfprintf( stderr, msg, ap );
+    va_end(ap);
+
+    if(m_colored)
+        ResetColor(false);
+
+    fprintf( stderr, "\\n" );
+    if(spamlog)
+    {
+        outTimestamp(spamlog);
+        fprintf(spamlog, "Reported spam: ");
+        va_start(ap, msg);
+        vfprintf(spamlog, msg, ap);
+        fprintf(spamlog, "\\n" );
+        va_end(ap);
+        fflush(spamlog);
+    }
+    fflush(stderr);
+}
+
void outstring_log(const char * str, ...)
{
    if( !str )
diff --git a/src/shared/Log.h b/src/shared/Log.h
index 391a93d..68f4fc4 100644
--- a/src/shared/Log.h
+++ b/src/shared/Log.h
@@ -79,6 +79,11 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
        if (raLogfile != NULL)
            fclose(raLogfile);
        raLogfile = NULL;
+        
+        if (spamlog != NULL)
+            fclose(spamlog);
+        raLogfile = NULL;
+
    }
    public:
        void Initialize();
@@ -107,6 +112,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
                                                            // any log level
        void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
        void outRALog( const char * str, ... )       ATTR_PRINTF(2,3);
+        void outSpam( const char * msg, ... )       ATTR_PRINTF(2,3);
+
        void SetLogLevel(char * Level);
        void SetLogFileLevel(char * Level);
        void SetColor(bool stdout_stream, Color color);
@@ -123,6 +130,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
        FILE* openGmlogPerAccount(uint32 account);

        FILE* raLogfile;
+        FILE* spamlog;
        FILE* logfile;
        FILE* gmLogfile;
        FILE* charLogfile;

Link to comment
Share on other sites

These should be logged in db that makes it much easier to see if someone is reported multiple times.

I see what you mean, but logging is normally put into files, eg: server logging, GM logging, RA logging, DB error logging, etc.

That's why I asked for it to be done that way. I'll be testing the new one out soon.

But I mean I completely agree database would be better and easier to read. When we submit this to the devs we'll see their opinion on what is best.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use