begin process at 2010 02 09 20:53:07
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

AddOns

 > [XCHAT] ANTI KICK / AWAY C++

[XCHAT] ANTI KICK / AWAY C++


 Information sur la source

Note :
Aucune note
Catégorie :AddOns Classé sous :Xchat, Anti Kick, Away, Interface graphique, Cpp Niveau :Débutant Date de création :12/11/2009 Date de mise à jour :18/11/2009 20:02:21 Vu :979

Auteur : GeroXXXX

Ecrire un message privé
Site perso
Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Bah voila, étant donné qu' apparemment programmer un script avec interface graphique en perl pour Xchat relève de l' exploit avec la nouvelle version (5.10), - et au passage qu' apparemment perl n' est pas un language aimé de tous - je vais au fur et a mesure reprendre mon script perso ( http://www.ircfr.com/codes/XCHAT-PERL-ANTI-KICK-AW AY_50779.aspx ) et le refaire en c++ sous forme de plugin, afin au final d' y intégrer une interface graphique...
Étant un peu rouillé en c++, je commence doucement en implantent pour l' instant que les fonctions antikick et away ( qui fonctionnent strictement de la même manière que celles en perl ).
Commentaires désagréables non utiles s' abstenir, commentaires désagréables utiles bienvenus :p

Source

  • #include <string>
  • #include <windows.h>
  • #include "xchat-plugin.h"
  • #define PNAME "Perso"
  • #define PDESC "Script perso"
  • #define PVERSION "0.4"
  • #define DLL_EXPORT extern "C" __declspec( dllexport )
  • using namespace std;
  • int iaway=0;
  • static xchat_plugin *ph;
  • string cmd;
  • xchat_hook *hmsg, *hnot;
  • HINSTANCE hThisInstance;
  • HWND hWnd, listBox;
  • DWORD dwGenericThread;
  • HANDLE hThread;
  • // Utilisation de string::find insensiblement a la case
  • bool caseFind(string s1, string s2){
  • for(unsigned int i=0;i<s1.size();i++){
  • s1[i] = tolower(s1.at(i));
  • }
  • for(unsigned int i=0;i<s2.size();i++){
  • s2[i] = tolower(s2.at(i));
  • }
  • if(s1.find(s2)!=string::npos)return true;
  • return false;
  • }
  • // Routine executée lors du hook sur les PRIVMSG du serveur
  • static int msgrecu(char *word[], char *word_eol[], void *userdata){
  • if((xchat_get_info(ph, "away"))==NULL)return XCHAT_EAT_NONE;
  • if(caseFind(word_eol[4], "gero")){
  • int i=0;
  • cmd = word[1];
  • // Recupere le pseudo dans la string pseudo!xxxx@host.serveur
  • while(cmd.at(i)!='!')i++;
  • cmd = cmd.substr(1, i-1) + ":" + word[3] + word_eol[4];
  • SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)cmd.c_str());
  • }
  • return XCHAT_EAT_NONE;
  • }
  • // Routine executée lors du hook sur les NOTICES du serveur
  • static int notrecu(char *word[], char *word_eol[], void *userdata){
  • if((xchat_get_info(ph, "away"))==NULL)return XCHAT_EAT_NONE;
  • int i=0;
  • // Recupere le pseudo dans la string pseudo!xxxx@host.serveur
  • cmd = word[1];
  • while(cmd.at(i)!='!')i++;
  • cmd = cmd.substr(1, i-1) + word_eol[4];
  • cmd = "NOTICE:" + cmd;
  • SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)cmd.c_str());
  • return XCHAT_EAT_NONE;
  • }
  • // Si kické, retour sur le serveur et envoie d' une notice au kickeur ...
  • static int youkicked(char *word[], void *userdata){
  • string s = string("Tu as été kické de ") + word[2] + " par : " + word[3] + " : " + word[4] + "\r\n";
  • xchat_print(ph, s.c_str());
  • xchat_print(ph, "Reconnection en cours ...\r\n");
  • cmd = string("NOTICE ") + word[3] + " Plus jamais tu me kick toi :@ !!!\r\n";
  • xchat_command(ph, cmd.c_str());
  • cmd = string("JOIN ") + word[2];
  • xchat_command(ph, cmd.c_str());
  • return XCHAT_EAT_XCHAT;
  • }
  • LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
  • switch (message){
  • case WM_DESTROY:
  • PostQuitMessage (0);
  • break;
  • case WM_CREATE:
  • //MessageBox(0, "fenetre cree", "fenetre", 0);
  • break;
  • default:
  • return DefWindowProc (hwnd, message, wParam, lParam);
  • }
  • return 0;
  • }
  • DWORD WINAPI interface_graphique(LPVOID iValue){
  • MSG messages;
  • WNDCLASSEX wincl;
  • wincl.hInstance = hThisInstance;
  • wincl.lpszClassName = "XchatPlugin";
  • wincl.lpfnWndProc = WindowProcedure;
  • wincl.style = CS_DBLCLKS;
  • wincl.cbSize = sizeof (WNDCLASSEX);
  • wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  • wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  • wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  • wincl.lpszMenuName = NULL;
  • wincl.cbClsExtra = 0;
  • wincl.cbWndExtra = 0;
  • wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  • if (!RegisterClassEx (&wincl)){
  • MessageBox(0, "Erreur", "Impossible d' enregistrer la classe windows !", 0);
  • return 0;
  • }
  • hWnd = CreateWindowEx (0,"XchatPlugin","Messages Reçus",WS_OVERLAPPED ,CW_USEDEFAULT,CW_USEDEFAULT,
  • 527,355,HWND_DESKTOP,NULL,hThisInstance,NULL);
  • listBox = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", NULL, WS_VISIBLE|WS_CHILD|LBS_SORT|LBS_NOTIFY|\
  • WS_HSCROLL|WS_VSCROLL, 10, 10, 500, 320, hWnd, (HMENU)100, hThisInstance, NULL);
  • ShowWindow(hWnd, 0);
  • while (GetMessage (&messages, NULL, 0, 0)){
  • TranslateMessage(&messages);
  • DispatchMessage(&messages);
  • }
  • return 0;
  • }
  • // Passe en mode away et rajoute [away] a la fin de votre nom
  • // Ou annule le mode away et remets votre pseudo sans le [away] ...
  • static int away(char *word[], char *word_eol[], void *userdata){
  • string pseudo;
  • if((xchat_get_info(ph, "away"))==NULL){
  • pseudo = string(xchat_get_info(ph, "nick"));
  • cmd = "nick " + pseudo + "[away]";
  • xchat_command(ph, cmd.c_str());
  • // Active le hook sur les PRIVMSG et NOTICE du serveur
  • // Evite la multiplication des hooks si away sur plusieurs serveurs
  • if(iaway==0){
  • hmsg = xchat_hook_server(ph, "PRIVMSG", XCHAT_PRI_NORM, msgrecu, 0);
  • hnot = xchat_hook_server(ph, "NOTICE", XCHAT_PRI_NORM, notrecu, 0);
  • ShowWindow(hWnd, SW_SHOW);
  • UpdateWindow(hWnd);
  • }
  • iaway++;
  • }else{
  • pseudo = string(xchat_get_info(ph, "nick"));
  • pseudo = pseudo.substr(0, pseudo.size()-6);
  • cmd = "nick " + pseudo;
  • xchat_command(ph, cmd.c_str());
  • xchat_command(ph, "back");
  • iaway--;
  • // Si on est en ligne sur tous les serveurs alors on supprime les hooks et la fenetre msg_recu
  • if(iaway==0){
  • xchat_unhook(ph, hmsg);
  • xchat_unhook(ph, hnot);
  • ShowWindow(hWnd, SW_HIDE);
  • UpdateWindow(hWnd);
  • }
  • }
  • return XCHAT_EAT_NONE;
  • }
  • // Envoie des infos du plugin au progz
  • DLL_EXPORT void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved){
  • *name = PNAME;
  • *desc = PDESC;
  • *version = PVERSION;
  • }
  • // Initialisation du plugin
  • DLL_EXPORT int xchat_plugin_init(xchat_plugin *plugin_handle,
  • char **plugin_name,
  • char **plugin_desc,
  • char **plugin_version,
  • char *arg){
  • ph = plugin_handle;
  • *plugin_name = PNAME;
  • *plugin_desc = PDESC;
  • *plugin_version = PVERSION;
  • xchat_hook_print(ph, "You kicked", XCHAT_PRI_NORM, youkicked, 0);
  • xchat_hook_command(ph, "away", XCHAT_PRI_NORM, away, "", 0);
  • hThisInstance = GetModuleHandle(0);
  • hThread = CreateThread(NULL,0,interface_graphique,0,0,&dwGenericThread);
  • xchat_print(ph, "Script perso cpp chargé!\n");
  • return 1;
  • }
  • DLL_EXPORT int xchat_plugin_deinit(){
  • ShowWindow(hWnd, SW_HIDE);
  • TerminateThread(hThread, 0);
  • return 0;
  • }
#include <string>
#include <windows.h>
#include "xchat-plugin.h"


#define PNAME "Perso"
#define PDESC "Script perso"
#define PVERSION "0.4"
#define DLL_EXPORT extern "C" __declspec( dllexport )

using namespace std;
int iaway=0;
static xchat_plugin *ph;
string cmd;
xchat_hook *hmsg, *hnot;
HINSTANCE hThisInstance;
HWND hWnd, listBox;
DWORD dwGenericThread;
HANDLE hThread;

// Utilisation de string::find insensiblement a la case
bool caseFind(string s1, string s2){
    for(unsigned int i=0;i<s1.size();i++){
        s1[i] = tolower(s1.at(i));
    }
    for(unsigned int i=0;i<s2.size();i++){
        s2[i] = tolower(s2.at(i));
    }
    if(s1.find(s2)!=string::npos)return true;
    return false;
}

// Routine executée lors du hook sur les PRIVMSG du serveur
static int msgrecu(char *word[], char *word_eol[], void *userdata){
    if((xchat_get_info(ph, "away"))==NULL)return XCHAT_EAT_NONE;
    if(caseFind(word_eol[4], "gero")){
        int i=0;
        cmd = word[1];
        // Recupere le pseudo dans la string pseudo!xxxx@host.serveur
        while(cmd.at(i)!='!')i++;
        cmd = cmd.substr(1, i-1) + ":" + word[3] + word_eol[4];
        SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)cmd.c_str());
    }
    return XCHAT_EAT_NONE;
}
// Routine executée lors du hook sur les NOTICES du serveur
static int notrecu(char *word[], char *word_eol[], void *userdata){
    if((xchat_get_info(ph, "away"))==NULL)return XCHAT_EAT_NONE;
    int i=0;
    // Recupere le pseudo dans la string pseudo!xxxx@host.serveur
    cmd = word[1];
    while(cmd.at(i)!='!')i++;
    cmd = cmd.substr(1, i-1) + word_eol[4];
    cmd = "NOTICE:" + cmd;
    SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)cmd.c_str());
    return XCHAT_EAT_NONE;
}

// Si kické, retour sur le serveur et envoie d' une notice au kickeur ...
static int youkicked(char *word[], void *userdata){
    string s = string("Tu as été kické de ") + word[2] + " par : " + word[3] + " : " + word[4] + "\r\n";
    xchat_print(ph, s.c_str());
    xchat_print(ph, "Reconnection en cours ...\r\n");
    cmd = string("NOTICE ") + word[3] + " Plus jamais tu me kick toi :@ !!!\r\n";
    xchat_command(ph, cmd.c_str());
    cmd = string("JOIN ") + word[2];
    xchat_command(ph, cmd.c_str());
    return XCHAT_EAT_XCHAT;
}

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
    switch (message){
        case WM_DESTROY:
            PostQuitMessage (0);
        break;
        case WM_CREATE:
            //MessageBox(0, "fenetre cree", "fenetre", 0);
        break;
        default:
        return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}

DWORD WINAPI interface_graphique(LPVOID iValue){
    MSG messages;
    WNDCLASSEX wincl;
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = "XchatPlugin";
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;
    wincl.cbSize = sizeof (WNDCLASSEX);
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    if (!RegisterClassEx (&wincl)){
        MessageBox(0, "Erreur", "Impossible d' enregistrer la classe windows !", 0);
        return 0;
    }

    hWnd = CreateWindowEx (0,"XchatPlugin","Messages Reçus",WS_OVERLAPPED ,CW_USEDEFAULT,CW_USEDEFAULT,
    527,355,HWND_DESKTOP,NULL,hThisInstance,NULL);

    listBox = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", NULL, WS_VISIBLE|WS_CHILD|LBS_SORT|LBS_NOTIFY|\
            WS_HSCROLL|WS_VSCROLL, 10, 10, 500, 320, hWnd, (HMENU)100, hThisInstance, NULL);

    ShowWindow(hWnd, 0);
    while (GetMessage (&messages, NULL, 0, 0)){
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }
    return 0;
}

// Passe en mode away et rajoute [away] a la fin de votre nom
// Ou annule le mode away et remets votre pseudo sans le [away] ...
static int away(char *word[], char *word_eol[], void *userdata){
    string pseudo;
    if((xchat_get_info(ph, "away"))==NULL){
        pseudo = string(xchat_get_info(ph, "nick"));
        cmd = "nick " + pseudo + "[away]";
        xchat_command(ph, cmd.c_str());
        // Active le hook sur les PRIVMSG et NOTICE du serveur
        // Evite la multiplication des hooks si away sur plusieurs serveurs
        if(iaway==0){
            hmsg = xchat_hook_server(ph, "PRIVMSG", XCHAT_PRI_NORM, msgrecu, 0);
            hnot = xchat_hook_server(ph, "NOTICE", XCHAT_PRI_NORM, notrecu, 0);
            ShowWindow(hWnd, SW_SHOW);
            UpdateWindow(hWnd);
        }
        iaway++;

    }else{
        pseudo = string(xchat_get_info(ph, "nick"));
        pseudo = pseudo.substr(0, pseudo.size()-6);
        cmd = "nick " + pseudo;
        xchat_command(ph, cmd.c_str());
        xchat_command(ph, "back");
        iaway--;
        // Si on est en ligne sur tous les serveurs alors on supprime les hooks et la fenetre msg_recu
        if(iaway==0){
            xchat_unhook(ph, hmsg);
            xchat_unhook(ph, hnot);
            ShowWindow(hWnd, SW_HIDE);
            UpdateWindow(hWnd);
        }
    }
    return XCHAT_EAT_NONE;
}

// Envoie des infos du plugin au progz
DLL_EXPORT void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved){
   *name = PNAME;
   *desc = PDESC;
   *version = PVERSION;
}

// Initialisation du plugin
DLL_EXPORT int xchat_plugin_init(xchat_plugin *plugin_handle,
                      char **plugin_name,
                      char **plugin_desc,
                      char **plugin_version,
                      char *arg){

   ph = plugin_handle;

   *plugin_name = PNAME;
   *plugin_desc = PDESC;
   *plugin_version = PVERSION;

   xchat_hook_print(ph, "You kicked", XCHAT_PRI_NORM, youkicked, 0);
   xchat_hook_command(ph, "away", XCHAT_PRI_NORM, away, "", 0);

   hThisInstance = GetModuleHandle(0);
   hThread = CreateThread(NULL,0,interface_graphique,0,0,&dwGenericThread);

   xchat_print(ph, "Script perso cpp chargé!\n");

   return 1;
}

DLL_EXPORT int xchat_plugin_deinit(){
    ShowWindow(hWnd, SW_HIDE);
    TerminateThread(hThread, 0);
    return 0;
}



 Conclusion

Bah reste plus qu'a faire une belle interface conviviale à la place de la fenêtre et ça sera bon :)


 Historique

12 novembre 2009 23:59:35 :
- Partie /away avec enregistrement des messages envoyés a votre intention crée... Le programme analyse les phrase tapés par les utilisateurs pour savoir si une partie de votre pseudo y est. ( pour ma part "gero" ) puis enregistre ces messages dans l' onglet serveur afin que vous puissiez les lire ultérieurement. Pour le non graphique je n' ai aucune idée de par où commencer ... :-s
16 novembre 2009 01:01:15 :
Ajout d' une fenêtre gérée par un thread de la dll, avec une simple ListBox dans laquelle tous les messages perso sont affichés lorsque l'on passe en mode "away" à la place de les enregistrer sur l' onglet serveur ... Code utilisant les API Windows, sans MFC ( beurk )
16 novembre 2009 01:07:06 :
J' ai oublié de modifier la source xD Bah ... il est 1h du mat et je viens de finir le boulot aussi ... :p
18 novembre 2009 20:00:22 :
Je me suis rendu compte qu' une fois away sur un serveur, lorsque je me connectais sur un autre serveur en même temps Xchat plantais ... C'était due au fait que j'utilisais iaway de type bool pour savoir si je mettais mis away, sans penser qu' Xchat était multi-serveur ... Problème résolu en utilisant xchat_get_info(ph, "away") qui me renvoie NULL si je ne suis pas away sur le serveur en cours ... Voila ;)
18 novembre 2009 20:02:21 :
Arf ... Un jour j' arriverai à faire une MAJ sur codes-sources du premier coup, promis ... xD

 Sources du même auteur

[XCHAT] [PERL] ANTI-KICK + AWAY

 Sources de la même categorie

BLACKLIST PSEUDOS/MASKS par usurpateur
JEU DU CODE par alanpersonproject
SERVEUR FTP par hisoka2501
BANNIR LES AGES, LES HOMMES, LES FEMMES ET PSEUDO AVEC CHIFF... par cougar_du_havre
MODE ANTI-ATTACK par cougar_du_havre

 Sources en rapport avec celle ci

[XCHAT] [PERL] ANTI-KICK + AWAY par GeroXXXX
Source avec une capture AWAY BY MSK par devorZ
[XCHAT] COMMANDES CHR/ASC par 0x586e
[XCHAT] REPERTOIRE DE CONFIG par 0x586e
XCHAT - SCRIPT PERL AWAY par lumesh

Commentaires et avis

Commentaire de uaip le 14/11/2009 01:37:22

Salut,
Ben... c'est sympa comme truc. Rien à dire sur le code. Quoi que je ne savais pas qu'on pouvait utiliser le namespace std avant d'inclure <string>.
Pour l'interface graphique, je te souhaite du courage... XChat est multi-plateforme, je crois :p (remarque, GTK+ devrait faire l'affaire).

(commentaire non utile, mais pas désagréable, ma foi)

Bonne continuation.

Commentaire de GeroXXXX le 14/11/2009 01:53:22

Salut !
:) Effectivement, commentaire non-désagréable ...
Oui, Xchat est multi-plateforme ... :-s
Je t' avouerai que je n' avais pas pensé du tout à la portabilité ...
( puisque j' utilise //extern "C" __declspec( dllexport )// et surtout que je me suis habitué à perl :) ) mais je modifiais cela demain avec un petit typedef ...
Étant donné que je suis sous vista sur ce pc je pensais faire ça en standard avec windows.h,
mais il est vrai que gtk+ devrais faire l' affaire et me simplifiera surement la tache...
( Quoiqu'il va falloir que j' apprenne à m' en servir xD )
Merci quand même pour ce petit commentaire, enfin qqun qui visite ma source et mets un
comm dessus :)

Au plaisir ;)

Commentaire de uaip le 14/11/2009 03:10:08

Bah, si tu projettes de coder ce prog uniquement pour Windows, les API (windows.h) sont peut-être préférables. Ca t'éviterait d'installer une lib graphique.
Enfin bon, c'est à toi de voir.

Bonne nuit.

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Il était away depuis 19min54s... [ par NicX ] Bonjour,comme l'indique le titre,je voudrais calculer la durée de mon absence..je sais plus trop ce qu'il faut utiliser,se serait sympa de me filer un pour chrono sur les away [ par FyLiPuSsE ] bonjour je vrourai savoir comment fais t on un chrono sur les away :-) Away sur plusieurs servers en meme tps [ par Jipem ] Bonjour,J'ai un probleme existentiel que je n'arrive pas a régler :(Dans mon systeme d'away je voudrais laisser le choix entre : "Se mettre away sur c Auto-away au bout de X minutes... [ par Millardo ] J'aimerais faire un auto away au bout de x minutes.Avec un auto deop/dehalfop.Alors j'avais pensé à :on *:connect: {timerIDLE 0 30 {if ( $idle &gt;= $ j'ai un probleme avec un systeme d'away [ par lynk ] http://www.ircfr.com/article.aspx?ID=519je n'arrive pas a le lancer, pourtant tout a l'ai de fonctionner mais je n'arrive pas a savoir ce que je dois Commande en Remote multi server [ par Gouje ] SAlutJ'aimerai savoir si on peut associer une remote a un server ...je m'explik ....Je voudrai par exemple ke lorske je fais /away ca fasse /nick %pse systeme away help plz [ par ketamin ] voila j ai toruver un systee away simple mais le message s affiche en /me en violer moi ej voudrais ki soit en/say come si j ecrivais un mess normale away [ par yoyo1990 ] pourkoi quand je vais en away sa marque You are no longer marked as being awaysvp réponder moi vite a cradl3@msn.com pcq je veux faire mon script le p systeme away [ par ketamin ] voila j aimerais avoir un menue deroulent ds mon systeme away pour choisir un pseudo parmit une liste je vous met le script deja fait au dessoups je d away system. [ par tofu ] un petit screenshot du system d'away que je suis en trin de faire.avis, commentaires, idées à rajouter, insultes, menaces de mort?----tofu\


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,811 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales