To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

KillNotice/code: Difference between revisions

From ZNC
Jump to navigation Jump to search
Created page with "<pre>/* * Copyright (C) Efreak * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as..."
 
>Efreak
m Added github link.
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
This source is also available on [https://github.com/Efreak/ZNC-Modules/blob/master/killnotice.cpp GitHub].
<pre>/*
<pre>/*
  * Copyright (C) Efreak
  * Copyright (C) 2010 Efreak.
  *
  *
  * This program is free software; you can redistribute it and/or modify it
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
  * under the terms of the GNU General Public License version 2 as published
  * by the Free Software Foundation.
  * by the Free Software Foundation.  
*
* If any other changes are made, update the version number to the latest ZNC
* version to reflect it, please. This makes things easier to know what
* version it works with; If you want to contribute code, let me know via IRC
* and I'll ad you as a contributor on GitHub.
* -Efreak
  */
  */


Line 35: Line 42:


};
};
GLOBALMODULEDEFS(CKillNoticeMod, "Sends admins a notice when a user gets killed")</pre>
GLOBALMODULEDEFS(CKillNoticeMod, "Sends admins a notice when a user gets killed. Version 0.01")</pre>
[[Category:Modules/Code]]
[[Category:Modules/Code]]

Latest revision as of 18:51, 31 August 2012

This source is also available on GitHub.

/*
 * Copyright (C) 2010 Efreak.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation. 
 * 
 * If any other changes are made, update the version number to the latest ZNC
 * version to reflect it, please. This makes things easier to know what
 * version it works with; If you want to contribute code, let me know via IRC
 * and I'll ad you as a contributor on GitHub.
 * -Efreak
 */

#include "znc.h"
#include "User.h"
#include "Modules.h"

class CKillNoticeMod : public CGlobalModule {
public:
        GLOBALMODCONSTRUCTOR(CKillNoticeMod) {}

        EModRet OnRaw(CString& sLine) {
                CString sCmd = sLine.Token(0).AsUpper();

                if(sCmd == "ERROR") {
                        CString sRest = sLine.Token(1, true).AsLower();

                        if(sRest.find("lined") != CString::npos || sRest.find("kill") != CString::npos) {
                                if(m_pUser) {
					SendAdmins(m_pUser->GetUserName() + " (killed: " + sLine + ")");
                                }
                        }
                }
                return CONTINUE;
        }
private:
        void SendAdmins(const CString &msg) {
                CZNC::Get().Broadcast(msg, true, NULL, GetClient());
        }

};
GLOBALMODULEDEFS(CKillNoticeMod, "Sends admins a notice when a user gets killed. Version 0.01")