https://wiki.znc.in/index.php?title=Savebuff/XChat&feed=atom&action=history
Savebuff/XChat - Revision history
2024-03-29T08:43:27Z
Revision history for this page on the wiki
MediaWiki 1.42.0-alpha
https://wiki.znc.in/index.php?title=Savebuff/XChat&diff=1243&oldid=prev
DarthGandalf: Created page with "===== XChat Plugin ===== # Save the code below as ~/.xchat2/znc-savebuff.c # cd ~/.xchat2 && gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC -I/usr/include/xchat znc-savebuf..."
2011-12-17T18:26:56Z
<p>Created page with "===== XChat Plugin ===== # Save the code below as ~/.xchat2/znc-savebuff.c # cd ~/.xchat2 && gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC -I/usr/include/xchat znc-savebuf..."</p>
<p><b>New page</b></p><div>===== XChat Plugin =====<br />
<br />
# Save the code below as ~/.xchat2/znc-savebuff.c<br />
# cd ~/.xchat2 && gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC -I/usr/include/xchat znc-savebuff.c -o znc-savebuff.so<br />
#* Note: your include dir may be different from above<br />
# In xchat go to the "Window" menu and choose "Plugins and Scripts..."<br />
# Navigate to your compiled znc-savebuff.so file and choose "Load..."<br />
# Restart xchat and the modes should now look pretty<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
#include <unistd.h><br />
<br />
#ifdef _WIN32<br />
#include <windows.h><br />
#endif<br />
<br />
#include "xchat-plugin.h"<br />
<br />
#ifdef _WIN32<br />
static xchat_plugin *ph;<br />
#endif<br />
<br />
#define EMITPRINT( ... ) xchat_emit_print( plugin_handle, __VA_ARGS__ )<br />
#define SHOWMODE "mode \00310%s\003 \002%s\002 by \002%s\002"<br />
#define MODNAME "*savebuff"<br />
<br />
void ShowMode( xchat_plugin *plugin_handle, const char *pChannel, const char *pModes, const char *pNick )<br />
{<br />
char *pText;<br />
u_int iLength = strlen( SHOWMODE );<br />
iLength += strlen( pChannel );<br />
iLength += strlen( pModes );<br />
iLength += strlen( pNick ) + 1; // ( allow for NULL )<br />
<br />
pText = (char *)malloc( iLength );<br />
sprintf( pText, SHOWMODE, pChannel, pModes, pNick );<br />
<br />
EMITPRINT( "Generic Message", "-\00310-\002-\002\003", pText, NULL );<br />
<br />
free( pText );<br />
}<br />
<br />
int ProcessPMSG( char **word, char **word_eol, void *userdata )<br />
{<br />
xchat_plugin *plugin_handle = (xchat_plugin *)userdata;<br />
<br />
if ( ( word[1] ) && ( strncmp( (word[1]+1), MODNAME, strlen( MODNAME ) ) == 0 ) && ( word[4] ) && ( word[5] ) && ( word[6] ) )<br />
{<br />
char *pHostMask, *pType, *pChannel, *pArgs = NULL;<br />
char *pNick, *pHost;<br />
<br />
pChannel = word[3];<br />
pHostMask = word[5];<br />
pType = word[6];<br />
if ( word[7] )<br />
pArgs = word_eol[7];<br />
<br />
pNick = strdup( pHostMask );<br />
pHost = strrchr( pNick, '!' );<br />
<br />
if ( pHost )<br />
*pHost++ = '\0';<br />
<br />
if ( ( strcmp( "MODE", pType ) == 0 ) && ( pArgs ) )<br />
{<br />
ShowMode( plugin_handle, pChannel, pArgs, pNick );<br />
}<br />
else if ( strcmp( "JOIN", pType ) == 0 )<br />
{<br />
EMITPRINT( "Join", pNick, pChannel, pHost, NULL );<br />
}<br />
else if ( strcmp( "PART", pType ) == 0 )<br />
{<br />
EMITPRINT( "Part", pNick, pHost, pChannel, NULL );<br />
}<br />
else if ( strcmp( "NICK", pType ) == 0 )<br />
{<br />
if ( pArgs )<br />
EMITPRINT( "Change Nick", pNick, pArgs, NULL );<br />
else<br />
EMITPRINT( "Change Nick", pNick, "*shrug*", NULL );<br />
}<br />
else if ( strcmp( "QUIT", pType ) == 0 )<br />
{<br />
if ( pArgs )<br />
EMITPRINT( "Quit", pNick, pArgs, pHost, NULL );<br />
else<br />
EMITPRINT( "Quit", pNick, "No Reason", pHost, NULL );<br />
}<br />
else if ( ( strcmp( "KICK", pType ) == 0 ) && ( pArgs ) )<br />
{<br />
char *pNickB = strdup( word[7] );<br />
pHost = strrchr( pNickB, '!' );<br />
if ( pHost )<br />
*pHost++ = '\0';<br />
<br />
if ( word[8] )<br />
EMITPRINT( "Kick", pNickB, pNick, pChannel, word_eol[8], NULL );<br />
else<br />
EMITPRINT( "Kick", pNickB, pNick, pChannel, "No Reason", NULL );<br />
<br />
free( pNickB );<br />
}<br />
else<br />
fprintf( stderr, "Unhandled Text! [%s]\n", word_eol[4] );<br />
<br />
free( pNick );<br />
return( XCHAT_EAT_ALL );<br />
}<br />
<br />
return( XCHAT_EAT_NONE );<br />
}<br />
<br />
void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved)<br />
{<br />
*name = "znc-xchat";<br />
*desc = "wraps messages sent by *savebuff module to fake modes and such";<br />
*version = "1.0";<br />
if ( reserved )<br />
*reserved = NULL;<br />
}<br />
<br />
int DontDisplay( char **word, void *userdata )<br />
{<br />
return( XCHAT_EAT_XCHAT );<br />
}<br />
<br />
int ShowModes( char **word, char **word_eol, void *userdata )<br />
{<br />
xchat_plugin *plugin_handle = (xchat_plugin *)userdata;<br />
char *pChannel = word[3], *pNick = strdup( (word[1]+1) ), *pModes = word_eol[4];<br />
char *pTmp;<br />
<br />
pTmp = strchr( pNick, '!' );<br />
if ( pTmp )<br />
*pTmp = '\0';<br />
<br />
ShowMode( plugin_handle, pChannel, pModes, pNick );<br />
<br />
free( pNick );<br />
return( XCHAT_EAT_NONE );<br />
}<br />
<br />
int xchat_plugin_init( xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg )<br />
{<br />
#ifdef _WIN32<br />
ph = plugin_handle;<br />
#endif<br />
<br />
xchat_plugin_get_info (plugin_name, plugin_desc, plugin_version, NULL);<br />
xchat_hook_server( plugin_handle, "PRIVMSG", XCHAT_PRI_NORM, ProcessPMSG, (void *)plugin_handle );<br />
xchat_hook_server( plugin_handle, "MODE", XCHAT_PRI_NORM, ShowModes, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Operator", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel DeOp", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Voice", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel DeVoice", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Ban", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel UnBan", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Mode Generic", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Set Key", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Set Limit", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Remove Keyword", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
xchat_hook_print( plugin_handle, "Channel Remove Limit", XCHAT_PRI_NORM, DontDisplay, (void *)plugin_handle );<br />
return( 1 );<br />
}<br />
<br />
int xchat_plugin_deinit( xchat_plugin *plugin_handle )<br />
{<br />
return( 1 );<br />
}</div>
DarthGandalf