Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Extremely old version of NovaBot from Mon 03 Aug 2009 04:01:54 PM EDT
- // ( the oldest .so was Sat 18 Jul 2009 04:02:26 PM EDT )
- #include "xchat-plugin.h"
- #include <string.h>
- #include <stdio.h>
- #include <time.h>
- #define PNAME "BridgeBot"
- #define PDESC "Bridges some servers together"
- #define PVERSION "0.2"
- static char ServerA[64]="?";
- static char ServerB[64]="?";
- char lastquit[64]="?";
- char lastjoin[64]="?";
- int Joins=0;
- int Messages=0;
- int Emotes=0;
- int StartTime;
- int Mute=0;
- static xchat_context *FromContext;
- static xchat_context *SendContext;
- static xchat_plugin *ph; /* plugin handle */
- static char ChannelName[64];
- static char ServerName[64];
- static char Temp[256];
- static char UseServer[64];
- static int FoundName=0;
- static int PrepOkay;
- static void Prep()
- {
- PrepOkay=0;
- FromContext=xchat_get_context(ph);
- FoundName=0;
- if(xchat_get_info(ph,"channel")==NULL)
- {
- xchat_print(ph, "Odd. Channel returns as null \n");
- return;
- }
- if(xchat_get_info(ph,"server")==NULL)
- {
- xchat_print(ph, "Odd. Server returns as null \n");
- return;
- }
- strcpy(ServerName,xchat_get_info(ph,"server"));
- strcpy(ChannelName,xchat_get_info(ph,"channel"));
- if(strcasecmp(ChannelName,"#NovaForest"))
- return;
- if(!strcasecmp(ServerA,"?"))
- {
- xchat_print(ph, "Filling in Server A \n");
- strcpy(ServerA,ServerName);
- xchat_command(ph, "SAY Okay, now post a message in the other #NovaForest");
- return;
- }
- if(!strcasecmp(ServerB,"?")&&strcasecmp(ServerA,ServerName))
- {
- xchat_print(ph, "Filling in Server B \n");
- strcpy(ServerB,ServerName);
- xchat_command(ph, "SAY Finished getting server names! Bridgebot should work now :3");
- return;
- }
- if(!strcasecmp(ServerA,"?")||!strcasecmp(ServerB,"?")) //If both server names aren't filled in, go no furher!
- {
- xchat_print(ph, "Server names aren't filled in for both servers yet \n");
- return;
- }
- if(!strcasecmp(ServerA,ServerName))
- {
- FoundName=1;
- strcpy(UseServer,ServerB);
- }
- if(!strcasecmp(ServerB,ServerName))
- {
- FoundName=1;
- strcpy(UseServer,ServerA);
- }
- if(FoundName==0)
- {
- xchat_printf(ph, "Huh? Couldn't find the name! \n");
- return;
- }
- ////////////////////////////////////////////////////////////////////
- if((SendContext=xchat_find_context(ph,UseServer,"#novaforest"))==NULL)
- {
- xchat_print(ph, "Failed to find the sending context! \n");
- strcpy(ServerA,"?");
- strcpy(ServerB,"?");
- return;
- }
- if(xchat_set_context(ph,SendContext)==0)
- {
- xchat_print(ph, "Failed to set context! \n");
- return;
- }
- if(Mute==1)
- return;
- PrepOkay=1;
- }
- static int disconnect_cb(char *word[], void *userdata) //After getting disconnected the
- {
- strcpy(ServerA,"?");
- strcpy(ServerB,"?");
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int join_cb(char *word[], void *userdata)
- {
- Joins++;
- Prep();
- sprintf(Temp,"SAY %s has joined", word[1]);
- if(PrepOkay==1 && strcasecmp(word[1],"Mare") && strcasecmp(word[1],"Dmare"))
- xchat_command(ph, Temp);
- strcpy(lastjoin,word[1]);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int part_cb(char *word[], void *userdata)
- {
- Prep();
- sprintf(Temp,"SAY %s has left", word[1]);
- if(PrepOkay==1)
- xchat_command(ph, Temp);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int partr_cb(char *word[], void *userdata)
- {
- Prep();
- sprintf(Temp,"SAY %s has left (%s)", word[1],word[4]);
- if(PrepOkay==1)
- xchat_command(ph, Temp);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int emote_cb(char *word[], void *userdata)
- {
- Emotes++;
- Prep();
- sprintf(Temp,"SAY %s %s", word[1],word[2]);
- if(PrepOkay==1)
- xchat_command(ph, Temp);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int message_cb(char *word[], void *userdata)
- {
- if(!strcasecmp(word[2],"nb.stat"))
- {
- sprintf(Temp,"SAY Joins: %i, Messages: %i, Emotes: %i, %s", Joins,Messages,Emotes,(Mute==0 ?"Bridgebot ON":"Bridgebot OFF"));
- xchat_command(ph, Temp);
- XCHAT_EAT_NONE;
- }
- if(!strcasecmp(word[2],"nb.mute"))
- {
- if(!strcasecmp(word[1],"NovaYoshi"))
- {
- sprintf(Temp,"SAY Bridgebot has been %s", (Mute==0 ?"Muted":"Unmuted"));
- xchat_command(ph, Temp);
- Mute=1-Mute;
- }
- else
- {
- sprintf(Temp,"SAY I'm gonna ignore you because you're not my master >:[");
- xchat_command(ph, Temp);
- }
- XCHAT_EAT_NONE;
- }
- Messages++;
- Prep();
- sprintf(Temp,"SAY %s: %s", word[1],word[2]);
- if(PrepOkay==1)
- xchat_command(ph, Temp);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int nickchange_cb(char *word[], void *userdata)
- {
- Prep();
- sprintf(Temp,"SAY %s is now known as %s", word[1],word[2]);
- if(PrepOkay==1)
- xchat_command(ph, Temp);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int kick_cb(char *word[], void *userdata)
- {
- Prep();
- sprintf(Temp,"SAY %s has been kicked by %s (%s)", word[2],word[1],word[4]);
- if(PrepOkay==1)
- xchat_command(ph, Temp);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int quit_cb(char *word[], void *userdata)
- {
- Prep();
- sprintf(Temp,"SAY %s has quit (%s)", word[1],word[2]);
- if(PrepOkay==1 && strcasecmp(word[1],"mare") && strcasecmp(word[1],"dmare"))
- xchat_command(ph, Temp);
- strcpy(lastquit,word[1]);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved)
- {
- *name = PNAME;
- *desc = PDESC;
- *version = PVERSION;
- }
- int xchat_plugin_init(xchat_plugin *plugin_handle,
- char **plugin_name,
- char **plugin_desc,
- char **plugin_version,
- char *arg)
- {
- /* we need to save this for use with any xchat_* functions */
- ph = plugin_handle;
- StartTime=time(NULL);
- /* tell xchat our info */
- *plugin_name = PNAME;
- *plugin_desc = PDESC;
- *plugin_version = PVERSION;
- xchat_hook_print(ph, "Join", XCHAT_PRI_NORM, join_cb, 0);
- xchat_hook_print(ph, "Disconnect", XCHAT_PRI_NORM, disconnect_cb, 0);
- xchat_hook_print(ph, "Part", XCHAT_PRI_NORM, part_cb, 0);
- xchat_hook_print(ph, "Part with reason", XCHAT_PRI_NORM, partr_cb, 0);
- xchat_hook_print(ph, "Channel Action", XCHAT_PRI_NORM, emote_cb, 0);
- xchat_hook_print(ph, "Channel Message", XCHAT_PRI_NORM, message_cb, 0);
- xchat_hook_print(ph, "Channel Nick", XCHAT_PRI_NORM, nickchange_cb, 0);
- xchat_hook_print(ph, "Kick", XCHAT_PRI_NORM, kick_cb, 0);
- xchat_hook_print(ph, "Quit", XCHAT_PRI_NORM, quit_cb, 0);
- xchat_print(ph, "Bridge Bot 3 reporting for duty!\n");
- return 1; /* return 1 for success */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement