Accueil > > > [XCHAT] ANTI KICK / AWAY C++
[XCHAT] ANTI KICK / AWAY C++
Information sur la source
Description
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 de la même categorie
Commentaires et avis
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 >= $
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\
|
Derniers Blogs
[RIA SERVICES] INCLUDE ET DOMAINDATASOURCE[RIA SERVICES] INCLUDE ET DOMAINDATASOURCE par Audrey
Dans un de mes articles précédents , j'avais parlé des DomainDataSource avec RIA Services dans le cas d'une interface Maître - Détail. Dans le même principe, je vais parler d'une autre manière de mettre en forme ce cas d'interface avec RIA Services. Et po...
Cliquez pour lire la suite de l'article par Audrey ZUNE : VERSION ZUNE SOFTWARE V 4.2 ET LA SOCIALISATIONZUNE : VERSION ZUNE SOFTWARE V 4.2 ET LA SOCIALISATION par ROMELARD Fabrice
Une des nouveautés de la version V 3.0 était l'apparition de l'onglet Social qui ne fonctionnait que si le MarketPlace était activé sur son poste. Cela limitait donc son intérêt, car hors du cadre commercial USA-CANADA, peu de monde trouva...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice PRATIQUE DE SILVERLIGHT PAR ERIC AMBROSIPRATIQUE DE SILVERLIGHT PAR ERIC AMBROSI par MPOWARE
Je viens de finir la lecture du dernier livre d'
Eric Ambrosi
éditions PEARSON
Son livre donne une approche pratique de Silverlight qui sera aussi bien comprise par le développeur que par le designeur.
Tous les aspects du développement RIA sont abor...
Cliquez pour lire la suite de l'article par MPOWARE APPRENDRE à DéVELOPPER POUR LES MOBILES AVEC LA NOUVELLE GéNéRATION .NETAPPRENDRE à DéVELOPPER POUR LES MOBILES AVEC LA NOUVELLE GéNéRATION .NET par odewit
2 déclinaisons de Silverlight et 2 déclinaisons de Mono permettent dorénavant (ou permettront prochainement) de développer des applications .NET mobiles pour les principales plates-formes du marché :
Silverlight pour Symbian, basé sur Silverlight 2...
Cliquez pour lire la suite de l'article par odewit ZUNE : NOUVELLE VERSION DU ZUNE SOFTWARE - V 4.2ZUNE : NOUVELLE VERSION DU ZUNE SOFTWARE - V 4.2 par ROMELARD Fabrice
Avec la dernière génération du lecteur MP3 de Microsoft, le ZUNE HD, Microsoft a publié une nouvelle version du logiciel pour PC. Ainsi, je me suis décidé à installer celle-ci sur mon Tablet PC ACER, comme toujours le logiciel est donc tél...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|