From 8d2199c705efc8a912c0640b8dbe5cc638546363 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 2 Feb 2014 02:12:47 -0500 Subject: added Sparkles source files --- 4hexchat.c | 40 + 4hexchat.exe | Bin 0 -> 53278 bytes XChat.def | 4 + hexchat-plugin.h | 374 +++++++ makeHexsparkles.bat | 4 + makeSparkles.bat | 3 + sparkles.c | 3114 +++++++++++++++++++++++++++++++++++++++++++++++++++ xchat-plugin.h | 334 ++++++ 8 files changed, 3873 insertions(+) create mode 100644 4hexchat.c create mode 100644 4hexchat.exe create mode 100644 XChat.def create mode 100644 hexchat-plugin.h create mode 100644 makeHexsparkles.bat create mode 100644 makeSparkles.bat create mode 100644 sparkles.c create mode 100644 xchat-plugin.h diff --git a/4hexchat.c b/4hexchat.c new file mode 100644 index 0000000..956a4a7 --- /dev/null +++ b/4hexchat.c @@ -0,0 +1,40 @@ +#include +#include +#include + +int main(int argc, char *argv[]) { + if(argc < 3){puts("Syntax: 4Hexchat Input Output"); return -1;} + + FILE *File = fopen(argv[1],"rb"); + if(File == NULL) { + fputs("Couldn't open file for reading",stderr); return 0; + } + fseek(File, 0, SEEK_END); + long FileSize = ftell(File); + rewind(File); + char *Buffer = (char*)malloc(sizeof(char)*FileSize); + if(Buffer == NULL) { + fclose(File); + fputs("Can't allocate memory",stderr); return 0; + } + if(FileSize != fread(Buffer,1,FileSize,File)) { + fclose(File); + fputs("Can't read from file",stderr); return 0; + } + fclose(File); + File = fopen(argv[2],"wb"); + if(File == NULL) { + fputs("Couldn't open file for writing",stderr); return 0; + } + + int i; + for(i=0;i + +#define HEXCHAT_PRI_HIGHEST 127 +#define HEXCHAT_PRI_HIGH 64 +#define HEXCHAT_PRI_NORM 0 +#define HEXCHAT_PRI_LOW (-64) +#define HEXCHAT_PRI_LOWEST (-128) + +#define HEXCHAT_FD_READ 1 +#define HEXCHAT_FD_WRITE 2 +#define HEXCHAT_FD_EXCEPTION 4 +#define HEXCHAT_FD_NOTSOCKET 8 + +#define HEXCHAT_EAT_NONE 0 /* pass it on through! */ +#define HEXCHAT_EAT_HEXCHAT 1 /* don't let HexChat see this event */ +#define HEXCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define HEXCHAT_EAT_ALL (HEXCHAT_EAT_HEXCHAT|HEXCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _hexchat_plugin hexchat_plugin; +typedef struct _hexchat_list hexchat_list; +typedef struct _hexchat_hook hexchat_hook; +#ifndef PLUGIN_C +typedef struct _hexchat_context hexchat_context; +#endif + +#ifndef PLUGIN_C +struct _hexchat_plugin +{ + /* these are only used on win32 */ + hexchat_hook *(*hexchat_hook_command) (hexchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + hexchat_hook *(*hexchat_hook_server) (hexchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + hexchat_hook *(*hexchat_hook_print) (hexchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + hexchat_hook *(*hexchat_hook_timer) (hexchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + hexchat_hook *(*hexchat_hook_fd) (hexchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*hexchat_unhook) (hexchat_plugin *ph, + hexchat_hook *hook); + void (*hexchat_print) (hexchat_plugin *ph, + const char *text); + void (*hexchat_printf) (hexchat_plugin *ph, + const char *format, ...); + void (*hexchat_command) (hexchat_plugin *ph, + const char *command); + void (*hexchat_commandf) (hexchat_plugin *ph, + const char *format, ...); + int (*hexchat_nickcmp) (hexchat_plugin *ph, + const char *s1, + const char *s2); + int (*hexchat_set_context) (hexchat_plugin *ph, + hexchat_context *ctx); + hexchat_context *(*hexchat_find_context) (hexchat_plugin *ph, + const char *servname, + const char *channel); + hexchat_context *(*hexchat_get_context) (hexchat_plugin *ph); + const char *(*hexchat_get_info) (hexchat_plugin *ph, + const char *id); + int (*hexchat_get_prefs) (hexchat_plugin *ph, + const char *name, + const char **string, + int *integer); + hexchat_list * (*hexchat_list_get) (hexchat_plugin *ph, + const char *name); + void (*hexchat_list_free) (hexchat_plugin *ph, + hexchat_list *xlist); + const char * const * (*hexchat_list_fields) (hexchat_plugin *ph, + const char *name); + int (*hexchat_list_next) (hexchat_plugin *ph, + hexchat_list *xlist); + const char * (*hexchat_list_str) (hexchat_plugin *ph, + hexchat_list *xlist, + const char *name); + int (*hexchat_list_int) (hexchat_plugin *ph, + hexchat_list *xlist, + const char *name); + void * (*hexchat_plugingui_add) (hexchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*hexchat_plugingui_remove) (hexchat_plugin *ph, + void *handle); + int (*hexchat_emit_print) (hexchat_plugin *ph, + const char *event_name, ...); + int (*hexchat_read_fd) (hexchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*hexchat_list_time) (hexchat_plugin *ph, + hexchat_list *xlist, + const char *name); + char *(*hexchat_gettext) (hexchat_plugin *ph, + const char *msgid); + void (*hexchat_send_modes) (hexchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*hexchat_strip) (hexchat_plugin *ph, + const char *str, + int len, + int flags); + void (*hexchat_free) (hexchat_plugin *ph, + void *ptr); + int (*hexchat_pluginpref_set_str) (hexchat_plugin *ph, + const char *var, + const char *value); + int (*hexchat_pluginpref_get_str) (hexchat_plugin *ph, + const char *var, + char *dest); + int (*hexchat_pluginpref_set_int) (hexchat_plugin *ph, + const char *var, + int value); + int (*hexchat_pluginpref_get_int) (hexchat_plugin *ph, + const char *var); + int (*hexchat_pluginpref_delete) (hexchat_plugin *ph, + const char *var); + int (*hexchat_pluginpref_list) (hexchat_plugin *ph, + char *dest); +}; +#endif + + +hexchat_hook * +hexchat_hook_command (hexchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + +hexchat_hook * +hexchat_hook_server (hexchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + +hexchat_hook * +hexchat_hook_print (hexchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + +hexchat_hook * +hexchat_hook_timer (hexchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + +hexchat_hook * +hexchat_hook_fd (hexchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + +void * +hexchat_unhook (hexchat_plugin *ph, + hexchat_hook *hook); + +void +hexchat_print (hexchat_plugin *ph, + const char *text); + +void +hexchat_printf (hexchat_plugin *ph, + const char *format, ...); + +void +hexchat_command (hexchat_plugin *ph, + const char *command); + +void +hexchat_commandf (hexchat_plugin *ph, + const char *format, ...); + +int +hexchat_nickcmp (hexchat_plugin *ph, + const char *s1, + const char *s2); + +int +hexchat_set_context (hexchat_plugin *ph, + hexchat_context *ctx); + +hexchat_context * +hexchat_find_context (hexchat_plugin *ph, + const char *servname, + const char *channel); + +hexchat_context * +hexchat_get_context (hexchat_plugin *ph); + +const char * +hexchat_get_info (hexchat_plugin *ph, + const char *id); + +int +hexchat_get_prefs (hexchat_plugin *ph, + const char *name, + const char **string, + int *integer); + +hexchat_list * +hexchat_list_get (hexchat_plugin *ph, + const char *name); + +void +hexchat_list_free (hexchat_plugin *ph, + hexchat_list *xlist); + +const char * const * +hexchat_list_fields (hexchat_plugin *ph, + const char *name); + +int +hexchat_list_next (hexchat_plugin *ph, + hexchat_list *xlist); + +const char * +hexchat_list_str (hexchat_plugin *ph, + hexchat_list *xlist, + const char *name); + +int +hexchat_list_int (hexchat_plugin *ph, + hexchat_list *xlist, + const char *name); + +time_t +hexchat_list_time (hexchat_plugin *ph, + hexchat_list *xlist, + const char *name); + +void * +hexchat_plugingui_add (hexchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + +void +hexchat_plugingui_remove (hexchat_plugin *ph, + void *handle); + +int +hexchat_emit_print (hexchat_plugin *ph, + const char *event_name, ...); + +char * +hexchat_gettext (hexchat_plugin *ph, + const char *msgid); + +void +hexchat_send_modes (hexchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + +char * +hexchat_strip (hexchat_plugin *ph, + const char *str, + int len, + int flags); + +void +hexchat_free (hexchat_plugin *ph, + void *ptr); + +int +hexchat_pluginpref_set_str (hexchat_plugin *ph, + const char *var, + const char *value); + +int +hexchat_pluginpref_get_str (hexchat_plugin *ph, + const char *var, + char *dest); + +int +hexchat_pluginpref_set_int (hexchat_plugin *ph, + const char *var, + int value); +int +hexchat_pluginpref_get_int (hexchat_plugin *ph, + const char *var); + +int +hexchat_pluginpref_delete (hexchat_plugin *ph, + const char *var); + +int +hexchat_pluginpref_list (hexchat_plugin *ph, + char *dest); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef HEXCHAT_PLUGIN_HANDLE +#define HEXCHAT_PLUGIN_HANDLE (ph) +#endif +#define hexchat_hook_command ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_command) +#define hexchat_hook_server ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_server) +#define hexchat_hook_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_print) +#define hexchat_hook_timer ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_timer) +#define hexchat_hook_fd ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_fd) +#define hexchat_unhook ((HEXCHAT_PLUGIN_HANDLE)->hexchat_unhook) +#define hexchat_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_print) +#define hexchat_printf ((HEXCHAT_PLUGIN_HANDLE)->hexchat_printf) +#define hexchat_command ((HEXCHAT_PLUGIN_HANDLE)->hexchat_command) +#define hexchat_commandf ((HEXCHAT_PLUGIN_HANDLE)->hexchat_commandf) +#define hexchat_nickcmp ((HEXCHAT_PLUGIN_HANDLE)->hexchat_nickcmp) +#define hexchat_set_context ((HEXCHAT_PLUGIN_HANDLE)->hexchat_set_context) +#define hexchat_find_context ((HEXCHAT_PLUGIN_HANDLE)->hexchat_find_context) +#define hexchat_get_context ((HEXCHAT_PLUGIN_HANDLE)->hexchat_get_context) +#define hexchat_get_info ((HEXCHAT_PLUGIN_HANDLE)->hexchat_get_info) +#define hexchat_get_prefs ((HEXCHAT_PLUGIN_HANDLE)->hexchat_get_prefs) +#define hexchat_list_get ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_get) +#define hexchat_list_free ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_free) +#define hexchat_list_fields ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_fields) +#define hexchat_list_next ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_next) +#define hexchat_list_str ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_str) +#define hexchat_list_int ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_int) +#define hexchat_plugingui_add ((HEXCHAT_PLUGIN_HANDLE)->hexchat_plugingui_add) +#define hexchat_plugingui_remove ((HEXCHAT_PLUGIN_HANDLE)->hexchat_plugingui_remove) +#define hexchat_emit_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_emit_print) +#define hexchat_list_time ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_time) +#define hexchat_gettext ((HEXCHAT_PLUGIN_HANDLE)->hexchat_gettext) +#define hexchat_send_modes ((HEXCHAT_PLUGIN_HANDLE)->hexchat_send_modes) +#define hexchat_strip ((HEXCHAT_PLUGIN_HANDLE)->hexchat_strip) +#define hexchat_free ((HEXCHAT_PLUGIN_HANDLE)->hexchat_free) +#define hexchat_pluginpref_set_str ((HEXCHAT_PLUGIN_HANDLE)->hexchat_pluginpref_set_str) +#define hexchat_pluginpref_get_str ((HEXCHAT_PLUGIN_HANDLE)->hexchat_pluginpref_get_str) +#define hexchat_pluginpref_set_int ((HEXCHAT_PLUGIN_HANDLE)->hexchat_pluginpref_set_int) +#define hexchat_pluginpref_get_int ((HEXCHAT_PLUGIN_HANDLE)->hexchat_pluginpref_get_int) +#define hexchat_pluginpref_delete ((HEXCHAT_PLUGIN_HANDLE)->hexchat_pluginpref_delete) +#define hexchat_pluginpref_list ((HEXCHAT_PLUGIN_HANDLE)->hexchat_pluginpref_list) +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/makeHexsparkles.bat b/makeHexsparkles.bat new file mode 100644 index 0000000..8884a59 --- /dev/null +++ b/makeHexsparkles.bat @@ -0,0 +1,4 @@ +4hexchat sparkles.c hexsparkles.c +gcc -Wall -Os -DWIN32 -c hexsparkles.c +dllwrap --def HexChat.def --dllname hexsparkles.dll hexsparkles.o +pause \ No newline at end of file diff --git a/makeSparkles.bat b/makeSparkles.bat new file mode 100644 index 0000000..1007c88 --- /dev/null +++ b/makeSparkles.bat @@ -0,0 +1,3 @@ +gcc -Wall -Os -DWIN32 -c sparkles.c +dllwrap --def XChat.def --dllname sparkles.dll sparkles.o +pause diff --git a/sparkles.c b/sparkles.c new file mode 100644 index 0000000..28f1328 --- /dev/null +++ b/sparkles.c @@ -0,0 +1,3114 @@ +/* + * Sparkles for XChat + * + * Copyright (C) 2011-2013 Princess Nova Storm the Squirrel + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +// YiffScript originally by Dr Dos +// Extra yiff actions taken from http://pastie.org/pastes/1069466 + +#define PNAME "Nova's Sparkles" +#define PDESC "Mix of annoying/powerful/useful stuff" +#define PVERSION "0.98+a" +#define USE_SPARKLES_USER 0 +#define ENABLE_NSFW_CONTENT 1 +#define PESTERCHUM_NETWORK "Pesterchum" + +#include "xchat-plugin.h" +#include // sprintf() and file access +#include // compares and copies and stuff +#include // Adj() really needs this +#include // for strtol() and rand() mainly +#include // so I can seed the randomizer with the current time +#include // used in the capitalization functions +#ifdef _WIN32 +#include +#endif +static xchat_plugin *ph; /* plugin handle */ +static char TextEditor[512]="start notepad"; +static int RejoinKick = 0; +static int EatInvites = 0; +static int JoinOnInvite= 0; +static int BeVerbose = 0; +static int LastYiff = -1; +static int DisableAutoIdent = 0; +static int DisableAutoNickDeblue= 0; +static int DisableAutoGhost=0; +static int DisablePesterchum=0; +static int DisablePrettyJanus=0; +static int DisableSparklesCTCP = 0; +static int AutoReclaimNick = 0; +static char GhostReclaimNick[80]=""; +static int DisablePlusJFix = 0; +static int Activity2Focus = 0; +static char SayHookCommand[512]=""; +static int SayHookSpace = 1; +static char OneSayHook[512]=""; +static char MeHookCommand[512]=""; +static int UseOneSayHook = 0; +static xchat_hook *SayHook, *MeHook; +static int EatHighlights = 0; +static int MoveNotifyToServer=0; +static int MoveServicesToServer=0; +static char ConfigFilePath[512]=""; + +static unsigned int StartingTime = 0; // to help stop "oh my god I started xchat and it autoghosted stuff" +static int GrabbingTopic = 0; +static char CommandPrefix[5] = "/"; // because this is able to be changed in XChat + +static char CmdStackText[512]; +static char *CmdStackPtr = NULL; +//static int CmdStackLevel = 0; + +static int ContextStackSP = 0; +static xchat_context *ContextStack[16]; +static int RandomType = 1; + +static int DisableShowNetworkOnJoin=0; +static int NeedSpaceBetweenX5Font = 0; +static char PesterchumChanHook[256] = "spark pestersay"; +static char PesterchumColor[64] = "0,0,0"; + +static xchat_hook *SpawnHook[64] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; +static char JanusLinkbots[32][8] = {"IotaIRC","IotaIRC_","","","","","",""}; + +// 02 16 1f 16 16 0f 02 03 30 30 03 30 30 +static const char SparkEncryptPrefix[] = {2,0x16,0x1f,0x16,0x16,0x0f,2,3,'0','0',3,'0','0',0}; +static char SparklesUser[64]; + +static char *Rainbow[]={"04","08","09","12","13"}; + +void INIConfigHandler(const char *Group, const char *Item, const char *Value); +int ParseINI(FILE *File, void (*Handler)(const char *Group, const char *Item, const char *Value)); + +struct SpawnInfo { + int Slot; + int TimeAmount; + char Command[1024]; + xchat_context *Context; +}; + +static int spawntimer_cb(void *userdata) { + struct SpawnInfo *Spawn = (struct SpawnInfo *)userdata; + if(Spawn) { + if(xchat_set_context(ph,Spawn->Context)) + xchat_command(ph, Spawn->Command); + else + xchat_printf(ph, "%sContext switch failed for spawn %i \n", SparklesUser, Spawn->Slot); + SpawnHook[Spawn->Slot]=NULL; + free(Spawn); + } + return 0; +} + +static unsigned int MZXRand(unsigned long long range) { + static unsigned long long seed = 0; + unsigned long long value; + // If the seed is 0, initialise it with time and clock + if(seed == 0) + seed = time(NULL) + clock(); + seed = seed * 1664525 + 1013904223; + value = (seed & 0xFFFFFFFF) * range / 0xFFFFFFFF; + return (unsigned int)value; +} +static int RepeatRand(int Max) { + Max = abs(Max); + int Mask = 1; + while(Mask < (Max-1)) + Mask = (Mask<<1) | 1; + int Try; + while(1) { + if(RandomType!=3) + Try = rand()&Mask; + else + Try = MZXRand(Mask+1); + if(Try > (Max-1)) continue; + break; + } + return Try; +} +static int rand2(int max) { + if(max <= 0) return 0; + switch(RandomType) { + default: + return rand()%max; + case 1: + return RepeatRand(max); + case 2: + return MZXRand(max); + case 3: + return RepeatRand(max); + } +} + +static int IsPesterchum() { + const char *Net = xchat_get_info(ph,"network"); + if(Net == NULL) return 0; + return !strcasecmp(Net, PESTERCHUM_NETWORK); +} +static int IsChannel() { + const char *Chan = xchat_get_info(ph,"channel"); + if(Chan == NULL) return 0; + return *Chan == '#'; +} + +static int MyNickCmp(char *N1, char *N2) { + static char *StripName; + StripName = xchat_strip(ph, N1, -1, 3); + if(StripName == NULL) + return 0; + if(!strcasecmp(StripName, N2)) { + xchat_free(ph, StripName); + return 1; + } + xchat_free(ph, StripName); + return 0; +} +struct RandomReplaceList { + char In; int Amount; char Out[8]; +}; +struct RandomReplaceList AccentList[] = { + {'A',6,{'À','Á','Â','Ã','Ä','Å'}}, + {'a',6,{'à','á','â','ã','ä','å'}}, + {'E',6,{'È','É','Ê','Ë','E','E'}}, + {'e',6,{'è','é','ê','ë','e','e'}}, + {'O',6,{'Ò','Ó','Ô','Õ','Ö','Ø'}}, + {'o',6,{'ò','ó','ô','õ','ö','ø'}}, + {'U',4,{'Ù','Ú','Û','Ü'}}, + {'u',4,{'ù','ú','û','ü'}}, + {'I',4,{'Ì','Í','Î','Ï'}}, + {'i',4,{'ì','í','î','ï'}}, + {0} +}; + +static char *AccentFilter(char *Output, char *Input) { + char *Poke = Output, *Peek = Input; + while(*Peek) { + char k = *(Peek++); + if(k == 'N') k = 'Ñ'; + if(k == 'n') k = 'ñ'; + if(k == 'S') k = 'Š'; + if(k == 's') k = 'š'; + if(k == 'Z') k = 'Ž'; + if(k == 'y') k = 'ý'; + if(k == 'Y') k = 'Ý'; + if(k == 'D') k = 'Ð'; + if(k == 'C') k = 'Ç'; + if(k == 'c') k = 'ç'; + if(k == 'B') k = 'ß'; + int i; + *Poke = k; + for(i=0;AccentList[i].In;i++) + if(k==AccentList[i].In) { + int j = rand2(AccentList[i].Amount); + *Poke = AccentList[i].Out[j]; + break; + } + Poke++; + } + *Poke = 0; + return Output; +} + +struct ReplaceList { + char *In; char *Out; int Mode; +}; +struct ReplaceList SellyList[] = { + {"you", "u", 0}, {"your", "ur", 0}, {"you're", "ur", 0}, {"know", "kno", 0}, {"threw", "thru", 0}, {"through", "thru", 0}, + {"where", "where", 0}, {"there", "there", 0}, {"place", "plase", 0}, {"really", "reely", 0}, + {"yone", "1", 0}, {" one", " 1", 0}, {"yeah", "ya", 0}, {"mean", "meen", 0}, {"because", "cuz", 0}, + {"'cause", "cuz", 0}, {"you", "u", 0}, {"i'm", "im", 0}, {"though", "tho", 0}, {"weren't", "wernt", 0}, {"people", "ppl", 0}, + {"weird", "wierd", 0}, {"i'm going to", "ima", 0}, {"going to", "gunna", 0}, {"gonna", "gunna", 0}, {"until", "till", 0}, + {"when", "wen", 0}, {"like", "liek", 0}, {"person", "persin", 0}, {"here", "heer", 0}, {"probably", "probly", 0}, {"should", "shud", 0}, + {"are you", "ru", 0}, {"what", "wat", 0}, {"tried", "tryed", 0}, {"ould", "ud", 0}, {"bye", "bai", 0}, {" are ", " r ", 0}, {"really", "rlly", 0}, + {"please", "plz", 0}, {"'t", "t", 0}, {"'ll", "ll", 0}, {"'s", "s", 0}, {"'re", "re", 0}, {"'ve", "ve", 0}, {"'d", "d", 0}, + + {"why", "y", 1}, {"was", "wuz", 1}, {"please", "plz", 1}, {" the ", " teh ", 1}, {"more", "moar", 1}, {"with", "wif", 1}, + {"my", "mai", 1}, // gud + {NULL, NULL, 0} +}; +static char *SellyFilter(char *Output, char *Input, int Mode) { + char *Poke = Output; + char *Peek = Input; + void Replace(char *Old, char *New, int Mode) { + int i=0; + if(Peek==Input) + if(Old[0]==' ') { + Old++; + New++; + } + for(i=0;Old[i];i++) + if(Old[i] != tolower(Peek[i])) + return; + i=0; + memcpy(Poke, New, strlen(New)); + Peek+=strlen(Old)-1; + Poke+=strlen(New)-1; + } + while(*Peek) { + if((Peek == Input) || (Peek[-1]!=':' && Peek[-1]!=';')) + *Poke = tolower(*Peek); + else + *Poke = *Peek; + int i=0; + for(i=0;SellyList[i].In != NULL;i++) + if(Mode >= (SellyList[i].Mode & 3)) + Replace(SellyList[i].In, SellyList[i].Out, 0); + Poke++; Peek++; + } + *Poke = 0; + return Output; +} + +static char *ScarletFilter(char *Output, char *Input) { + char *Poke = Output; + char *Peek = Input; + void Replace(char *Old, char *New, int Mode) { + int i=0, WasUpper=0; + if(isupper(*Peek)) + WasUpper=1; + if(Peek==Input) + if(Old[0]==' ') { + Old++; + New++; + } + for(i=0;Old[i];i++) + if(Old[i] != tolower(Peek[i])) + return; + int AllCaps = 1; + for(i=0;Old[i];i++) { + if(isalpha(Peek[i]) && islower(Peek[i])) { + AllCaps = 0; + break; + } + } + i=0; + memcpy(Poke, New, strlen(New)); + if(AllCaps) + for(i=0;i') // change to + ReplaceTo = Words[i]+1; + if(Words[i][0] == '<') // change from + if(ReplaceTo!=NULL) + Replace(Words[i]+1, ReplaceTo, 0); + if(Words[i][0] == '^') { // set flags + if(Words[i][1] == 'K' && Words[i][2] == 'C') + KeepCaps ^= 1; + } + } + Poke++; Peek++; + } + *Poke = 0; + return Output; +} + + +static void ShuffleChars(char *Poke, char *Peek, int Swaps, int Flags) { + strcpy(Poke,Peek); + char *End = Poke + strlen(Poke); + int i,EndNow = 0; + char *Next; + while(Poke <= End && !EndNow) { + Next = Poke; + while(isalpha(*Next)) + Next++; + int WordLen = Next - Poke; + if(WordLen>=2) { // must be at least 4 letters + for(i=0;i 4) RainbowIndex = 0; + s++; + } + if(Loop[s] == ',') { + Out[o++]=Loop[s++]; + if(tolower(Loop[s]) != 'g') { + Out[o++]=Loop[s++]; + Out[o++]=Loop[s++]; + } + else { + Out[o++]=Rainbow[RainbowIndex][0]; + Out[o++]=Rainbow[RainbowIndex][1]; + if(Loop[s]!='G') + RainbowIndex++; + if(RainbowIndex > 4) RainbowIndex = 0; + s++; + } + } + break; + case 'u': Out[o++]=0x1f; break; + case 'b': Out[o++]=0x02; break; + case 'i': Out[o++]=0x16; break; + case 'p': Out[o++]=0x0f; break; + case '_': Out[o++]=' '; break; + + case '\'': Out[o++]=Loop[s++]; break; + case '*': + switch(Caps) { + case 0: Out[o++]=In[i++]; break; + case 1: Out[o++]=toupper(In[i++]); break; + case 2: Out[o++]=tolower(In[i++]); break; + case 3: Out[o++]=(rand()&1)?toupper(In[i++]):tolower(In[i++]); break; + } + break; + + case 'C': + switch(Loop[s++]) { + case 'N': Caps=0; break; + case 'U': Caps=1; break; + case 'L': Caps=2; break; + case 'R': Caps=3; break; + } + break; + + case '`': + switch(Loop[s++]) { + case '?': + while(!(isgraph(In[i]) || (In[i]==' ')) && i 1000) return 1; break; + } + } + Out[o]=0; + return 0; +} + +static char *Adj(int Amount, char *Word, ...); +static char *TrollFilter(char *Output, char *Input, char *Troll) { + if(Troll[0] == 0) return "???"; + if(Troll[1] == 0) return "???"; + + char *Poke = Output; + char *Peek = Input; + int j; + void LowerAll() { + int i; + for(i=0;Output[i];i++) + Output[i]=tolower(Output[i]); + } + void UpperAll() { + int i; + for(i=0;Output[i];i++) + Output[i]=toupper(Output[i]); + } + void Replace(char *Old, char *New, int Mode) { + int i=0; + if(Peek==Input && Old[0]==' ') { + Old++; + New++; + } + for(i=0;Old[i];i++) + if(Old[i] != tolower(Peek[i])) + return; + i=0; + memcpy(Poke, New, strlen(New)); + Peek+=strlen(Old)-1; + Poke+=strlen(New)-1; + } + int TrollNum = 0; + switch(tolower(Troll[0])) { + case 'a': TrollNum|=0; break; + case 't': TrollNum|=4; break; + case 'g': TrollNum|=8; break; + case 'c': TrollNum|=12; break; + } + switch(tolower(Troll[1])) { + case 'a': TrollNum|=0; break; + case 't': TrollNum|=1; break; + case 'g': TrollNum|=2; break; + case 'c': TrollNum|=3; break; + } + + if(Troll[0]=='U'&&Troll[1]=='U') { + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'u') *Poke = 'U'; + else *Poke = tolower(*Peek); + Poke++; Peek++; + } + } else if(Troll[0]=='u'&&Troll[1]=='u') { + while(*Peek) { + *Poke = *Peek; + if(toupper(Peek[0]) == 'U') *Poke = 'u'; + else *Poke = toupper(*Peek); + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='l'&&tolower(Troll[1])=='p') { + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'a') *Poke = '4'; + if(tolower(Peek[0]) == 'i') *Poke = '1'; + if(tolower(Peek[0]) == 'e') *Poke = '3'; + Poke++; Peek++; + } + LowerAll(); + } else if(tolower(Troll[0])=='m'&&tolower(Troll[1])=='c') { + while(*Peek) { + *Poke = toupper(*Peek); + if(tolower(Peek[0]) == 'a') *Poke = '4'; + if(tolower(Peek[0]) == 's') *Poke = '5'; + if(tolower(Peek[0]) == 'o') *Poke = '0'; + if(tolower(Peek[0]) == 't') *Poke = '7'; + if(tolower(Peek[0]) == 'b') *Poke = '8'; + if(tolower(Peek[0]) == 'i') *Poke = '1'; + if(tolower(Peek[0]) == 'e') *Poke = '3'; + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='k'&&tolower(Troll[1])=='v') { + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'b') *Poke = '6'; + if(tolower(Peek[0]) == 'o') *Poke = '9'; + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='m'&&tolower(Troll[1])=='l') { + strcpy(Poke, Adj(8, "(=`ω´=) ","(^•ω•^) ","(=^•^=) ","(=^•ω•^=) ","(^•o•^) ","(=^-ω-^=) ","(=^ω^=) ","(=TωT=) ")); + Poke = strchr(Poke, 0); + if(!Poke) return "???"; + while(*Peek) { + *Poke = *Peek; + Replace("ee", "33", 0); + Replace("pause", "pawse", 0); + Replace(" per", " purr", 0); + Replace(" for", " fur", 0); + Replace(" pos", " paws", 0); + Replace(" pro", " purro", 0); + Replace(":3", ":33", 0); + Replace("x3", "X33", 0); + Replace(":D", ":DD", 0); + Replace(":)", ":))", 0); + Replace(":(", ":((", 0); + Replace("transparent", "transpurrent", 0); + Replace("hypocrite", "hypurrcrite", 0); + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='a'&&tolower(Troll[1])=='s') { + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'b') *Poke = '8'; + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='p'&&tolower(Troll[1])=='m') { + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'o') *(++Poke) = '+'; + Replace(" plus", " +", 0); + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='m'&&tolower(Troll[1])=='p') { + while(*Peek) { + *Poke = *Peek; + Replace("h", ")(", 0); + Replace("H", ")(", 0); + Replace(":", "38", 0); + if(*Peek == 'E') { + *(Poke++) = '-'; + *Poke = 'E'; + } + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='k'&&tolower(Troll[1])=='m') { + *(Poke++) = 0x02; + *(Poke++) = 0x03; + *(Poke++) = '1'; + *(Poke++) = '3'; + *(Poke++) = ','; + *(Poke++) = '0'; + *(Poke++) = '1'; + while(*Peek) { + *Poke = toupper(*Peek); + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='h'&&tolower(Troll[1])=='z') { + strcpy(Poke, "8=D < "); + Poke += 6; + + while(*Peek) { + *Poke = *Peek; + Replace("strong","STRONG",0); + Replace("loo","100",0); + Replace("lue ","100 ",0); + Replace("ool","001",0); + if(tolower(Peek[0]) == 'x') *Poke = '%'; + Replace("ks","%",0); + Poke++; Peek++; + } + } else if(tolower(Troll[0])=='c'&&tolower(Troll[1])=='r') { + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'w') *(++Poke) = 'v'; + if(tolower(Peek[0]) == 'v') *(++Poke) = 'w'; + if(Peek[0] == 'B' && isupper(Peek[-1])) *(++Poke) = '8'; + Replace("ing ","in ",0); + Poke++; + Peek++; + } + } else if(tolower(Troll[0])=='d'&&tolower(Troll[1])=='m') { + while(*Peek) + *(Poke++) = *(Peek++); + UpperAll(); + } else if(tolower(Troll[0])=='r'&&tolower(Troll[1])=='n') { + while(*Peek) { + *(Poke++) = *(Peek++); + if(tolower(Peek[0]) == 'i') *(++Poke) = '1'; + } + LowerAll(); + } else switch(TrollNum) { + case 0: // aa + while(*Peek) { + *(Poke++) = *(Peek++); + if(tolower(Peek[-1]) == 'O') Poke[-1] = '0'; + } + LowerAll(); + break; + case 1: // at + while(*Peek) { + if(isupper(*Peek)) + *Poke = tolower(*Peek); + else + *Poke = toupper(*Peek); + if(Peek == Input) + *Poke = tolower(*Peek); + if(*Peek == '.') *Poke = ','; + Replace(":", "}:", 0); + Poke++; Peek++; + } + break; + case 2: // ag + while(*Peek) { + *(Poke++) = *(Peek++); + if(tolower(Peek[-1]) == 'b') Poke[-1] = '8'; + Replace("ate", "8", 0); + Replace("ait", "8", 0); + Replace(":", "::::", 0); + } + break; + case 3: // ac, http://mspaintadventures.com/?s=6&p=004062 + strcpy(Poke, ":33 < "); + Poke += 6; + while(*Peek) { + *Poke = *Peek; + Replace("ee", "33", 0); + Replace("pause", "pawse", 0); + Replace(" per", " purr", 0); + Replace(" for", " fur", 0); + Replace(" pos", " paws", 0); + Replace(" pro", " purro", 0); + Replace(":3", ":33", 0); + Replace("x3", "X33", 0); + Replace(":D", ":DD", 0); + Replace(":)", ":))", 0); + Replace(":(", ":((", 0); + Replace("transparent", "transpurrent", 0); + Replace("hypocrite", "hypurrcrite", 0); +// amewsment, purrk, meowscular, purrtend, oppurtunity, prepawsterous, pawsture, accomeowdate + Poke++; Peek++; + } + LowerAll(); + break; + case 4: // ta + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 's') *Poke = '2'; + if(tolower(Peek[0]) == 'i') *(++Poke) = 'i'; + Poke++; Peek++; + } + Replace(" to"," two",0); + Replace(" too "," two ",0); + LowerAll(); + break; + case 5: // tt + // not a troll, rose + while(*Peek) + *(Poke++) = *(Peek++); + break; + case 6: // tg + // not a troll, dave + while(*Peek) + *(Poke++) = *(Peek++); + break; + case 7: // tc, gamzee + j=0; + while(*Peek) { + *Poke = ((j&1)?tolower(*Peek):toupper(*Peek)); + if(isgraph(*Poke)) j++; + if(*Poke == 'O' && Poke[-1]==':') *Poke = 'o'; + Poke++; Peek++; + } + break; + case 8: // ga + while(*Peek) { + *Poke = *Peek; + if(Peek==Input || (tolower(Peek[-1]) == ' ')) *Poke = toupper(*Peek); + Poke++; Peek++; + } + break; + case 9: // gt + // not a troll, john + while(*Peek) + *(Poke++) = *(Peek++); + break; + case 10: // gg + // not a troll, jade + while(*Peek) + *(Poke++) = *(Peek++); + break; + case 11: // gc + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'a') *Poke = '4'; + if(tolower(Peek[0]) == 'i') *Poke = '1'; + if(tolower(Peek[0]) == 'e') *Poke = '3'; + Poke++; Peek++; + Replace(":)", ">:]", 0); + Replace(";)", ">;]", 0); + } + UpperAll(); + break; + case 12: // ca + while(*Peek) { + *Poke = *Peek; + if(tolower(Peek[0]) == 'w') *(++Poke) = 'w'; + if(tolower(Peek[0]) == 'v') *(++Poke) = 'v'; + Replace("ing ","in ",0); + Poke++; + Peek++; + } + LowerAll(); + break; + case 13: // ct + strcpy(Poke, "D --> "); + Poke += 6; + while(*Peek) { + *Poke = *Peek; + Replace("strong","STRONG",0); + Replace("loo","100",0); + Replace("lue ","100 ",0); + Replace("ool","001",0); + if(tolower(Peek[0]) == 'x') *Poke = '%'; + Replace(" cross"," %",0); + Replace(" doublecross"," %%",0); + Poke++; Peek++; + } + // todo: make ool/loo sounds use 001/100 + break; + case 14: // cg + while(*Peek) + *(Poke++) = toupper(*(Peek++)); + break; + case 15: // cc + while(*Peek) { + *Poke = *Peek; + Replace("h", ")(", 0); + Replace("H", ")(", 0); + Replace(":", "38", 0); + if(*Peek == 'E') { + *(Poke++) = '-'; + *Poke = 'E'; + } + Poke++; Peek++; + } + break; + } + *Poke = 0; + + if(Troll[2] != 0) { + char Buffer[768]; + TrollFilter(Buffer, Output, Troll+2); + strcpy(Output, Buffer); + } + + return Output; +} +// http://tibasicdev.wikidot.com/83smfont +void PrintX5Font(char *In, char *Config) { + if(Config==NULL) + Config = "@0001"; + + char NewConfig[20]; + strcpy(NewConfig, Config); + Config = NewConfig; + + int UseReverse = 0, SpecialFG = 0, SpecialBG = 0; + if(!strcasecmp(Config, "r")) { + Config = " ????"; + UseReverse = 1; + } + if(!strcasecmp(Config, "rainbow")) { + SpecialFG = 1; + SpecialBG = 1; + Config = "@0001"; + } + if(strlen(Config) >= 5) { + if(toupper(Config[1])=='R' && toupper(Config[2])=='R') SpecialFG = 1; + if(toupper(Config[3])=='R' && toupper(Config[4])=='R') SpecialBG = 1; + } + + if(NeedSpaceBetweenX5Font) + xchat_commandf(ph, "say "); + unsigned const char Font[96][6] = { + { 0, 0, 0, 0, 0, 1}, /* */ { 1, 1, 1, 0, 1, 1}, /* ! */ { 5, 5, 5, 0, 0, 3}, /* " */ {10, 31, 10, 31, 10, 5}, /* # */ + {14, 20, 14, 5, 30, 5}, /* $ */ { 5, 1, 2, 4, 5, 3}, /* % */ { 4, 10, 4, 10, 5, 4}, /* & */ { 1, 1, 1, 0, 0, 1}, /* ' */ + { 1, 2, 2, 2, 1, 2}, /* ( */ { 2, 1, 1, 1, 2, 2}, /* ) */ { 4, 21, 14, 21, 4, 5}, /* * */ { 0, 2, 7, 2, 0, 3}, /* + */ + { 0, 0, 1, 1, 2, 2}, /* , */ { 0, 0, 7, 0, 0, 3}, /* - */ { 0, 0, 0, 0, 1, 1}, /* . */ { 1, 1, 2, 4, 4, 3}, /* / */ + { 2, 5, 5, 5, 2, 3}, /* 0 */ { 2, 6, 2, 2, 7, 3}, /* 1 */ { 6, 1, 2, 4, 7, 3}, /* 2 */ { 6, 1, 2, 1, 6, 3}, /* 3 */ + { 4, 5, 7, 1, 1, 3}, /* 4 */ { 7, 4, 6, 1, 6, 3}, /* 5 */ { 3, 4, 7, 5, 7, 3}, /* 6 */ { 7, 1, 2, 4, 4, 3}, /* 7 */ + { 7, 5, 7, 5, 7, 3}, /* 8 */ { 7, 5, 7, 1, 6, 3}, /* 9 */ { 0, 1, 0, 1, 0, 1}, /* : */ { 0, 1, 0, 1, 2, 2}, /* ; */ + { 1, 2, 4, 2, 1, 3}, /* < */ { 0, 7, 0, 7, 0, 3}, /* = */ { 4, 2, 1, 2, 4, 3}, /* > */ { 6, 1, 2, 0, 2, 3}, /* ? */ + {14, 1, 13, 21, 14, 5}, /* @ */ { 2, 5, 7, 5, 5, 3}, /* A */ { 6, 5, 6, 5, 6, 3}, /* B */ { 3, 4, 4, 4, 3, 3}, /* C */ + { 6, 5, 5, 5, 6, 3}, /* D */ { 7, 4, 6, 4, 7, 3}, /* E */ { 7, 4, 6, 4, 4, 3}, /* F */ { 3, 4, 5, 5, 3, 3}, /* G */ + { 5, 5, 7, 5, 5, 3}, /* H */ { 7, 2, 2, 2, 7, 3}, /* I */ { 1, 1, 1, 5, 7, 3}, /* J */ { 5, 5, 6, 5, 5, 3}, /* K */ + { 4, 4, 4, 4, 7, 3}, /* L */ { 5, 7, 7, 5, 5, 3}, /* M */ { 6, 5, 5, 5, 5, 3}, /* N */ { 7, 5, 5, 5, 7, 3}, /* O */ + { 6, 5, 6, 4, 4, 3}, /* P */ { 7, 5, 5, 7, 3, 3}, /* Q */ { 6, 5, 6, 5, 5, 3}, /* R */ { 3, 4, 2, 1, 6, 3}, /* S */ + { 7, 2, 2, 2, 2, 3}, /* T */ { 5, 5, 5, 5, 7, 3}, /* U */ { 5, 5, 5, 2, 2, 3}, /* V */ { 5, 5, 5, 7, 5, 3}, /* W */ + { 5, 5, 2, 5, 5, 3}, /* X */ { 5, 5, 2, 2, 2, 3}, /* Y */ { 7, 1, 2, 4, 7, 3}, /* Z */ { 3, 2, 2, 2, 3, 2}, /* [ */ + { 4, 4, 2, 1, 1, 3}, /* \ */ { 3, 1, 1, 1, 3, 2}, /* ] */ { 2, 5, 0, 0, 0, 3}, /* ^ */ { 0, 0, 0, 0, 7, 3}, /* _ */ + { 2, 1, 0, 0, 0, 2}, /* ` */ { 0, 3, 5, 5, 3, 3}, /* a */ { 4, 6, 5, 5, 6, 3}, /* b */ { 0, 3, 4, 4, 3, 3}, /* c */ + { 1, 3, 5, 5, 3, 3}, /* d */ { 0, 2, 5, 6, 3, 3}, /* e */ { 1, 2, 3, 2, 2, 2}, /* f */ { 3, 5, 3, 1, 6, 3}, /* g */ + { 4, 6, 5, 5, 5, 3}, /* h */ { 1, 0, 1, 1, 1, 1}, /* i */ { 1, 0, 1, 5, 2, 3}, /* j */ { 4, 4, 5, 6, 5, 3}, /* k */ + { 3, 1, 1, 1, 1, 2}, /* l */ { 0, 26, 21, 21, 17, 5}, /* m */ { 0, 6, 5, 5, 5, 3}, /* n */ { 0, 2, 5, 5, 2, 3}, /* o */ + { 0, 6, 5, 6, 4, 3}, /* p */ { 0, 3, 5, 3, 1, 3}, /* q */ { 0, 5, 6, 4, 4, 3}, /* r */ { 0, 3, 2, 1, 3, 2}, /* s */ + { 2, 3, 2, 2, 1, 2}, /* t */ { 0, 5, 5, 5, 7, 3}, /* u */ { 0, 5, 5, 2, 2, 3}, /* v */ { 0, 17, 21, 21, 10, 5}, /* w */ + { 0, 5, 2, 2, 5, 3}, /* x */ { 0, 5, 5, 2, 4, 3}, /* y */ { 0, 15, 2, 4, 15, 4}, /* z */ { 3, 2, 4, 2, 3, 3}, /* { */ + { 1, 1, 1, 1, 1, 1}, /* | */ { 6, 2, 1, 2, 6, 3}, /* } */ { 0, 5, 10, 0, 0, 4}, /* ~ */ + }; + int Row; char *Peek; + + for(Row = 0; Row<5; Row++) { + char RowBuffer[512]; + *RowBuffer = 0; + char *Poke = RowBuffer; + + for(Peek = In; *Peek; Peek++) { + int Char = *Peek; + if(Char > '~' || Char < ' ') Char = '?'; + char FontBits = Font[Char-0x20][Row]; + char Column; char Width = Font[Char-0x20][5]; + for(Column=0;Column>(Width-Column))&1)?'@':' '; + } + *(Poke++) = ' '; + *Poke=0; + + char ColorBuffer[512]; + strcpy(ColorBuffer, ""); + Poke = ColorBuffer; + + if(!UseReverse) { + *(Poke++) = 0x03; *(Poke++) = Config[3]; + *(Poke++) = Config[4]; *(Poke++) = ','; + *(Poke++) = Config[3]; *(Poke++) = Config[4]; + } + + for(Peek = RowBuffer; *Peek; Peek++) { + if(SpecialFG == 1) { + int x = rand2(5); + NewConfig[1] = Rainbow[x][0]; + NewConfig[2] = Rainbow[x][1]; + } + if(SpecialBG == 1) { + int x = rand2(5); + NewConfig[2] = Rainbow[x][0]; + NewConfig[3] = Rainbow[x][1]; + } + + if(!UseReverse&&(Peek==RowBuffer || Peek[-1]!=Peek[0] || SpecialFG==1)) { + if(*Peek == '@') { + *(Poke++) = 0x03; *(Poke++) = Config[1]; + *(Poke++) = Config[2]; *(Poke++) = ','; + *(Poke++) = Config[1]; *(Poke++) = Config[2]; + } else { + *(Poke++) = 0x03; *(Poke++) = Config[3]; + *(Poke++) = Config[4]; *(Poke++) = ','; + *(Poke++) = Config[3]; *(Poke++) = Config[4]; + } + } + if(UseReverse && Peek!=RowBuffer && Peek[-1]!=Peek[0]) { + *(Poke++) = 0x16; + } + + *(Poke++) = Config[0]; + } + + *Poke=0; + xchat_commandf(ph, "say %s", ColorBuffer); + } + NeedSpaceBetweenX5Font=1; +} + +void Print35Font(char *In, char *Config) { + if(Config==NULL) + Config = "@0001"; + int i; + unsigned const short Font[256] = { + ['0']=075557, ['1']=022222, ['2']=074216, ['3']=071717, + ['4']=011755, ['5']=061747, ['6']=075747, ['7']=044217, + ['8']=075757, ['9']=071757, ['!']=020222, ['?']=020317, + ['A']=055752, ['B']=065656, ['C']=034443, ['D']=065556, + ['E']=074747, ['F']=044747, ['G']=035543, ['H']=055755, + ['I']=072227, ['J']=075111, ['K']=055655, ['L']=074444, + ['M']=055775, ['N']=055556, ['O']=075557, ['P']=044757, + ['Q']=036552, ['R']=055656, ['S']=071747, ['T']=022227, + ['U']=075555, ['V']=025555, ['W']=057555, ['X']=055255, + ['Y']=022755, ['Z']=074217, [' ']=000000, + ['^']=000052, ['-']=000700, ['+']=002720, ['=']=007070, + ['.']=022000, [',']=062000, ['_']=070000, ['/']=042221, + [':']=002020, [';']=062020, ['<']=012421, ['>']=042124, + ['\\']=012224, ['\"']=000055, ['\'']=000022, ['\2']=077777, + }; + if(NeedSpaceBetweenX5Font) + xchat_commandf(ph, "say "); + int Row; char *Peek; + int ColorType[2]={0,0}; + for(i=0;i<2;i++) { + if(toupper(Config[(i<<1)+1])=='R' && toupper(Config[(i<<1)+2])=='B') ColorType[i] = 1; // horiz rainbow + if(toupper(Config[(i<<1)+1])=='R' && toupper(Config[(i<<1)+2])=='H') ColorType[i] = 1; // horiz rainbow + if(toupper(Config[(i<<1)+1])=='R' && toupper(Config[(i<<1)+2])=='V') ColorType[i] = 2; // vert rainbow + } + + for(Row = 0; Row<5; Row++) { + unsigned short ShiftBy = Row*3; + unsigned short AndBy = 0x7<>ShiftBy; + char Column; + for(Column=0;Column<3;Column++) + *(Poke++) = ((FontBits<<=1)&8?'@':' '); + *(Poke++) = ' '; + } + *Poke=0; + + char ColorBuffer[512]; + strcpy(ColorBuffer, ""); + Poke = ColorBuffer; + + int Index = 0; + + if(ColorType[1] != 0) + memcpy(Config+(2)+1,Rainbow[Row%5],sizeof(char)*2); + //memcpy(Config+(2)+1,"00",sizeof(char)*2); + + *(Poke++) = 0x03; *(Poke++) = Config[3]; + *(Poke++) = Config[4]; *(Poke++) = ','; + *(Poke++) = Config[3]; *(Poke++) = Config[4]; + *(Poke++) = Config[0]; + + + for(Peek = RowBuffer; *Peek; Peek++) { + for(i=0;i<2;i++) { + switch(ColorType[i]) { + case 1: + if(0==(Index&3)) + memcpy(Config+(i<<1)+1,Rainbow[(Index/4)%5],sizeof(char)*2); + break; + case 2: + memcpy(Config+(i<<1)+1,Rainbow[Row%5],sizeof(char)*2); + break; + } + } + Index++; + + if(Peek==RowBuffer || Peek[-1]!=Peek[0]) { + if(*Peek == '@') { + *(Poke++) = 0x03; *(Poke++) = Config[1]; + *(Poke++) = Config[2]; *(Poke++) = ','; + *(Poke++) = Config[1]; *(Poke++) = Config[2]; + } else { + *(Poke++) = 0x03; *(Poke++) = Config[3]; + *(Poke++) = Config[4]; *(Poke++) = ','; + *(Poke++) = Config[3]; *(Poke++) = Config[4]; + } + } + *(Poke++) = Config[0]; + } + + *Poke=0; + xchat_commandf(ph, "say %s", ColorBuffer); + } + NeedSpaceBetweenX5Font=1; +} + +char *AcidText(char *NewString, char *Input) { + char *Poke = NewString, *Peek, *StartHere = Input; + *(Poke++) = 2; + + int ColorFrequency = 7; + if(strlen(Input) > 100) ColorFrequency = 15; + if(strlen(Input) > 200) ColorFrequency = 31; + if(strlen(Input) > 300) ColorFrequency = -1; + + for(Peek = StartHere;*Peek;Peek++) { + if(Peek == StartHere || (isgraph(*Peek) && (ColorFrequency!=-1) && ((rand()&ColorFrequency) == 0))) { + int Color1 = rand()&15; + while(Color1 == 1 || Color1 == 14 || Color1 == 0) + Color1 = rand()&15; + char ColorString[10]; + *(Poke++) = 3; + sprintf(ColorString, "%.2i", Color1); + *(Poke++) = ColorString[0]; + *(Poke++) = ColorString[1]; + if(Peek == StartHere) { + *(Poke++) = ','; + *(Poke++) = '0'; + *(Poke++) = '1'; + } + } + if((rand()&7) == 0) + *(Poke++) = 0x1f; + char k = *Peek; + *(Poke++) = (rand()&1)?toupper(k):tolower(k); + } + *Poke = 0; + return NewString; +} + +// Used for /spark slashf +static char *sparkles_text_unescape(char *Poke, char *Peek) { +// Takes a string given, and interprets \n and friends + char *End = Peek+strlen(Peek); + while(*Peek != 0 && (Peek < End)) { + // (Peek Note the "and then" + "and then" + is that the best you can come up with? + yes + you should have a whole bunch of conjoining strings + so that it's not like + "and then... and then... and then... and then" + maybe + "next... then... thenceforth... finally..." +*/ + assmunch = rand2(MaxYiffScript); // pick a new yiff action +} + sprintf(CommandBuf, "%s %s", ChainBuffer, Emoticon); // append a smiley + + if(BillyMaysMode==1 || !strcasecmp(Victim,"Billy Mays") || !strcasecmp(Victim,"BillyMays")) { + for(i=0;CommandBuf[i];i++) + CommandBuf[i]=toupper(CommandBuf[i]); + } + if(BillyMaysMode==2) { + for(i=0;CommandBuf[i];i++) + if(i&1) + CommandBuf[i]=toupper(CommandBuf[i]); + else + CommandBuf[i]=tolower(CommandBuf[i]); + } + if(BillyMaysMode==3) { + for(i=0;CommandBuf[i];i++) + if(rand()&1) + CommandBuf[i]=toupper(CommandBuf[i]); + else + CommandBuf[i]=tolower(CommandBuf[i]); + } + if(Rainbows) { + int j; + char *Poke = ChainBuffer; + for(i=0,j=0;CommandBuf[i];i++) { + if(isgraph(CommandBuf[i]) && !(i&3)) { + *(Poke++) = 0x03; + *(Poke++) = Rainbow[j][0]; + *(Poke++) = Rainbow[j++][1]; + if(j == 5) j = 0; + } + *(Poke++) = CommandBuf[i]; + } + *Poke = 0; + strcpy(CommandBuf,ChainBuffer); + } + + LastYiff=assmunch; + + if(ShuffleLevel > 0) { + ShuffleChars(ChainBuffer, CommandBuf, ShuffleLevel,0); + strcpy(CommandBuf, ChainBuffer); + } + + if(HSTroll == NULL) + xchat_commandf(ph, "%s %s", ReplyWith, CommandBuf); + else { + xchat_commandf(ph, "me %s", TrollFilter(ChainBuffer, CommandBuf, HSTroll)); + } + return XCHAT_EAT_ALL; /* eat this command so xchat and other plugins can't process it */ +} +#endif + +static int Activity2Focus_cb(char *word[], void *userdata) { + NeedSpaceBetweenX5Font = 0; + if(Activity2Focus) + xchat_command(ph,"gui focus"); + return XCHAT_EAT_NONE; +} +static int RawServer_cb(char *word[], char *word_eol[], void *userdata) { + if(GrabbingTopic) { + if(!strcasecmp(word[2],"332")) { + char *Copy = word_eol[5]; + if(*Copy == ':') Copy++; + xchat_commandf(ph, "settext /topic %s", Copy); + xchat_commandf(ph, "setcursor 7"); + GrabbingTopic = 0; + return XCHAT_EAT_ALL; + } + } + + if(DisablePlusJFix || !RejoinKick) + return XCHAT_EAT_NONE; + if(!strcasecmp(word[2],"495")) { // "can't join, because +J" + char *Channel = word[4]; + if(NULL!=strstr(word_eol[6], "after being kicked to rejoin")) { + char *N = strstr(word_eol[6], "must wait "); + if(N != NULL) { + int Seconds = strtol(N+10,NULL,10); + xchat_commandf(ph,"spark spawnquiet %i.4 s join %s", Seconds, Channel); + } + } + } +//>> :kuroi.irc.nolimitzone.com 495 NovaYoshi #acmlm :You must wait 10 seconds after being kicked to rejoin (+J) + return XCHAT_EAT_NONE; +} + +static const char *SafeGet(const char *Orig, char *Substitute) { +// For functions that freak out when given NULL instead of a string + if(Orig != NULL) return(Orig); + if(Substitute != NULL) return(Substitute); + return("(null)"); +} + +static char *Backwords(const char *Inp, char *Out) { + int i, temp, Len; char *Seek = Out, *Fix; + + for(i=strlen(Inp)-1;i!=-1;i--) + *(Seek++) = Inp[i]; + *Seek = 0; + + for(Seek = Out;;Seek++) { + if((Seek!=Out) && ((*Seek == ' '||!*Seek) && Seek[-1]!=' ')) { + for(Fix = Seek;Fix != Out && Fix[-1] != ' ';Fix--); + if(NULL!=strchr(Fix, ' ')) Len = strchr(Fix, ' ') - Fix; + else Len = strlen(Fix); + for(i=0;i<=(Len>>1)-1;i++) { + temp = Fix[i]; + Fix[i] = Fix[Len-1-i]; + Fix[Len-1-i] = temp; + } + } + if(!*Seek) + break; + } + return Out; +} + +static int WhatNetwork_cb(char *word[], void *userdata) { +// Just in case filenames get damaged, I can still see from my logs what network they're from + if(DisableShowNetworkOnJoin) return XCHAT_EAT_NONE; + xchat_printf(ph,"( Network is \"%s\" , \"%s\" )\n", //SparklesUser, + SafeGet(xchat_get_info(ph, "network"),"Not found"), + SafeGet(xchat_get_info(ph, "server"),NULL)); + return XCHAT_EAT_NONE; +} + +static int TrapActionPost_cb(char *word[], char *word_eol[], void *userdata) { + if(UseOneSayHook) { + if(MeHook != NULL) + xchat_unhook(ph, MeHook); + xchat_commandf(ph, "%s %s", OneSayHook, word_eol[2]); + MeHook = xchat_hook_command(ph, "me", XCHAT_PRI_NORM, TrapActionPost_cb, NULL, 0); + return XCHAT_EAT_ALL; + } + if(strcasecmp(MeHookCommand,"")) { + if(MeHook != NULL) + xchat_unhook(ph, MeHook); + xchat_commandf(ph, "%s %s", MeHookCommand, word_eol[2]); + MeHook = xchat_hook_command(ph, "me", XCHAT_PRI_NORM, TrapActionPost_cb, NULL, 0); + return XCHAT_EAT_ALL; + } + if(IsPesterchum() && !DisablePesterchum) { + xchat_commandf(ph, "spark normalsay /me %s", word_eol[2]); + return XCHAT_EAT_ALL; + } + return XCHAT_EAT_NONE; +} + +static int TrapNormalPost_cb(char *word[], char *word_eol[], void *userdata) { + if(UseOneSayHook) { + if(SayHook != NULL) + xchat_unhook(ph, SayHook); + xchat_commandf(ph, "%s %s", OneSayHook, word_eol[1]); + SayHook = xchat_hook_command(ph, "", XCHAT_PRI_NORM, TrapNormalPost_cb, NULL, 0); + return XCHAT_EAT_ALL; + } + else if(CmdStackPtr != NULL) { + char Buffer[512]; + strcpy(Buffer, CmdStackPtr); + char *A = strstr(Buffer, "||"); + if(A) { + *A = 0; + CmdStackPtr=A+2; + char *OldPtr = CmdStackPtr; + xchat_commandf(ph, "%s %s", Buffer, word_eol[1]); + if(OldPtr == CmdStackPtr) { + xchat_printf(ph, "\"%s\" in cmdstack did not result in /say", Buffer); + CmdStackPtr = NULL; + } + return XCHAT_EAT_ALL; + } + else { + CmdStackPtr=NULL; + xchat_commandf(ph, "%s %s", Buffer, word_eol[1]); + return XCHAT_EAT_ALL; + } + } + else { + if(IsPesterchum() && IsChannel() && *PesterchumChanHook && !DisablePesterchum) { + if(SayHook != NULL) + xchat_unhook(ph, SayHook); + xchat_commandf(ph, "%s %s", PesterchumChanHook, word_eol[1]); + SayHook = xchat_hook_command(ph, "", XCHAT_PRI_NORM, TrapNormalPost_cb, NULL, 0); + return XCHAT_EAT_ALL; + } + if(strcasecmp(SayHookCommand,"")) { + if(SayHook != NULL) + xchat_unhook(ph, SayHook); + if(SayHookSpace) + xchat_commandf(ph, "%s %s", SayHookCommand, word_eol[1]); + else + xchat_commandf(ph, "%s%s", SayHookCommand, word_eol[1]); + SayHook = xchat_hook_command(ph, "", XCHAT_PRI_NORM, TrapNormalPost_cb, NULL, 0); + return XCHAT_EAT_ALL; + } + return XCHAT_EAT_NONE; + } + return XCHAT_EAT_NONE; +} +// :snowleopard.anthrochat.net 322 NovaYoshi #purrfection 11 :[+ntr] +static int AsyncExec(char *Command) { +//shamelessy taken from hexchat's exec plugin +#ifdef _WIN32 + STARTUPINFO sInfo; + PROCESS_INFORMATION pInfo; + ZeroMemory(&sInfo, sizeof (sInfo)); + ZeroMemory(&pInfo, sizeof (pInfo)); + sInfo.cb = sizeof(sInfo); + sInfo.dwFlags = STARTF_USESTDHANDLES; + sInfo.hStdInput = NULL; + sInfo.hStdOutput = NULL; + sInfo.hStdError = NULL; + char commandLine[1024]; + sprintf(commandLine, "cmd.exe /c %s", Command); + CreateProcess(0, commandLine, 0, 0, TRUE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, 0, 0, &sInfo, &pInfo); + return 1; +#else + xchat_printf(ph,"AsyncExec() not ported to non-Windows platforms yet\n"); + return 0; +#endif +} +static int Spark_cb(char *word[], char *word_eol[], void *userdata) { + char Buffer[2048]; int i=0, j=0, k=0; + if(!strcasecmp(word[2],"sprintf") || !strcasecmp(word[2],"slashf")) { + if(word[3] != NULL) { + sparkles_text_unescape(Buffer, word_eol[3]); + xchat_commandf(ph,"%s", Buffer); + } + } + if(!strcasecmp(word[2],"brokecp")) { // intended to get around a Silverex bug. + if(word[3] != NULL) { // obsolete because I use XChat-WDK now. + FILE *Broke = fopen("C:\\dodongo\\broke.txt","a"); // change for your situation + if(Broke != NULL) { + fprintf(Broke, "%s\n",word_eol[3]); + fclose(Broke); + xchat_commandf(ph,"exec C:\\dodongo\\brokens.bat"); // also this + } + } + } + + if(!strcasecmp(word[2],"crami")) // cram into the input box + xchat_commandf(ph, "spark onesayhook settext cram %s", word_eol[3]); + + if(!strcasecmp(word[2],"cram")) { // cram multiple posts into one + int Mode = word[3]!=NULL && !strcasecmp(word[3],"noslash"); + const char *Peek = xchat_get_info(ph, "inputbox"); + char *Poke = Buffer; + const char *End = Peek+strlen(Peek); + while(*Peek) { + i = *(Peek++); + if(Mode==0 && (i=='\n' || i=='\r')) { + *(Poke++) = ' '; + *(Poke++) = '\\'; + i=' '; + while(*Peek == '\n' || *Peek == '\r' || *Peek == ' ') + Peek++; + } + if(Mode==1 && (i=='\n' || i=='\r')) { + while(*Peek == '\n' || *Peek == '\r' || *Peek == ' ') + Peek++; + if(Peek > End) break; + continue; + } + *(Poke++) = i; + if(Peek > End) break; + } + *Poke = 0; + xchat_commandf(ph, "say %s\n", Buffer); + } + + if(!strcasecmp(word[2],"mathaddi")) { + for(i=3;*word[i];i++) + j+=strtol(word[i], NULL, 10); + xchat_commandf(ph, "settext %i", j); + } + + if(!strcasecmp(word[2],"mathmuli")) { + j=1; + for(i=3;*word[i];i++) + j*=strtol(word[i], NULL, 10); + xchat_commandf(ph, "settext %i", j); + } + + if(!strcasecmp(word[2],"set")) + INIConfigHandler(word[3], word[4], word_eol[5]); + if(!strcasecmp(word[2],"rehash")) { + sprintf(Buffer, ConfigFilePath, xchat_get_info(ph, "xchatdirfs")); + ParseINI(fopen(Buffer,"rb"), INIConfigHandler); + } + if(!strcasecmp(word[2],"editconfig")) + xchat_commandf(ph,"spark aexec %s %s\n", TextEditor, ConfigFilePath); + + if(!strcasecmp(word[2],"aexec")||!strcasecmp(word[2],"asyncexec")) + AsyncExec(word_eol[3]); + if(!strcasecmp(word[2],"openlogs")) { + const char *Chan = xchat_get_info(ph, "channel"); + const char *Network = xchat_get_info(ph, "network"); + if(strcasecmp(word[3],"")) { + Chan = word[3]; + if(strcasecmp(word[4],"")) Network = word[4]; + } + #ifdef HEXCHAT_PLUGIN_H + sprintf(Buffer, "%s/logs/%s-%s.log", xchat_get_info(ph, "xchatdirfs"), Network, Chan); + #else + sprintf(Buffer, "%s/xchatlogs/%s-%s.log", xchat_get_info(ph, "xchatdirfs"), Network, Chan); + #endif + xchat_commandf(ph,"spark aexec %s %s\n", TextEditor, Buffer); + // todo: actually care what irc_logmask is but for now it is %n-%c.log + } + + if(!strcasecmp(word[2],"repeatstring")) { + *Buffer = 0; + j = strtol(word[3],NULL,10); + for(i=0;i%s: %s", PesterchumColor, Buffer, word_eol[3]); + } + if(!strcasecmp(word[2],"pestercolor")) + strcpy(PesterchumColor, word_eol[3]); + + if(!strcasecmp(word[2],"pesterchanhook")) + strcpy(PesterchumChanHook, word_eol[3]); + + if(!strcasecmp(word[2],"sayhook") || !strcasecmp(word[2],"sayhooknospace")) { + SayHookSpace = 1; + if(!strcasecmp(word[2],"sayhooknospace")) + SayHookSpace = 0; + if(word_eol[3]!=NULL) { + if(!strcasecmp(word[3],"unhook")) { + if(SayHook != NULL) { + xchat_unhook(ph, SayHook); + SayHook = NULL; + xchat_printf(ph, "%sSay unhooked\n",SparklesUser); + } + else + xchat_printf(ph, "%sSay was already unhooked",SparklesUser); + } + else if(!strcasecmp(word[3],"hook")) { + if(SayHook == NULL) { + SayHook = xchat_hook_command(ph, "", XCHAT_PRI_NORM, TrapNormalPost_cb, NULL, 0); + xchat_printf(ph, "%sSay hooked\n",SparklesUser); + } + else + xchat_printf(ph, "%sSay was already hooked",SparklesUser); + } + else if(!strcasecmp(word[3],"off")) { + strcpy(SayHookCommand,""); + xchat_printf(ph, "%sSparkles will now leave /say ALONE (but the hook wasn't changed)\n",SparklesUser); + } + else { + strcpy(SayHookCommand,word_eol[3]); + xchat_printf(ph, "%s%ssay will now be interpreted as /%s\n", SparklesUser, CommandPrefix, SayHookCommand); + if(SayHook == NULL) { + SayHook = xchat_hook_command(ph, "", XCHAT_PRI_NORM, TrapNormalPost_cb, NULL, 0); + xchat_printf(ph, "%sand /say was hooked again\n", SparklesUser); + } + + } + } + } + + if(!strcasecmp(word[2],"mehook")) { + if(word_eol[3]!=NULL) { + if(!strcasecmp(word[3],"off")) { + strcpy(MeHookCommand,""); + xchat_printf(ph, "%sSparkles will now leave /me ALONE\n",SparklesUser); + } + else { + strcpy(MeHookCommand,word_eol[3]); + xchat_printf(ph, "%s%sme will now be interpreted as /%s\n", SparklesUser, CommandPrefix, MeHookCommand); + } + } + } + + if(!strcasecmp(word[2],"thou")) { + const char *Word1[] = {"artless", "bawdy", "beslubbering", "bootless", "churlish", "cockered", "clouted", "craven", "currish", "dankish", "dissembling", "droning", "errant", "fawning", "fobbing", "froward", "frothy", "gleeking", "goatish", "gorbellied", "impertinent", "infectious", "jarring", "loggerheaded", "lumpish", "mammering", "mangled", "mewling", "paunchy", "pribbling", "puking", "puny", "qualling", "rank", "reeky", "roguish", "ruttish", "saucy", "spleeny", "spongy", "surly", "tottering", "unmuzzled", "vain", "venomed", "villainous", "warped", "wayward", "weedy", "yeasty",NULL}; + const char *Word2[] = {"base-courted", "bat-fowling", "beef-witted", "beetle-headed", "boil-brained", "clapper-clawed", "clay-brained", "common-kissing", "crook-pated", "dismal-dreaming", "dizzy-eyed", "doghearted", "dread-bolted", "earth-vexing", "elf-skinned", "fat-kidneyed", "fen-sucked", "flap-mouthed", "fly-bitten", "folly-fallen", "fool-born", "full-gorged", "guts-griping", "half-faced", "hasty-witted", "hedge-born", "hell-hated", "idle-headed", "ill-breeding", "ill-nurtured", "knotty-pated", "milk-livered", "motley-minded", "onion-eyed", "plume-plucked", "pottle-deep", "pox-marked", "reeling-ripe", "rough-hen", "rude-growing", "rump-fed", "sheep-biting", "spur-galled", "swag-bellied", "tardy-gaited", "tickle-brained", "toad-spotted", "urchin-snouted", "weather-bitten",NULL}; + const char *Word3[] = {"apple-john", "baggage", "barnacle", "bladder", "boar-pig", "bugbear", "bum-bailey", "canker-blossom", "clack-dick", "clotpole", "coxcomb", "codpiece", "death-token", "dewberry", "flap-dragon", "flax-wench", "flirt-gill", "foot-licker", "fustilarian", "giglet", "gudgeon", "haggard", "harpy", "hedge-pig", "horn-beast", "hugger-bugger", "joithead", "lewdster", "lout", "maggot-pie", "malt-worm", "mammet", "measle", "minnow", "miscreant", "moldwarp", "mumble-news", "nut-hook", "pigeon-egg", "pignut", "puttock", "pumpion", "ratsbane", "scut", "skainsmate", "strumpet", "varlot", "vassal", "wheyface", "wagtail",NULL}; + int Word1L=0, Word2L=0, Word3L=0; + while(Word1[Word1L] != NULL) Word1L++; + while(Word2[Word2L] != NULL) Word2L++; + while(Word2[Word3L] != NULL) Word3L++; + if(strcasecmp(word[3],"")&&strlen(word[3])) + xchat_commandf(ph, "say %s, thou %s %s %s!", word[3], Word1[rand2(Word1L)], Word2[rand2(Word2L)], Word3[rand2(Word3L)]); + else + xchat_commandf(ph, "say Thou %s %s %s!", Word1[rand2(Word1L)], Word2[rand2(Word2L)], Word3[rand2(Word3L)]); + } + + if(!strcasecmp(word[2],"rot13")) { + strcpy(Buffer,word_eol[3]); + char offset; + for(i=0;Buffer[i];i++) { + if(!isalpha(Buffer[i])) + continue; + if(islower(Buffer[i])) + offset = 'a'; + else + offset = 'A'; + if(Buffer[i] - offset < 13) + Buffer[i] += 13; + else + Buffer[i] -= 13; + } + xchat_commandf(ph, "say %s", Buffer); + } + + if(!strcasecmp(word[2],"cmdstack") || !strcasecmp(word[2],"pipe")) { + strcpy(CmdStackText, word[3]); + CmdStackPtr = CmdStackText; + strcpy(Buffer, CmdStackText); + char *A = strstr(Buffer, "||"); + if(A) { + *A = 0; + CmdStackPtr=A+2; + xchat_commandf(ph, "%s %s", Buffer, word_eol[4]); + } + } + + if(!strcasecmp(word[2],"multicmd")) { + char *Ptr = word[3]; + while(1) { + strcpy(Buffer, Ptr); + char *A = strstr(Buffer, "||"); + if(A) { + *A = 0; + Ptr=A+2; + xchat_commandf(ph, "%s", Buffer); + } + else { + xchat_commandf(ph, "%s", Buffer); + break; + } + } + } + + if(!strcasecmp(word[2],"SparkEncrypt1")) { + unsigned char Key1 = rand()&255; + unsigned char kA = (Key1 & 192) >> 6; +// unsigned char kB = (Key1 & 48) >> 4; + unsigned char kC = (Key1 & 15); + char TinyBuf[128]; + sprintf(TinyBuf,"%s\3%.2d\3%.2d\3%.2d\xf",SparkEncryptPrefix, + Key1&15, (Key1&0xf0)>>4, 0&15); + strcpy(Buffer,TinyBuf); + + char *Poke = Buffer+strlen(TinyBuf); + char *Peek = word_eol[3]; + + while(*Peek) { + char c = *(Peek++); + char nyb = c &15; + c&=~0x0f; + if(c>=0x20) { + switch(kA) { + case 0: nyb ^=15; + case 1: nyb +=kC; break; + case 2: nyb ^=15; + case 3: nyb -=kC; break; + } + } + c|=(nyb&15); + *(Poke++) = c; + } + *Poke = 0; + if(NULL != strstr(Buffer, word_eol[3])) + xchat_commandf(ph,"spark sparkencrypt1 %s", word_eol[3]); + else { +// xchat_printf(ph,"(SE1 %2i %2i)-\t%s\n", kA, kC, word_eol[3]); + xchat_printf(ph,"(SE1)-\t%s\n", word_eol[3]); + xchat_commandf(ph,"say %s", Buffer); + } + } + + if(!strcasecmp(word[2],"2sprintf") || !strcasecmp(word[2],"2slashf") || !strcasecmp(word[2],"2slashfi")) { + char TinyBuf[32]; + char *Poke = Buffer; + char *Peek = word_eol[3]; + char c; + while(*Peek) { + c = *(Poke++) = *(Peek++); + switch(c) { + case 0x1f: Poke--; *(Poke++) = '\\'; *(Poke++) = 'u'; break; + case 0x02: Poke--; *(Poke++) = '\\'; *(Poke++) = 'b'; break; + case 0x03: Poke--; *(Poke++) = '\\'; *(Poke++) = 'c'; break; + case 0x16: Poke--; *(Poke++) = '\\'; *(Poke++) = 'i'; break; + case 0x0f: Poke--; *(Poke++) = '\\'; *(Poke++) = 'p'; break; + case 0x07: Poke--; *(Poke++) = '\\'; *(Poke++) = 'a'; break; + case '\\': *(Poke++) = '\\'; break; + default: + if(!(isgraph(c)||c==' ')) { + *(--Poke) = 0; + sprintf(TinyBuf, "\\x%x ", c); + strcat(Buffer, TinyBuf); + Poke+=strlen(TinyBuf); + } + break; + } + } + *Poke = 0; + if(strcasecmp(word[2],"2slashfi")) + xchat_printf(ph, "%s%sspark slashfs %s\n", SparklesUser, CommandPrefix, Buffer); + else { + xchat_commandf(ph, "settext /spark slashfs %s", Buffer); + xchat_commandf(ph, "setcursor 15"); + } + } + + if(!strcasecmp(word[2],"atloop")) { // atloop [format] [action] [text] + if(!AttributeLoop(Buffer, word_eol[5], word[3])) { + xchat_commandf(ph, "%s %s", word[4], Buffer); + } else { + xchat_printf(ph, "%sBad attribute loop?\n",SparklesUser); + } + } + if(!strcasecmp(word[2],"atloops")) + xchat_commandf(ph,"spark atloop %s say %s", SafeGet(word[3],""), SafeGet(word_eol[4],"")); + if(!strcasecmp(word[2],"atloopm")) + xchat_commandf(ph,"spark atloop %s me %s", SafeGet(word[3],""), SafeGet(word_eol[4],"")); + if(!strcasecmp(word[2],"atloopi")) + xchat_commandf(ph,"spark atloop %s settext %s", SafeGet(word[3],""), SafeGet(word_eol[4],"")); + if(!strcasecmp(word[2],"unsettab")) + xchat_commandf(ph,"settab %s", SafeGet(xchat_get_info(ph, "channel"),"")); + + + if(!strcasecmp(word[2],"backwards")) { + char *Poke = Buffer; + for(i=strlen(word_eol[3])-1;i!=-1;i--) + *(Poke++) = word_eol[3][i]; + *Poke = 0; + xchat_commandf(ph, "say %s", Buffer); + } + if(!strcasecmp(word[2],"backwords")) { + Backwords(word_eol[3], Buffer); + xchat_commandf(ph, "say %s", Buffer); + } + + if(!strcasecmp(word[2],"grabtopic")) { + GrabbingTopic = 1; + xchat_commandf(ph, "topic"); + } + + if(!strcasecmp(word[2],"spawn") || !strcasecmp(word[2],"spawnquiet")) { + // /spark(1) spawn(2) X(3) units(4) Command(5) + int Slot; + if(!strcasecmp(word[3],"clear")) { + for(Slot=0;Slot<16;Slot++) + if(SpawnHook[Slot]!=NULL) { + struct SpawnInfo *FreeMe = xchat_unhook(ph, SpawnHook[Slot]); + if(FreeMe != NULL) + free(FreeMe); + SpawnHook[Slot]=NULL; + } + if(strcasecmp(word[2],"spawnquiet")) + xchat_printf(ph, "%sSpawn list cleared",SparklesUser); + } else { + double Time = strtod(word[3], NULL); + switch(word[4][0]) { + case 'd': + Time*=24; + case 'h': + Time*=60; + case 'm': + Time*=60; + case 's': + Time*=1000; + break; + } + + struct SpawnInfo *Spawn = (struct SpawnInfo*)malloc(sizeof(struct SpawnInfo)); + int SpawnUsed = 0; + for(Slot = 0; Slot<64; Slot++) + if(SpawnHook[Slot] == NULL) + if(Spawn != NULL) { + if(strcasecmp(word[2],"spawnquiet")) + xchat_printf(ph,"%sTimer started! (%f seconds) \n", SparklesUser, Time/1000); + strcpy(Spawn->Command, word_eol[5]); + Spawn->Context = xchat_get_context(ph); + Spawn->Slot = Slot; + SpawnHook[Slot] = xchat_hook_timer(ph, Time, spawntimer_cb, Spawn); + SpawnUsed = 1; + break; + } + if(!SpawnUsed) + free(Spawn); + } + } + + if(!strcasecmp(word[2],"rainbow") || !strcasecmp(word[2],"rainbowt")) { + char *Poke = Buffer; + for(i=0,j=0;word_eol[3][i];i++) { + if(isgraph(word_eol[3][i])) { + *(Poke++) = 0x03; + *(Poke++) = Rainbow[j][0]; + *(Poke++) = Rainbow[j++][1]; + if(j == 5) j = 0; + } + *(Poke++) = word_eol[3][i]; + } + if(strcasecmp(word[2],"rainbowt")) + *Poke = 0; + else { + *(Poke++) = 0x0f; + *Poke = 0; + } + xchat_commandf(ph, "say %s", Buffer); + } + if(!strcasecmp(word[2],"hstroll")) + xchat_commandf(ph, "say %s", TrollFilter(Buffer, word_eol[4], word[3])); + if(!strcasecmp(word[2],"scarletsay")) + xchat_commandf(ph, "say %s", ScarletFilter(Buffer, word_eol[3])); + if(!strcasecmp(word[2],"sellysay")) + xchat_commandf(ph, "say %s", SellyFilter(Buffer, word_eol[3], 0)); + if(!strcasecmp(word[2],"sellysay2")) + xchat_commandf(ph, "say %s", SellyFilter(Buffer, word_eol[3], 1)); + if(!strcasecmp(word[2],"replwords")) + xchat_commandf(ph, "say %s", CustomReplace(Buffer, word_eol[4], word[3])); + + if(!strcasecmp(word[2],"replchars") || !strcasecmp(word[2],"replcharsi") || !strcasecmp(word[2],"replcharsim")) { + if(strlen(word[3])&1) { + xchat_printf(ph, "A replchars character replace list's length must be an even number\n"); + return XCHAT_EAT_ALL; + } + int CaseSensitive = !strcasecmp(word[2],"replchars"); + int MatchCase = !strcasecmp(word[2],"replcharsim"); + + strcpy(Buffer, word_eol[4]); + char *Poke = Buffer; + while(*Poke) { + char old = *Poke; + char *RList = word[3]; + while(*RList) { + if(old == *RList) + *Poke = RList[1]; + else if(!CaseSensitive && toupper(old) == toupper(*RList)) { + if(!MatchCase || !isalpha(old)) + *Poke = RList[1]; + else + *Poke = isupper(old)?toupper(RList[1]):tolower(RList[1]); + } + + RList++; + } + Poke++; + } + if(!strcasecmp(word[2],"replcharsi") || !strcasecmp(word[2],"replcharsim")) + xchat_commandf(ph, "settext %s", Buffer); + else + xchat_commandf(ph, "say %s", Buffer); + } + + if(!strcasecmp(word[2],"onesayhook") || !strcasecmp(word[2],"me2cmd") || !strcasecmp(word[2],"say2cmd")) { + strcpy(OneSayHook, word[3]); + UseOneSayHook = 1; + xchat_command(ph, word_eol[4]); + UseOneSayHook = 0; + } + + if(!strcasecmp(word[2],"me2say")) { + strcpy(OneSayHook, "say"); + UseOneSayHook = 1; + xchat_command(ph, word_eol[3]); + UseOneSayHook = 0; + } + + if(!strcasecmp(word[2],"hideset")) + xchat_commandf(ph, "spark hidecmd set %s"); + + if(!strcasecmp(word[2],"hidecmd")) { + xchat_context *Old = xchat_get_context(ph); + xchat_command(ph, "query $"); + xchat_context *New = xchat_find_context(ph, NULL, "$"); + if(New != NULL) + if(xchat_set_context(ph, New)) { + xchat_command(ph, word_eol[3]); + xchat_command(ph, "close"); + xchat_set_context(ph, Old); + xchat_command(ph, "gui focus"); + } + } + + if(!strcasecmp(word[2],"space2newline")) { + char *Ptr = word_eol[3]; + while(1) { + strcpy(Buffer, Ptr); + char *A = strstr(Buffer, " "); + if(A) { + *A = 0; + Ptr=A+1; + xchat_commandf(ph, "say %s", Buffer); + } + else { + xchat_commandf(ph, "say %s", Buffer); + break; + } + } + } + + if(!strcasecmp(word[2],"repeatcmd")) { // /spark repeatcmd times command + int i, Times=strtol(word[3],NULL,10); + char *Cmd = word_eol[4]; + if(isdigit(word[4][0])) { + Cmd = word_eol[5]; + xchat_commandf(ph, "%s", Cmd); + if(Times>1) + xchat_commandf(ph, "spark spawnquiet %s s spark repeatcmd %i %s %s", word[4], Times-1, word[4], Cmd); + } + else + for(i=0;i= 100) + break; + } + } + xchat_list_free(ph, list); + } +// xchat_printf(ph, "Setting %s on %i users\n", word[3], Users); + xchat_send_modes(ph, UserList, Users, 0, word[3][0], word[3][1]); + } + + if(!strcasecmp(word[2],"SendModePrefix")){ // /spark sendmodeprefix +o prefix exclude + xchat_list *list; + int Users = 0; + int Exclude; + char *Prefix = word[4]; + if(!strcasecmp(Prefix, ".")) + Prefix = ""; + const char *UserList[40]; // nobody will ever trust this evil squirrel with >40 users + list = xchat_list_get(ph, "users"); + if(list){ + while(xchat_list_next(ph, list)) { + if(!strcasecmp(Prefix, xchat_list_str(ph, list, "prefix"))) { + int ShouldExclude = 0; + for(Exclude = 5; word[Exclude]!=NULL && strlen(word[Exclude]); Exclude++) + if(!strcasecmp(word[Exclude], xchat_list_str(ph, list, "nick"))) { + ShouldExclude = 1; + break; + } + if(ShouldExclude) + continue; + UserList[Users]=xchat_list_str(ph, list, "nick"); + Users = Users+1; + if(Users >= 40) + break; + } + } + xchat_list_free(ph, list); + } + xchat_send_modes(ph, UserList, Users, 0, word[3][0], word[3][1]); + } + + if(!strcasecmp(word[2],"pusers")){ // prefix of users in local context + xchat_list *list; + int Users = 0; + list = xchat_list_get(ph, "users"); + if(list){ + while(xchat_list_next(ph, list)) { + xchat_printf(ph, "user %s has %s \n",xchat_list_str(ph, list, "nick"), xchat_list_str(ph, list, "prefix")); + Users = Users+1; + } + xchat_list_free(ph, list); + } + } + + if(!strcasecmp(word[2],"get_info")) { // for debugging and curiosity + if(word[3] != NULL) + xchat_printf(ph,"%sxchat_get_info(ph, \"%s\") returns \"%s\";\n", SparklesUser, + word[3], SafeGet(xchat_get_info(ph, word[3]),NULL)); + } + if(!strcasecmp(word[2],"get_prefs")) { // for debugging and curiosity + int Int; + const char *Str; + switch(xchat_get_prefs (ph, word[3], &Str, &Int)) { + case 0: + xchat_printf(ph, "%sxchat_get_prefs() failed\n" ,SparklesUser); + break; + case 1: + xchat_printf(ph, "%sstring: \"%s\" \n", SparklesUser, Str); + break; + case 2: + xchat_printf(ph, "%sinteger: %i | %x \n", SparklesUser, Int, Int); + break; + case 3: + xchat_printf(ph, "%sboolean: %i \n", SparklesUser, Int); + break; + } + } + + if(!strcasecmp(word[2],"randtype")) { + RandomType = strtol(word[3], NULL, 10); + if(word[4] == NULL || strcasecmp(word[4],"quiet")) + xchat_printf(ph, "%sRandom number type set to %i \n", SparklesUser, RandomType); + } + if(!strcasecmp(word[2],"randnum")) + xchat_printf(ph, "%sRandom number: %i \n", SparklesUser, rand2(strtol(word[3], NULL, 10))); + + + if(!strcasecmp(word[2],"pesterchum")) { + if(!strcasecmp(word[3],"on")) { + DisablePesterchum = 1; xchat_printf(ph,"%sPesterchum mode OFF",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + DisablePesterchum = 0; xchat_printf(ph,"%sPesterchum mode ON",SparklesUser); + } + } + if(!strcasecmp(word[2],"prettyjanus")) { + if(!strcasecmp(word[3],"on")) { + DisablePrettyJanus = 1; xchat_printf(ph,"%sPretty Janus OFF",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + DisablePrettyJanus = 0; xchat_printf(ph,"%sPretty Janus ON",SparklesUser); + } + } + if(!strcasecmp(word[2],"invitejoin")) { + if(!strcasecmp(word[3],"on")) { + JoinOnInvite = 1; xchat_printf(ph,"%sJoin-on-invite enabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + JoinOnInvite = 0; xchat_printf(ph,"%sJoin-on-invite disabled",SparklesUser); + } + } + if(!strcasecmp(word[2],"rejoin")) { + if(!strcasecmp(word[3],"on")) { + RejoinKick = 1; xchat_printf(ph,"%sRejoin-on-kick enabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + RejoinKick = 0; xchat_printf(ph,"%sRejoin-on-kick disabled",SparklesUser); + } + } + if(!strcasecmp(word[2],"autoident")) { + if(!strcasecmp(word[3],"on")) { + DisableAutoIdent = 1; xchat_printf(ph,"%sAuto-ident disabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + DisableAutoIdent = 0; xchat_printf(ph,"%sAuto-ident re-enabled",SparklesUser); + } + } + + if(!strcasecmp(word[2],"autoghost")) { + if(!strcasecmp(word[3],"on")) { + DisableAutoGhost = 1; xchat_printf(ph,"%sAuto-ghost disabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + DisableAutoGhost = 0; xchat_printf(ph,"%sAuto-ghost re-enabled",SparklesUser); + } + } + + if(!strcasecmp(word[2],"autonickdeblue")) { + if(!strcasecmp(word[3],"on")) { + DisableAutoNickDeblue = 1; xchat_printf(ph,"%sAuto-nick-deblue disabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + DisableAutoNickDeblue = 0; xchat_printf(ph,"%sAuto-nick-deblue re-enabled",SparklesUser); + } + } + + if(!strcasecmp(word[2],"plusjfix")) { + if(!strcasecmp(word[3],"on")) { + DisablePlusJFix = 1; xchat_printf(ph,"%s+J fix disabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + DisablePlusJFix = 0; xchat_printf(ph,"%s+J fix re-enabled",SparklesUser); + } + } + + if(!strcasecmp(word[2],"activity2focus")) { + if(!strcasecmp(word[3],"on")) { + Activity2Focus = 1; xchat_printf(ph,"%sActivity-to-Focus enabled",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + Activity2Focus = 0; xchat_printf(ph,"%sActivity-to-Focus disabled",SparklesUser); + } + } + + if(!strcasecmp(word[2],"eathighlights")) { + if(!strcasecmp(word[3],"on")) { + EatHighlights = 1; xchat_printf(ph,"%sHighlights will now be eaten",SparklesUser); + } + if(!strcasecmp(word[3],"off")) { + EatHighlights = 0; xchat_printf(ph,"%sHighlights will now be left alone",SparklesUser); + } + } + + if(!strcasecmp(word[2],"invite")) { + if(!strcasecmp(word[3],"eat")) { + EatInvites = 1; xchat_printf(ph,"%sInvites will now be eaten",SparklesUser); + } + if(!strcasecmp(word[3],"leave")) { + EatInvites = 0; xchat_printf(ph,"%sInvites will now be left alone",SparklesUser); + } + } + if(!strcasecmp(word[2],"unsettabs")) { // unset all tabs + xchat_list *list = xchat_list_get(ph, "channels"); + if(list) { + while(xchat_list_next(ph, list)) { + if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context"))) + xchat_command(ph, "spark unsettab"); + } + xchat_list_free(ph, list); + } + } + if(!strcasecmp(word[2],"rchan2")) { // redirect to channel + xchat_list *list = xchat_list_get(ph, "channels"); + if(list) { + while(xchat_list_next(ph, list)) { + if(!strcasecmp(xchat_list_str(ph, list, "channel"),SafeGet(word[3],NULL))) { + if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context"))) + xchat_command(ph, SafeGet(word_eol[4],"echo Okay, and do WHAT on that channel?")); + } + } + xchat_list_free(ph, list); + } + } + if(!strcasecmp(word[2],"rchan")) { // redirect to channel (on same network) + xchat_context *Go = xchat_find_context(ph, NULL, word[3]); + if( xchat_set_context(ph, Go)) + xchat_command(ph, word_eol[4]); + } + if(!strcasecmp(word[2],"mrchan")) { + char *Ptr = word[3]; + while(1) { + strcpy(Buffer, Ptr); + char *A = strstr(Buffer, "!"); + if(A) { + *A = 0; + Ptr=A+1; + xchat_context *Go = xchat_find_context(ph, NULL, Buffer); + if(xchat_set_context(ph, Go)) + xchat_command(ph, word_eol[4]); + } + else { + xchat_context *Go = xchat_find_context(ph, NULL, Buffer); + if(xchat_set_context(ph, Go)) + xchat_command(ph, word_eol[4]); + break; + } + } + } + + if(!strcasecmp(word[2],"help")) { // get help + xchat_print(ph,"http://bin.smwcentral.net/u/1780/SparklesGuide.txt"); + } + if(!strcasecmp(word[2],"mutualchan")) { + strcpy(Buffer,""); + if(!strcasecmp(word[3],"")) { + // use current channel + } + else { // search for channels you're sharing with the given user + xchat_list *list = xchat_list_get(ph, "channels"); + if(list != NULL) { + while(xchat_list_next(ph, list)) + if(xchat_list_int(ph, list, "type")==2 && xchat_list_int(ph, list, "users")) + if(xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context"))) { + xchat_list *users = xchat_list_get(ph, "users"); + if(users != NULL) { + while(xchat_list_next(ph, users)) + if(!xchat_nickcmp(ph, xchat_list_str(ph, list, "nick"),word[3])) + sprintf(Buffer, "%s%s, ", Buffer, xchat_get_info(ph, "channel")); + xchat_list_free(ph, users); + } + } + xchat_printf(ph, "Channels shared with %s: %s\n", word[3], Buffer); + xchat_list_free(ph, list); + } + } + } + if(!strcasecmp(word[2],"chancolorset")) { // set all channels to one color + xchat_list *list = xchat_list_get(ph, "channels"); + if(list) { + while(xchat_list_next(ph, list)) { + if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) ) + xchat_commandf(ph, "gui color %s", (word[3]!=NULL ? word[3]: "0")); + } + xchat_list_free(ph, list); + } + } + + if(!strcasecmp(word[2],"chancolorset2")) { // for one server only + const char *Server = xchat_get_info(ph, "server"); + if(Server != NULL) { + xchat_list *list = xchat_list_get(ph, "channels"); + if(list) { + while(xchat_list_next(ph, list)) { + if(!strcasecmp(xchat_list_str(ph, list, "server"), Server)) { + if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) ) + xchat_commandf(ph, "gui color %s", (word[3]!=NULL ? word[3]: "0")); + } + } + xchat_list_free(ph, list); + } + } + } + + return XCHAT_EAT_ALL; +} + +static int invite_cb(char *word[], void *userdata) { + if(JoinOnInvite > 0) + if(strcasecmp(word[1],"#dontjoinitsatrap")) + xchat_commandf(ph,"JOIN %s",word[1]); + if(EatInvites > 0) + return XCHAT_EAT_ALL; + return XCHAT_EAT_NONE; +} + +static int userquit_cb(char *word[], void *userdata) { +//* Devann has quit (NickServ (GHOST command used by Devannisnowaghost)) +//* NovaYoshi has quit (Killed (NickServ (GHOST command used by NovaYoshi__))) +//* Haz has quit (NickServ (GHOST command used by sHazam)) + // 1 nick + // 2 reason + if(AutoReclaimNick) { + if(MyNickCmp(word[1], GhostReclaimNick)) { + xchat_commandf(ph, "nick %s", GhostReclaimNick); + AutoReclaimNick = 0; + } + } + return XCHAT_EAT_NONE; +} + +static int younick_cb(char *word[], void *userdata) { + if(!DisableAutoNickDeblue) + xchat_commandf(ph,"spark spawnquiet 1 s spark chancolorset2 0"); + return XCHAT_EAT_NONE; +} + +static int youkick_cb(char *word[], void *userdata) { + if(RejoinKick > 0) + xchat_commandf(ph,"JOIN %s",word[2]); + return XCHAT_EAT_NONE; +} + +static int getnotice_cb(char *word[], void *userdata) { +/* + if(MoveServicesToServer) { +// todo: fix + const char *Server = xchat_get_info(ph, "server"); + if(Server != NULL) { + xchat_list *list = xchat_list_get(ph, "channels"); + if(list) { + while(xchat_list_next(ph, list)) { + if(!strcasecmp(xchat_list_str(ph, list, "server"), Server)) { + xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) +//xchat_list_int(ph, list, "type")==1 + } + } + xchat_list_free(ph, list); + } + } + } +*/ + if(MyNickCmp(word[1], "NickServ")) { + if(!DisableAutoIdent) + if(NULL != strstr(word[2],"is registered and protected.") || NULL != strstr(word[2],"Please choose a different nickname")) + xchat_commandf(ph, "spark ident"); + if(AutoReclaimNick) + if((NULL != strstr(word[2],"isn't currently in use")) || + (NULL != strstr(word[2],"ghost")) || + (NULL != strstr(word[2],"Ghost")) || + (NULL != strstr(word[2],"killed"))) { + xchat_commandf(ph, "nick %s", GhostReclaimNick); + xchat_commandf(ph,"spark spawnquiet 1 s nick %s", GhostReclaimNick); + AutoReclaimNick = 0; + } + } + return XCHAT_EAT_NONE; +} +static int nickclash_cb(char *word[], void *userdata) { + if(((unsigned)time(NULL)) < (StartingTime+6)) + return XCHAT_EAT_NONE; + if(!DisableAutoGhost) { + xchat_commandf(ph,"spark spawnquiet 2.2 s spark ghost2 %s", word[1]); + } + return XCHAT_EAT_NONE; +} + +static int ctcp_cb(char *word[], void *userdata) { + if(DisableSparklesCTCP) + return XCHAT_EAT_NONE; + if(!strcasecmp(word[1],"SPARKLES")) + xchat_commandf(ph,"nctcp %s %s %s", word[2], PNAME, PVERSION); + return XCHAT_EAT_NONE; +} + +static int channelmessage_cb(char *word[], void *userdata) { + // 1-nick, 2-text + NeedSpaceBetweenX5Font = 0; + int PrefixLen = strlen(SparkEncryptPrefix); + + int i = 0; + if(!DisablePrettyJanus) { + for(i=0;JanusLinkbots[i]!=NULL&&strcmp("",JanusLinkbots[i])&&i<8;i++) + if(MyNickCmp(word[1], JanusLinkbots[i])) { + if(word[2][0] == '<') { + char Nick[80]; + char *Ends = strchr(word[2],'>'); + if(!Ends) + break; + char *Poke = Nick, *Peek = word[2]+1; + while(*Peek != '>') { + *(Poke++) = *(Peek++); + if(Poke > (Nick+sizeof(Nick))) + return XCHAT_EAT_NONE; + } + *Poke = 0; + if(!Ends[1]) return XCHAT_EAT_NONE; + if(!Ends[2]) return XCHAT_EAT_NONE; + Ends+=2; + + xchat_commandf(ph, "recv :%s!sparkles@sparkles PRIVMSG %s :%s", Nick, xchat_get_info(ph, "channel"), Ends); + return XCHAT_EAT_ALL; + } + if(word[2][0] == '*') { + char Nick[80]; + char *Peek = word[2]+1; + if(*Peek == ' ') Peek++; + char *Poke = Nick; + while(*Peek && (*Peek != ' ')) { + *(Poke++) = *(Peek++); + } + *Poke = 0; + if(!*Peek) return XCHAT_EAT_NONE; + if(!Peek[1]) return XCHAT_EAT_NONE; + if(!Peek[2]) return XCHAT_EAT_NONE; + + xchat_commandf(ph, "recv :%s!sparkles@sparkles PRIVMSG %s :\1ACTION %s\1", Nick, xchat_get_info(ph, "channel"), Peek+1); + return XCHAT_EAT_ALL; + } + break; + } + } + + if((strlen(word[2]) > (PrefixLen + 7)) && !memcmp(word[2], SparkEncryptPrefix, strlen(SparkEncryptPrefix) )) { + char *Peek = word[2]+PrefixLen; + // \c__\c__\p + + if(Peek != NULL) { + char Key1 = strtol(Peek+1,NULL,10) | (strtol(Peek+4,NULL,10)<<4); + char Buffer[768]=""; + char *Poke = Buffer; + + Peek = strchr(Peek, 15); // look for the "normal formatting" code on the end + if(Peek == NULL) + return XCHAT_EAT_NONE; + + unsigned char kA = (Key1 & 192) >> 6; + unsigned char kC = (Key1 & 15); + while(*Peek) { + char c = *(Peek++); + char nyb = c &15; + c&=~0x0f; + if(c>=0x20) { + switch(kA) { + case 0: nyb -=kC; nyb ^=15; break; + case 1: nyb -=kC; break; + case 2: nyb +=kC; nyb ^=15; break; + case 3: nyb +=kC; break; + } + } + c|=(nyb&15); + *(Poke++) = c; + } + *Poke = 0; + +// xchat_printf(ph, "(SE1)%s\xf\t%s\n", word[1], Buffer); + xchat_commandf(ph, "recv :SE1/%s!sparkles@sparkles PRIVMSG %s :%s", word[1], xchat_get_info(ph, "channel"), Buffer); + } + return XCHAT_EAT_ALL; + } + return XCHAT_EAT_NONE; +} + +enum ConfigTypes { + CONFIG_STRING, + CONFIG_BOOLEAN, + CONFIG_INTEGER, +}; +struct ConfigItem { + char *Group; + char *Item; + void *Data; + char Type; + short Len; +} ConfigOptions[] = { + {"General", "RandomType", &RandomType, CONFIG_INTEGER, 0}, + {"General", "TextEditor", &TextEditor, CONFIG_STRING, 512}, + {"Automatic", "RejoinOnKick", &RejoinKick, CONFIG_BOOLEAN, 0}, + {"Automatic", "JoinOnInvite", &JoinOnInvite, CONFIG_BOOLEAN, 0}, + {"Automatic", "DisableAutoIdent", &DisableAutoIdent, CONFIG_BOOLEAN, 0}, + {"Automatic", "DisableAutoNickColorReset", &DisableAutoNickDeblue, CONFIG_BOOLEAN, 0}, + {"Automatic", "DisableAutoGhost", &DisableAutoGhost, CONFIG_BOOLEAN, 0}, + {"Automatic", "Activity2Focus", &Activity2Focus, CONFIG_BOOLEAN, 0}, + {"Automatic", "DisableNetworkSayer", &DisableShowNetworkOnJoin, CONFIG_BOOLEAN, 0}, + {"Automatic", "MoveNotifyToServerTab", &MoveNotifyToServer, CONFIG_BOOLEAN, 0}, + {"Automatic", "MoveServicesToServerTab", &MoveServicesToServer, CONFIG_BOOLEAN, 0}, + {"PrettyJanus", "Disabled", &DisablePrettyJanus, CONFIG_BOOLEAN, 0}, + {"PrettyJanus", "Nick0", JanusLinkbots[0], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick1", JanusLinkbots[1], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick2", JanusLinkbots[2], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick3", JanusLinkbots[3], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick4", JanusLinkbots[4], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick5", JanusLinkbots[5], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick6", JanusLinkbots[6], CONFIG_STRING, 32}, + {"PrettyJanus", "Nick7", JanusLinkbots[7], CONFIG_STRING, 32}, + {"Pesterchum", "Disabled", &DisablePesterchum, CONFIG_BOOLEAN, 0}, + {"Pesterchum", "ChannelCommand", PesterchumChanHook, CONFIG_STRING, 512}, + {"Pesterchum", "Color", PesterchumColor, CONFIG_STRING, 64}, + {NULL}, // <-- end marker +}; +void INIConfigHandler(const char *Group, const char *Item, const char *Value) { +// printf("[%s] %s = %s\n", Group, Item, Value); + int i, *Int; + char *String; + for(i=0;ConfigOptions[i].Group!=NULL;i++) + if(!strcasecmp(ConfigOptions[i].Group, Group)&&!strcasecmp(ConfigOptions[i].Item, Item)) { + switch(ConfigOptions[i].Type) { + case CONFIG_INTEGER: + Int = ConfigOptions[i].Data; + if(isdigit(*Value)) + *Int = strtol(Value, NULL, 10); + else + xchat_printf(ph, "Item \"[%s] %s\" requires a numeric value\n", Group, Item); + return; + case CONFIG_BOOLEAN: + Int = ConfigOptions[i].Data; + if(!strcasecmp(Value, "on") || !strcasecmp(Value, "yes")) + *Int = 1; + else if(!strcasecmp(Value, "off") || !strcasecmp(Value, "no")) + *Int = 0; + else + xchat_printf(ph, "Item \"[%s] %s\" requires a value of on/yes or off/no (You put %s)\n", Group, Item, Value); + return; + case CONFIG_STRING: + String = ConfigOptions[i].Data; + if(strlen(Value) + +#define XCHAT_IFACE_MAJOR 1 +#define XCHAT_IFACE_MINOR 9 +#define XCHAT_IFACE_MICRO 11 +#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ + (XCHAT_IFACE_MINOR * 100) + \ + (XCHAT_IFACE_MICRO)) + +#define XCHAT_PRI_HIGHEST 127 +#define XCHAT_PRI_HIGH 64 +#define XCHAT_PRI_NORM 0 +#define XCHAT_PRI_LOW (-64) +#define XCHAT_PRI_LOWEST (-128) + +#define XCHAT_FD_READ 1 +#define XCHAT_FD_WRITE 2 +#define XCHAT_FD_EXCEPTION 4 +#define XCHAT_FD_NOTSOCKET 8 + +#define XCHAT_EAT_NONE 0 /* pass it on through! */ +#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ +#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xchat_plugin xchat_plugin; +typedef struct _xchat_list xchat_list; +typedef struct _xchat_hook xchat_hook; +#ifndef PLUGIN_C +typedef struct _xchat_context xchat_context; +#endif + +#ifndef PLUGIN_C +struct _xchat_plugin +{ + /* these are only used on win32 */ + xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*xchat_unhook) (xchat_plugin *ph, + xchat_hook *hook); + void (*xchat_print) (xchat_plugin *ph, + const char *text); + void (*xchat_printf) (xchat_plugin *ph, + const char *format, ...); + void (*xchat_command) (xchat_plugin *ph, + const char *command); + void (*xchat_commandf) (xchat_plugin *ph, + const char *format, ...); + int (*xchat_nickcmp) (xchat_plugin *ph, + const char *s1, + const char *s2); + int (*xchat_set_context) (xchat_plugin *ph, + xchat_context *ctx); + xchat_context *(*xchat_find_context) (xchat_plugin *ph, + const char *servname, + const char *channel); + xchat_context *(*xchat_get_context) (xchat_plugin *ph); + const char *(*xchat_get_info) (xchat_plugin *ph, + const char *id); + int (*xchat_get_prefs) (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + xchat_list * (*xchat_list_get) (xchat_plugin *ph, + const char *name); + void (*xchat_list_free) (xchat_plugin *ph, + xchat_list *xlist); + const char * const * (*xchat_list_fields) (xchat_plugin *ph, + const char *name); + int (*xchat_list_next) (xchat_plugin *ph, + xchat_list *xlist); + const char * (*xchat_list_str) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + int (*xchat_list_int) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + void * (*xchat_plugingui_add) (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*xchat_plugingui_remove) (xchat_plugin *ph, + void *handle); + int (*xchat_emit_print) (xchat_plugin *ph, + const char *event_name, ...); + int (*xchat_read_fd) (xchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*xchat_list_time) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + char *(*xchat_gettext) (xchat_plugin *ph, + const char *msgid); + void (*xchat_send_modes) (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*xchat_strip) (xchat_plugin *ph, + const char *str, + int len, + int flags); + void (*xchat_free) (xchat_plugin *ph, + void *ptr); +}; +#endif + + +xchat_hook * +xchat_hook_command (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + +xchat_hook * +xchat_hook_server (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_print (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_timer (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_fd (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + +void * +xchat_unhook (xchat_plugin *ph, + xchat_hook *hook); + +void +xchat_print (xchat_plugin *ph, + const char *text); + +void +xchat_printf (xchat_plugin *ph, + const char *format, ...); + +void +xchat_command (xchat_plugin *ph, + const char *command); + +void +xchat_commandf (xchat_plugin *ph, + const char *format, ...); + +int +xchat_nickcmp (xchat_plugin *ph, + const char *s1, + const char *s2); + +int +xchat_set_context (xchat_plugin *ph, + xchat_context *ctx); + +xchat_context * +xchat_find_context (xchat_plugin *ph, + const char *servname, + const char *channel); + +xchat_context * +xchat_get_context (xchat_plugin *ph); + +const char * +xchat_get_info (xchat_plugin *ph, + const char *id); + +int +xchat_get_prefs (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + +xchat_list * +xchat_list_get (xchat_plugin *ph, + const char *name); + +void +xchat_list_free (xchat_plugin *ph, + xchat_list *xlist); + +const char * const * +xchat_list_fields (xchat_plugin *ph, + const char *name); + +int +xchat_list_next (xchat_plugin *ph, + xchat_list *xlist); + +const char * +xchat_list_str (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +int +xchat_list_int (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +time_t +xchat_list_time (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +void * +xchat_plugingui_add (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + +void +xchat_plugingui_remove (xchat_plugin *ph, + void *handle); + +int +xchat_emit_print (xchat_plugin *ph, + const char *event_name, ...); + +char * +xchat_gettext (xchat_plugin *ph, + const char *msgid); + +void +xchat_send_modes (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + +char * +xchat_strip (xchat_plugin *ph, + const char *str, + int len, + int flags); + +void +xchat_free (xchat_plugin *ph, + void *ptr); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef XCHAT_PLUGIN_HANDLE +#define XCHAT_PLUGIN_HANDLE (ph) +#endif +#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) +#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) +#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) +#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) +#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) +#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) +#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) +#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) +#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) +#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) +#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) +#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) +#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) +#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) +#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) +#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) +#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) +#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) +#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) +#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) +#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) +#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) +#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) +#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) +#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) +#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) +#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) +#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) +#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) +#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#endif + +#ifdef __cplusplus +} +#endif +#endif -- cgit v1.2.3