I have one attached to the first post in the thread.
I also just put the source to the x-chat plugin in there.
Right now, it just manipulates the text to be easier to read. I want to get userlist integration too, but I'm not sure I can manipulate those in X-Chat and mIRC.
You hadn't attached it when I posted, but I see now, thanks.
No xchat_plugin_init symbol; is this really an xchat plugin?
The issue I have with stripping a bunch of extra nicks is that every time the bots are down, someone inevitably impersonates the bot and screws with stuff.Ah ok I see. Well are you plannign to at least strip the defualt ones?
Nice stuff! :D Just a friendly poke that XChat can support Python, Perl, and TCL (the former being the most popular), so you can have a bit more portability. ;)
(I can't compile that plugin until I dig out some archives for the needed headers - surprisingly, XChat on Linux doesn't come with them, but they are installed when compiling XChat2 source.)
ON ^*:TEXT:*:#:if ( $nick == OmnomIRC ) { echo $chan $iif($regsubex($readini($mircini,options,n4),/(^(.+?,){11}(.+?).*)/,\3) == 1,$timestamp,) $iif( $mid($1-,2,1) == $chr(35) , (4 $+ $chr(35) $+ ) $+ $mid($1-,4), (12O) $+ $mid($1-,7) ) | haltdef }
#include <string>
with#include <cstring>
using namespace std::tr1;
You don't need this line. Comment or remove it.gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC -std=c++0x xchat_omnomirc.cpp -o xchat_omnomirc.so
Ah ok thanks for the update and info :)Nice stuff! :D Just a friendly poke that XChat can support Python, Perl, and TCL (the former being the most popular), so you can have a bit more portability. ;)
(I can't compile that plugin until I dig out some archives for the needed headers - surprisingly, XChat on Linux doesn't come with them, but they are installed when compiling XChat2 source.)
Except those extensions require hundreds of megs of extra libs on Windows.
Also, here's an updated mIRC script, it supports timestamps.Code: [Select]ON ^*:TEXT:*:#:if ( $nick == OmnomIRC ) { echo $chan $iif($regsubex($readini($mircini,options,n4),/(^(.+?,){11}(.+?).*)/,\3) == 1,$timestamp,) $iif( $mid($1-,2,1) == $chr(35) , (4 $+ $chr(35) $+ ) $+ $mid($1-,4), (12O) $+ $mid($1-,7) ) | haltdef }
Also, OmnomIRC doesn't have an alt nick anymore, since I switched to the PHP bot. It'll just keep retrying with OmnomIRC until the server lets it in.
/load "/path/to/file"
Or, on windows/load "c:\path\to\file"
#include <stdio.h>
#include <tr1/type_traits>
...so things compile! :)#include "xchat-plugin.h"
#include <string.h>
#include <string>
#include <cstdlib>
#include <regex>
#include <iostream>
#include <tr1/type_traits>
#define PNAME "OmnomIRC Integration"
#define PDESC "Integrates OmnomIRC into X-Chat"
#define PVERSION "0.1"
static xchat_plugin *ph; /* plugin handle */
static int enable = 1;
static char omnomIRC_Name[] = "OmnomIRC";
using namespace std::tr1;
using namespace std;
//#define debug
static void dbgPrint(const char *message)
{
#ifdef debug
xchat_print(ph,message);
#endif
}
static void dbgPrint(string message)
{
#ifdef debug
xchat_print(ph,message.c_str());
#endif
}
static string getMessageType(string message)
{
if (regex_search(message.begin(),message.end(),regex("^.{0,3}\\((.)\\).{0,1}<(.+?)> (.*)")))
return "message";
if (regex_search(message.begin(),message.end(),regex("^.{0,4}\\((.)\\)([^:space:]{0,4})\\* ?(.*)")))
return "action";
return "";
}
static char* getNameColor(const char *name)
{
char *rcolors[] = {"19", "20", "22", "24", "25", "26", "27", "28", "29"};
int sum = 0, i = 0;
while (name[i] != '\x00')
sum += name[i++];
sum %= 9;
return rcolors[sum];
}
static int on_text_cb(char *word[], void *userdata)
{
if (strcmp(word[0],omnomIRC_Name))
{
string messageType = getMessageType(word[2]).c_str();
string type = word[0];
cmatch parts;
if (strcmp(messageType.c_str(),"message") == 0)
{
regex rx("^.{0,3}\\((.)\\).{0,1}<(.+?)> (.*)");
regex_search(word[2],parts,rx);
bool omnomirc = parts[1].str().c_str()[0] == 'O';
string name;
if (omnomirc)
{
name.append("\x03""(\x03""12O\x03"")\x03");
name.append(getNameColor(parts[2].str().c_str()));
}
else
{
name.append("\x03""(\x03""4#\x03"")\x03");
name.append(getNameColor(parts[2].str().c_str()));
}
name.append(parts[2]);
string msg;;
msg.append(parts[3]);
parts[2].str();
if (xchat_nickcmp(ph,xchat_get_info(ph,"nick"),parts[2].str().c_str()) == 0)
xchat_emit_print(ph, "Channel Message",name.c_str(), msg.c_str(), "@", NULL); //Don't highlight on local messages
else
xchat_emit_print(ph, type.c_str(), name.c_str(), msg.c_str(), "@", NULL);
return XCHAT_EAT_ALL;
}
else if (strcmp(messageType.c_str(),"action") == 0)
{
regex rx("^.{0,3}\\((.)\\)([^:space:]{0,4})\\* ?(.*)");
regex_search(word[2],parts,rx);
bool omnomirc = parts[1].str().c_str()[0] == 'O';
string name = "\x03""\x03";
if (omnomirc)
name.append("12O\x03""18 *");
else
name.append("04#\x03""18 *");
string message(parts[2]);
message.append(parts[3]);
xchat_emit_print(ph, type.c_str(), name.c_str(), message.c_str(), "@", NULL);
return XCHAT_EAT_ALL;
}
}
return XCHAT_EAT_NONE;
}
void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved)
{
*name = PNAME;
*desc = PDESC;
*version = PVERSION;
}
int xchat_plugin_init(xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
{
/* we need to save this for use with any xchat_* functions */
ph = plugin_handle;
/* tell xchat our info */
*plugin_name = PNAME;
*plugin_desc = PDESC;
*plugin_version = PVERSION;
xchat_hook_print(ph, "Channel Message", XCHAT_PRI_NORM, on_text_cb, NULL);
xchat_hook_print(ph, "Channel Msg Hilight", XCHAT_PRI_NORM, on_text_cb, NULL);
xchat_print(ph, "OmnomIRC Integration loaded successfully!\n");
return 1;
}
#include "xchat-plugin.h"
#include <cstring>
#include <cstdlib>
#include <regex>
#include <iostream>
#define PNAME "OmnomIRC Integration"
#define PDESC "Integrates OmnomIRC into X-Chat"
#define PVERSION "0.1"
static xchat_plugin *ph; /* plugin handle */
static char omnomIRC_Name[] = "OmnomIRC";
using namespace std;
//#define debug
#ifdef debug
static void dbgPrint(const char *message)
{
xchat_print(ph,message);
}
static void dbgPrint(string message)
{
xchat_print(ph,message.c_str());
}
#endif
static string getMessageType(string message)
{
if (regex_search(message.begin(),message.end(),regex("^.{0,3}\\((.)\\).{0,1}<(.+?)> (.*)")))
return "message";
if (regex_search(message.begin(),message.end(),regex("^.{0,4}\\((.)\\)([^:space:]{0,4})\\* ?(.*)")))
return "action";
return "";
}
static char* getNameColor(const char *name)
{
char *rcolors[] = {"19", "20", "22", "24", "25", "26", "27", "28", "29"};
int sum = 0, i = 0;
while (name[i] != '\x00')
sum += name[i++];
sum %= 9;
return rcolors[sum];
}
static int on_text_cb(char *word[], void *userdata)
{
if (strcmp(word[0],omnomIRC_Name))
{
string messageType = getMessageType(word[2]).c_str();
string type = word[0];
cmatch parts;
if (strcmp(messageType.c_str(),"message") == 0)
{
regex rx("^.{0,3}\\((.)\\).{0,1}<(.+?)> (.*)");
regex_search(word[2],parts,rx);
bool omnomirc = parts[1].str().c_str()[0] == 'O';
string name;
if (omnomirc)
{
name.append("\x03""(\x03""12O\x03"")\x03");
name.append(getNameColor(parts[2].str().c_str()));
}
else
{
name.append("\x03""(\x03""4#\x03"")\x03");
name.append(getNameColor(parts[2].str().c_str()));
}
name.append(parts[2]);
string msg;;
msg.append(parts[3]);
parts[2].str();
if (xchat_nickcmp(ph,xchat_get_info(ph,"nick"),parts[2].str().c_str()) == 0)
xchat_emit_print(ph, "Channel Message",name.c_str(), msg.c_str(), "@", NULL); //Don't highlight on local messages
else
xchat_emit_print(ph, type.c_str(), name.c_str(), msg.c_str(), "@", NULL);
return XCHAT_EAT_ALL;
}
else if (strcmp(messageType.c_str(),"action") == 0)
{
regex rx("^.{0,3}\\((.)\\)([^:space:]{0,4})\\* ?(.*)");
regex_search(word[2],parts,rx);
bool omnomirc = parts[1].str().c_str()[0] == 'O';
string name = "\x03""\x03";
if (omnomirc)
name.append("12O\x03""18 *");
else
name.append("04#\x03""18 *");
string message(parts[2]);
message.append(parts[3]);
xchat_emit_print(ph, type.c_str(), name.c_str(), message.c_str(), "@", NULL);
return XCHAT_EAT_ALL;
}
}
return XCHAT_EAT_NONE;
}
extern "C" void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved)
{
*name = PNAME;
*desc = PDESC;
*version = PVERSION;
}
extern "C" int xchat_plugin_init(xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
{
/* we need to save this for use with any xchat_* functions */
ph = plugin_handle;
/* tell xchat our info */
*plugin_name = PNAME;
*plugin_desc = PDESC;
*plugin_version = PVERSION;
xchat_hook_print(ph, "Channel Message", XCHAT_PRI_NORM, on_text_cb, NULL);
xchat_hook_print(ph, "Channel Msg Hilight", XCHAT_PRI_NORM, on_text_cb, NULL);
xchat_print(ph, "OmnomIRC Integration loaded successfully!\n");
return 1;
}
Wow the X-Chat script is so much larger than the mIRC one. Is it because it's lower level or something? O.OYup, pure C++ at it's best. ;) I think I could port this to Python, not sure.
/home/jim/xchat_omnomirc.so: undefined symbol: _ZSt12regex_searchIPKcSaISt9sub_matchIS1_EEcSt12regex_traitsIcEEbT_S7_RSt13match_resultsIS7_T0_ERKSt11basic_regexIT1_T2_ESt6bitsetILj11EE
AutoLoad failed for: /home/julien/.xchat2/xchat_omnomirc.so
Le symbole xchat_plugin_init n'existe pas ; est-ce vraiment un greffon xchat ?
ON ^*:TEXT:*:#:{
var %timestamp $chr(20)
if ($regsubex($readini($mircini,options,n4),/(^(.+?,){11}(.+?).*)/,\3) == 1) { var %timestamp $timestamp }
if ( $nick == OmnomIRC ) { echo $chan %timestamp $iif( $mid($1-,2,1) == $chr(35) , (4 $+ $chr(35) $+ ) $+ $mid($1-,4), (12O) $+ $mid($1-,7) ) | haltdef }
if ( $nick == Saxjax ) { echo $chan %timestamp $regsubex( $1- ,\((.)\).\[(.+?)\] (.*),( $+ 5\1 $+ $+ ) <\2> \3) | haltdef }
}
julien@amy:~$ xchat
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Abandon
Looks awesome & useful! I love when things get simplified and integrated :D
I'm not using it myself though because I like to know who's actually online :-
Here is my version of the x-chat plugin. I thought the original was overly complex for the work to be done, so I rewrote everything in C and I personally think it is more readable. There was a small bug with nicks which I believe is fixed but I didn't test the fix so post here with any problems and hopefully someone(or I) will try and fix them. I will try and help with problems, but I've been busy looking for work etc so I might not be able to get things working immediately.Well I can't get it to work, it has that symbol thing that other people have had issues with.
Sorunome: Mind adding this info to the IRC page?Oh, right, forgot to do that :P