Omnimaga

Omnimaga => Discontinued => Our Projects => OmnomIRC Development => Topic started by: Netham45 on June 27, 2011, 07:03:03 am

Title: IRC Client Integration
Post by: Netham45 on June 27, 2011, 07:03:03 am
Hey, this is Sorunome here. Below you can find Nethams original post.

This are bindings for OmnomIRC to integrate into an IRC client, like, let's say, HexChat.
Ok, HexChat is the only one I've written it for, so far.
The binding is available at the repository, currently only the dev branch, so go over here: https://github.com/Sorunome/OmnomIRC2/blob/dev/omnombindings_hexchat.py




Netham45's stuff may still work, but maybe not, it is untested and heavily outdated as I changed the IRC bot a lot since. You can still check it out, though

Old code/bindings, by Netham45:
Spoiler For old:

I've written some tools to allow OmnomIRC to integrate into your IRC clients.

Here's the mIRC code, just put this into the remote.ini section of your scripts:

Spoiler For OmnomIRC only code:
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 }

Spoiler For OmnomIRC & Saxjax code:
Code: [Select]
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 }
}

And there is an XChat plugin attached. To use this, put it in %appdata%\X-Chat 2\ and restart XChat.
The file included only works on Windows X-Chat 2.

Here is the source code if someone wishes to compile it for Linux. It's a bit rushed, and not the neatest.
Code: [Select]
#include "xchat-plugin.h"
#include <string>
#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 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;
}

Edit: Updated mIRC script. >:D

Title: Re: IRC Client Integration
Post by: Munchor on June 27, 2011, 07:05:43 am
And what does this exactly do? Can you end a screenshot of how XChat/mIRC look like when this is installed?
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 07:06:30 am
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.
Title: Re: IRC Client Integration
Post by: Munchor on June 27, 2011, 07:08:00 am
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.
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 07:11:22 am
You hadn't attached it when I posted, but I see now, thanks.

Psh, I had posted it a good 5 seconds before you posted your message.

Also, I just realized that the X-Chat one doesn't care what your colored nick preferences are, it'll color 'em anyways. I'm not sure if I can get at the config to check it, X-Chat's API is lacking.
Title: Re: IRC Client Integration
Post by: Eeems on June 27, 2011, 01:16:50 pm
Chatzilla next? :)

looks great :)
Title: Re: IRC Client Integration
Post by: XVicarious on June 27, 2011, 01:49:23 pm
I get this error when I try to use the plugin:
Code: [Select]
No xchat_plugin_init symbol; is this really an xchat plugin?
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 01:50:07 pm
blarg. Lemme upload a fixed one, I didn't set the export defines for the release build.

EDIT: Uploaded to first post. I tested this one, too!
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 03:58:27 pm
Looks nice :D

EDIT: Hmm two suggestions:

-Display timestamps
-Strip SpyBot45, SpyBot46 and Omnimaga (alt nick for OmnomIRC) nicknames too

Also any idea if SpyBot nickname removal will ever be available again in the actual omnomIRC?
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 04:02:47 pm
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.
Title: Re: IRC Client Integration
Post by: Juju on June 27, 2011, 04:10:55 pm
Oh cool I was thinking of this too, can't wait to try it :D

Also I prefer if you leave the bots nicks there.

EDIT: I was able to successfully compile it on Linux by changing 2 lines :D
Title: Re: IRC Client Integration
Post by: alberthrocks on June 27, 2011, 04:22:34 pm
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.)
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 04:31:41 pm
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?
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 04:35:07 pm
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.
Title: Re: IRC Client Integration
Post by: Juju on June 27, 2011, 04:35:45 pm
In fact you need this file (http://xchat.org/docs/xchat-plugin.h) in the same directory as xchat_omnomirc.cpp, which contains Netham45's source code plus some modifications by me:

Line 2: Change
Code: [Select]
#include <string>with
Code: [Select]
#include <cstring>
Line 13:
Code: [Select]
using namespace std::tr1;You don't need this line. Comment or remove it.

Then you compile with:
Code: [Select]
gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC -std=c++0x xchat_omnomirc.cpp -o xchat_omnomirc.so
And you move the resulting file in ~/.xchat2 so it autoruns when xchat starts.
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 04:37:18 pm
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.
Ah ok thanks for the update and info :)
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 04:37:37 pm
You can also use
Code: [Select]
/load "/path/to/file"
Or, on windows
Code: [Select]
/load "c:\path\to\file"
Title: Re: IRC Client Integration
Post by: alberthrocks on June 27, 2011, 04:38:09 pm
Here's the compile command:
g++ -Wl,--export-dynamic -Wall -O1 -shared -fPIC -std=c++0x -I/usr/include/xchat OmnomIRC_XChat_Plugin.c -o OmnomIRC_XChat_Plugin.so

One minor fix needed - you need to add
Code: [Select]
#include <stdio.h>
#include <tr1/type_traits>
...so things compile! :)

Here's the updated source:
Code: [Select]
#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;
}

EDIT: Forgot to add "#include <tr1/type_traits>" to things to add. Sorry!
Title: Re: IRC Client Integration
Post by: willrandship on June 27, 2011, 04:40:46 pm
@netham tcl isn't a massive setup on windows, unlike python and perl.

Also, why the cstring instead of string? is it better? It seems like it might be smaller....
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 04:41:01 pm
Here's the full Windows project.
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 04:42:21 pm
Wow the X-Chat script is so much larger than the mIRC one. Is it because it's lower level or something? O.O
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 04:43:32 pm
mIRC makes it easy to do this stuff, I had to make a C++ dll for X-Chat to get it to do it. The mIRC one took me like 5 minutes, the stupid X-Chat one took me a couple hours (Those damn regex libs make no sense what-so-ever)
Title: Re: IRC Client Integration
Post by: Juju on June 27, 2011, 04:43:32 pm
alberthrocks, I don't think you need all these libraries... Get my version to keep it simple and optimized. Unless my version doesn't work at all.

Code: (xchat_omnomirc.cpp) [Select]
#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;
}

EDIT: Also removed a warning about a function being unused.
EDIT2: Removed more unused stuff. So you should only see deprecated conversion from string constant to ‘char*’ warnings.
EDIT3: Fixed symbol issue.
Title: Re: IRC Client Integration
Post by: ruler501 on June 27, 2011, 04:44:13 pm
Yeah miRC is a lot simpler to write something like this for. XChat you have to write in a lot more things
Title: Re: IRC Client Integration
Post by: alberthrocks on June 27, 2011, 04:44:42 pm
Wow the X-Chat script is so much larger than the mIRC one. Is it because it's lower level or something? O.O
Yup, pure C++ at it's best. ;) I think I could port this to Python, not sure.
The reason I say Python is because it's offered on most, if not all, Linux systems (including Macs! O_O), but not Tcl.
Title: Re: IRC Client Integration
Post by: Jim Bauwens on June 27, 2011, 04:45:47 pm
Thanks Juju, now I could compile it :D
One thing: gcc should be c++ :)

Edit: Apparently I did something wrong:
Code: [Select]
/home/jim/xchat_omnomirc.so: undefined symbol: _ZSt12regex_searchIPKcSaISt9sub_matchIS1_EEcSt12regex_traitsIcEEbT_S7_RSt13match_resultsIS7_T0_ERKSt11basic_regexIT1_T2_ESt6bitsetILj11EE
Title: Re: IRC Client Integration
Post by: Juju on June 27, 2011, 04:53:49 pm
Hmmm, I get this:
Code: [Select]
AutoLoad failed for: /home/julien/.xchat2/xchat_omnomirc.so
 Le symbole xchat_plugin_init n'existe pas ; est-ce vraiment un greffon xchat ?

Looks like the symbols get incorrectly exported.
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 04:56:17 pm
Here's an mIRC code that should strip Spybot45 and format Saxjax messages. Since I'm wrongfully banned in #cemetech still, I can't really test the Saxjax part of it.

Code: [Select]
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 }
}
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 05:06:49 pm
Yay it works :D

I might make using #cemetech and #omnimaga easier now, especially if I'm not using full screen windows.
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 05:07:27 pm
That's why I made it. I was having trouble keeping track of convos when the names were everywhere.
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 05:29:00 pm
Yeah, normally I have no issues in #omnimaga because of the (O) in color, but I used to have as much as in #cemetech. It was worse when I was doing other things and put mIRC at the bottom of the screen in a tiny window, though.
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 05:31:14 pm
I rely on colored nicks to tell who's talking a bit too much, and without that in x-chat, it was impossible to read. :P
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 05:58:56 pm
You have troubles with people talking too much? ???
Title: Re: IRC Client Integration
Post by: Netham45 on June 27, 2011, 05:59:43 pm
Yea, if they're using OmnomIRC, it's hard to read in X-Chat.
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 27, 2011, 06:00:40 pm
Lol ok I thought you meant just talking a lot in general :P
Title: Re: IRC Client Integration
Post by: Juju on June 28, 2011, 03:49:21 am
Good news everyone!

I got it working now, thanks to this page (http://www.linuxquestions.org/questions/programming-9/dynamic-symbols-382441/) :D

But it made xchat crash:
Code: [Select]
julien@amy:~$ xchat
terminate called after throwing an instance of 'std::regex_error'
  what():  regex_error
Abandon

And apparently it made my ZNC crash too O_o
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 28, 2011, 04:09:28 am
Hmm sorry to hear about the crash. Is there a way around that?

Also did it crash everyone's znc or just your connection?
Title: Re: IRC Client Integration
Post by: Juju on June 28, 2011, 04:17:10 am
I have to investigate... Well I know it's about the regex() thing.

Fortunately, it was my own ZNC nobody really uses but me and maybe 2 other people. Who all crashed BTW.
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on June 28, 2011, 04:18:16 am
Oh ok. I hope it's not a Linux issue x.x
Title: Re: IRC Client Integration
Post by: Netham45 on June 28, 2011, 05:06:56 am
Personally, I'd suggest finding another regex engine, instead of getting the current code to work with it.
Title: Re: IRC Client Integration
Post by: Deep Toaster on June 29, 2011, 05:56:12 pm
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 :-
Title: Re: IRC Client Integration
Post by: Tribal on June 29, 2011, 06:41:56 pm
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.

Spoiler For Abandon All Hope, Ye Who Enter Here:
Code: [Select]
#include "xchat-plugin.h"
#include <string.h>

#define PNAME "OmnomIRC Integration"
#define PDESC "Integrates OmnomIRC into X-Chat"
#define PVERSION "0.1"

static xchat_plugin *ph;
static const char *omnomirc_nick = "OmnomIRC";

static int
message_cb(char *word[], void *userdata) {
    int i;
    char *res, *msg, nick[30];

    if (strcmp(word[1], omnomirc_nick))
        return XCHAT_EAT_NONE;

    msg = word[2];
    res = strchr(msg, '*');
    if (res != NULL && res-msg+1 < 11) {
        for (; msg != res; ++msg)
            *msg = '\x03';
        *msg = '\x03';
        *++msg = '6';
        word[1] = "*";
        return XCHAT_EAT_NONE;
    }

    for (i = 0; *msg != '>'; ++i,++msg) {
        if (*msg == '<')
            *msg = '\x03';
        nick[i] = *msg;
        *msg = '\x03';
    }

    *msg = '\x03';
    *++msg = '\x03';
    strcpy(word[1], nick);

    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) {
    ph = plugin_handle;

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

    xchat_hook_print(ph, "Channel Message", XCHAT_PRI_NORM, message_cb, NULL);

    xchat_print(ph, "OmnomIRC Integration loaded successfully!");

    return 1;
}
Title: Re: IRC Client Integration
Post by: Netham45 on June 30, 2011, 04:43:37 am
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 :-

It doesn't alter the online users list.
Title: Re: IRC Client Integration
Post by: Netham45 on July 25, 2011, 03:42:40 pm
Was there a reason this thread was locked? Unlocked...
Title: Re: IRC Client Integration
Post by: DJ Omnimaga on July 30, 2011, 12:22:15 pm
No clue. Maybe somebody accidentally it. ???
Title: Re: IRC Client Integration
Post by: Eeems on August 17, 2011, 05:40:36 pm
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.
Title: Re: IRC Client Integration
Post by: Sorunome on February 26, 2015, 01:34:56 pm
Let's do some epic necro >:D

So yeah, i just took my time to write HexChat bindings for OmnomIRC!

They are currently only pushed in the dev branch of the repo, so you can get them here: https://github.com/Sorunome/OmnomIRC2/blob/dev/omnombindings_hexchat.py

Have fun testing them out and reporting bugs!

Also imma edit the first post
Title: Re: IRC Client Integration
Post by: Juju on February 27, 2015, 01:13:22 pm
Oooh nice :D
Title: Re: IRC Client Integration
Post by: Eeems on February 27, 2015, 08:28:57 pm
Sorunome: Mind adding this info to the IRC page?
Title: Re: IRC Client Integration
Post by: Sorunome on February 28, 2015, 04:27:39 am
Sorunome: Mind adding this info to the IRC page?
Oh, right, forgot to do that :P