Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "xchat-plugin.h"
- // Config settings
- #define MyNick "NovaYoshi"
- #define Enable_System 1
- #define Enable_Direct 1
- #define BITLBEE_SERVER "im.bitlbee.org"
- #include <string.h>
- #include <stdio.h>
- #include <time.h>
- #include <ctype.h>
- #include <stdlib.h>
- #define PNAME "NovaBot"
- #define PDESC "Yiffs people and does ASM stuff"
- #define PVERSION "5.0.1a"
- static unsigned int PowerTildeLock = 1;
- //static char PowerTildeUnlocker[128];
- static int juiceenabled = 0;
- static int NFLines = 0;
- static int BPLines = 0;
- static int OtherLines = 0;
- static int CommandTriggers = 0;
- static int StartTime;
- static int Mute=0;
- static xchat_plugin *ph; /* plugin handle */
- static int PrepOkay;
- static xchat_plugin *ph; /* plugin handle, needed for any XChat call */
- #define any_lowercase_letter case 'a':case 'b':case'c':case'd':case'e':case'f':case 'g':case 'h':case 'i':case 'j':case 'k':case 'l':case'm':case'n':case'o':case'p':case 'q':case 'r':case 's':case 't':case 'u':case 'v':case'w':case'x':case'y':case'z':
- #define any_decimal_digit case '0':case '1':case'2':case'3':case'4':case'5':case '6':case '7': case '8':case '9':
- #include "rscript.c"
- #include "juicetypes.h"
- // Change for whatever path you wanna store user data in
- static const char *BaseDataPath = "/home/joshua/Desktop/NovaBot/data/";
- // Create a pointer to someone's database entry
- static char *CreateDataPath2(char *Buffer, char *Group, char *Nick, char *FileType) {
- char NickBuf[64];
- int i=0;
- while(1) {
- NickBuf[i]=tolower(Nick[i]);
- if(NickBuf[i]=='/' || NickBuf[i]=='\\')
- NickBuf[i] = '-';
- if(0==Nick[i++])
- break;
- }
- sprintf(Buffer, "%s%s%s%s", BaseDataPath,Group,NickBuf,FileType);
- return(Buffer);
- }
- // Check if a message starts with a given command, and if so, return the argument
- static int RecognizeCommand(char *Msg, const char *Cmd, char **ArgPtr) {
- if(!memcmp(Msg, Cmd, strlen(Cmd))) {
- *ArgPtr = Msg+strlen(Cmd);
- if(**ArgPtr == 0) return(0);
- return(1);
- }
- return(0);
- }
- // Does CreateDataPath2() and also reads from the file
- static char *ReadTextDataPath2(char *Output, char *Group, char *Nick, char *FileType, char *Default) {
- char Temp[512];
- char *Poke;
- int i;
- CreateDataPath2(Temp, Group, Nick, FileType);
- FILE *Profile = fopen(Temp, "rb");
- if(Profile!=NULL) {
- Poke = Output;
- for(i=5;i!=EOF;) {
- i=fgetc(Profile);
- *Poke = i;
- if(i == '`'){*Poke = 0; break;}
- Poke++;
- }
- fclose(Profile);
- return(Output);
- } else {
- return(Default);
- }
- }
- static void IncChannelLines() {
- const char *Chan = xchat_get_info(ph,"channel");
- if (Chan==NULL) return;
- if(!strcasecmp(Chan,"#NovaForest")) NFLines++;
- else if(!strcasecmp(Chan,"#Botplace")) BPLines++;
- else OtherLines++;
- }
- static char *z80FakeMultiply(char *Result, int Find) { // nb.zmulbyadd
- char Temp[100];
- Temp[99]=0; // String end
- if(Find==-1){strcpy(Result,"neg"); return(Result);}
- if(Find==0){strcpy(Result,"xor a"); return(Result);}
- if(Find==1){strcpy(Result,"nop"); return(Result);}
- if(Find<0){strcpy(Result,"Only positive numbers, please"); return(Result);}
- char *Poke = Temp+98;
- while(Find != 1) {
- if(Find & 1) {
- Find--;
- *(Poke--) = 'y';
- } else {
- Find>>=1;
- *(Poke--) = 'x';
- }
- printf("%i ", Find);
- }
- strcpy(Result, ++Poke);
- printf("\nResult is %s \n", Poke);
- return(Result);
- }
- static void z80Asm(char *Input, char *Output) {
- remove("lazyass.bin");
- // First we need to create a file to feed z80asm
- FILE *MyFile = fopen("lazyass.asm","w");
- if(MyFile==NULL) {
- strcpy(Output,"unable to open lazyass.asm");
- return;
- }
- // Intercept all '\'s and turn them into newlines
- char *Peek = Input;
- while(*Peek) {
- char got = *Peek;
- if(got == '\\') { // new line
- fputc('\r',MyFile);
- fputc('\n',MyFile);
- }
- else
- fputc(got, MyFile);
- Peek++;
- }
- // Now we have a file to feed z80asm
- fclose(MyFile);
- char Command[512];
- sprintf(Command, "z80asm -i lazyass.asm -o lazyass.bin");
- int Status = system(Command);
- // Open the assembled code
- MyFile = fopen("lazyass.bin","rb");
- if(MyFile==NULL) {
- sprintf(Output,"Unable to open lazyass.bin. (system() returned %i) I'm guessing you made a mistake in your code", Status);
- return;
- }
- // Now get the hex values from the compiled code
- strcpy(Output,"");
- char *Poke = Output;
- // int len=0; // code length
- int ch;
- do {
- char Small[7];
- ch = fgetc(MyFile);
- if(ch==EOF)
- break;
- if(ch < 16)
- sprintf(Small, "0%x ",ch);
- else
- sprintf(Small, "%x ",ch);
- strcat(Poke,Small);
- } while(ch != EOF);
- }
- static char *text_unescape(char *Poke, char *Peek) {
- // Takes a string given, and interprets \n and friends
- unsigned char Safe;
- while(*Peek != 0) {
- *Poke++ = *Peek;
- if(*Peek == '\r') *(Poke-1) = ':';
- if(*Peek == '\n') *(Poke-1) = '3';
- if(*Peek == '\\') {
- Peek++;
- switch(*Peek) {
- case '\\': *(Poke-1) = '\\'; break; // Escaped '\'
- case 'i': *(Poke-1) = 0x16; break; // Italic
- case 'u': *(Poke-1) = 0x1f; break; // Underline
- case 'b': *(Poke-1) = 0x02; break; // Bold
- case 'c': *(Poke-1) = 0x03; break; // Colored
- case 'p': *(Poke-1) = 0x0f; break; // Plain
- case 'a': *(Poke-1) = '\a'; break; // Bell
- case 't': *(Poke-1) = '\t'; break; // Tab
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- Safe = strtol(Peek,&Peek,10);
- if(Safe == '\n') Safe = '$';
- if(Safe == '\r') Safe = '$';
- *(Poke-1) = Safe;
- break;
- default: *(Poke-1) = '?'; break; // Unrecognized
- }
- }
- Peek++;
- }
- *Poke = 0;
- return Poke;
- }
- // Look in current context to see what access level the user has
- static int UserMode_local(char *who) {
- return 0; // Too lazy to finish the function because I don't need it just yet
- }
- // Strips out any colors or text effects, then does a nick comparison
- static int MyNickCmp(char *N1, char *N2) {
- static char *StripName;
- StripName = xchat_strip(ph, N1, -1, 3);
- if(!strcasecmp(StripName, N2)) {
- xchat_free(ph, StripName);
- return 0;
- }
- xchat_free(ph, StripName);
- return 1;
- }
- static int IsBotOwner(char *Nick, xchat_context *Context) {
- if(!MyNickCmp(Nick,"NovaYoshi")) return 1;
- if(!MyNickCmp(Nick,"NovaRooey")) return 1;
- return 0;
- }
- static void AllOthers(char *String, const char *Origin, const char *PassServer)
- //Emit the command in every suitable channel but the origin
- {
- xchat_list *list = xchat_list_get(ph, "channels");
- if(list) {
- while(xchat_list_next(ph, list)) {
- if(!strcasecmp(xchat_list_str(ph, list, "channel"),Origin)) {
- if( strcasecmp(xchat_list_str(ph, list, "server"),PassServer)) {
- if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) == 0) {
- xchat_printf(ph,"Oops! Bad context! \n");
- }
- else {
- xchat_command(ph, String);
- }
- }
- }
- }
- xchat_list_free(ph, list);
- }
- }
- // Left over from when NovaBot was a bridgebot and not a yiffbot
- static void Prep() { // Make sure this context is okay
- PrepOkay=0;
- if(xchat_get_info(ph,"channel")==NULL) {
- xchat_print(ph, "Channel returned null! \n");
- return;
- }
- if(xchat_get_info(ph,"server")==NULL) {
- xchat_print(ph, "Server returned null! \n");
- return;
- }
- if(Mute==1)
- return;
- PrepOkay=1;
- }
- // Doesn't do anything yet
- static int ijoin_cb(char *word[], void *userdata) {
- return XCHAT_EAT_NONE;
- }
- // Hook for receiving notices
- static int notice_cb(char *word[], void *userdata) {
- int FindIt;
- FILE *ReadPass;
- char SecurityBuff[512];
- int i=0;
- for(i=0;;) {
- SecurityBuff[i]=tolower(word[2][i]);
- if(0==word[2][i++])
- break;
- }
- int ErrSecurity=0;
- if(RecognizeCommand(word[2], "ns ", NULL)) ErrSecurity = 1;
- if(RecognizeCommand(word[2], "cs ", NULL)) ErrSecurity = 1;
- if(RecognizeCommand(word[2], "msg nickserv ", NULL)) ErrSecurity = 1;
- if(RecognizeCommand(word[2], "msg chanserv ", NULL)) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"nickserv ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"chanserv ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"botserv ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"memoserv ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"hostserv ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"drop ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"access ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"ms ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"hs ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"bs ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"cs ")) ErrSecurity = 1;
- if(NULL!=strstr(SecurityBuff,"ns ")) ErrSecurity = 1;
- if(ErrSecurity == 1) { xchat_commandf(ph, "NOTICE %s I may be something Nova wrote but I'm not stupid",word[1]); return XCHAT_EAT_NONE; }
- FindIt=0;
- char *ArgPtr;
- if(IsBotOwner(word[1], xchat_get_context(ph))) { // Ignore comands if given by someone who isn't me
- if(RecognizeCommand(word[2], "^~", &ArgPtr)) {
- if(PowerTildeLock == 0)
- xchat_commandf(ph, "NOTICE %s PowerTilde is locked right now",word[1]);
- else
- xchat_commandf(ph, "%s", ArgPtr);
- return XCHAT_EAT_NONE;
- }
- if(RecognizeCommand(word[2], "lock ", &ArgPtr)) {
- ReadPass = fopen("/home/joshua/Desktop/NovaBot/tildepass.txt","rb");
- if(ReadPass != NULL) {
- char CheckBuffer[50];
- char *PokePass = CheckBuffer;
- for(i=5;i!=EOF;) {
- i=fgetc(ReadPass);
- *PokePass = i;
- if(i == '~'){*PokePass = 0; break;}
- PokePass++;
- }
- if(!strcasecmp(ArgPtr, CheckBuffer)) {
- PowerTildeLock = 1-PowerTildeLock;
- xchat_commandf(ph, "notice %s a winrar is you (%i)", word[1], PowerTildeLock);
- }
- else {
- xchat_commandf(ph, "notice %s That isn't my password", word[1]);
- }
- fclose(ReadPass);
- } else
- xchat_commandf(ph, "notice %s file didn't open", word[1]);
- }
- }
- return XCHAT_EAT_NONE;
- }
- // Hook for when NovaBot talks
- static int imessage_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- // sloppy check to see if it is a bridged message already
- if(word[2][0] == '*') return XCHAT_EAT_NONE;
- if(word[2][1] == '*') return XCHAT_EAT_NONE;
- if(word[2][0] == ':') return XCHAT_EAT_NONE;
- if(word[2][1] == ':') return XCHAT_EAT_NONE;
- if(word[2][0] == 2) return XCHAT_EAT_NONE;
- if(word[2][1] == 2) return XCHAT_EAT_NONE;
- sprintf(Temp, "SAY \2\2:NovaBot: %s", word[2]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // Hook for when NovaBot yiffs
- static int iaction_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- // sloppy check to see if it is a bridged message already
- if(word[2][0] == '*') return XCHAT_EAT_NONE;
- if(word[2][1] == '*') return XCHAT_EAT_NONE;
- if(word[2][0] == ':') return XCHAT_EAT_NONE;
- if(word[2][1] == ':') return XCHAT_EAT_NONE;
- if(word[2][0] == 2) return XCHAT_EAT_NONE;
- if(word[2][1] == 2) return XCHAT_EAT_NONE;
- sprintf(Temp, "SAY *NovaBot %s", word[2]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // Handler for when someone joins so we can voice aginas
- static int join_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- sprintf(Temp,"SAY \02%s\x0f has joined this channel on %s", word[1],xchat_get_info(ph,"server"));
- if(NULL !=strstr(word[1],"agina"))
- xchat_commandf(ph, "VOICE %s", word[1]);
- if((!MyNickCmp(word[1],"agina")))
- xchat_commandf(ph, "VOICE agina"); // set mode +v agina
- if((!MyNickCmp(word[1],"irgin")))
- xchat_commandf(ph, "VOICE irgin"); // set mode +v irgin
- if((!MyNickCmp(word[1],"irgin_mobile")))
- xchat_commandf(ph, "VOICE irgin_mobile"); // set mode +v irgin
- if((!MyNickCmp(word[1],"iagra")))
- xchat_commandf(ph, "VOICE iagra"); // set mode +v iagra
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // For when someone leaves
- static int part_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- sprintf(Temp,"SAY \02%s\x0f has left this channel on %s", word[1],xchat_get_info(ph,"server"));
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // For when someone leaves and gives a reason
- static int partr_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- sprintf(Temp,"SAY \02%s\x0f has left this channel on %s (%s)", word[1], xchat_get_info(ph,"server"), word[4]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- /* When the bot gets kicked, this code runs */
- static int kicked_cb(char *word[], void *userdata) {
- if(!strcasecmp(xchat_get_info(ph, "server"),BITLBEE_SERVER))
- xchat_command(ph, "JOIN &bitlbee"); // for taking over old connections
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // Whenever someone uses /me in a channel, this code runs
- static int emote_cb(char *word[], void *userdata) {
- static char Temp[512]; IncChannelLines(); Prep();
- sprintf(Temp,"SAY *%s\x0f %s", word[1],word[2]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // NovaBot should join when invited
- static int invited_cb(char *word[], void *userdata) {
- xchat_commandf(ph,"join %s",word[1]);
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- // Pretty much the core of NovaBot
- static int ReactGlobalCommand(xchat_context *Context, char *Nick, char *Message, char *ReplyCmd) {
- static char Temp[512];
- int already = 0;
- int i;
- xchat_set_context(ph,Context);
- char LowerBuffer[512];
- char *MkLowPeek = Message;
- char *MkLowPoke = LowerBuffer;
- while(*MkLowPeek) {
- *(MkLowPoke++)=tolower(*(MkLowPeek++));
- }
- *MkLowPoke = 0;
- char *MessageNoPF = Message+2; // add more sophisticated way of skipping the prefix later
- char *ArgPtr; // pass to RecognzieCommand
- if(!strcasecmp(MessageNoPF,".jumpengine")) {
- xchat_commandf(ph, "%s asl \\ tay \\ pla \\ sta 4 \\ pla \\ sta 5 \\ iny \\ lda (4),y \\ sta 6 \\ iny \\ lda (4),y \\ sta 7 \\ jmp (6)", ReplyCmd);
- }
- if(!strcasecmp(MessageNoPF,".episodes")) {
- xchat_commandf(ph, "%s All episodes currently on Youtube: http://bit.ly/mlplist", ReplyCmd);
- already = 1;
- }
- if((RecognizeCommand(MessageNoPF, ".furget ", &ArgPtr)|| !strcasecmp(MessageNoPF,".furget")) && !already) {
- if(!strcasecmp(MessageNoPF, ".furget")) ArgPtr = Nick;
- CreateDataPath2(Temp, "furprofile/", ArgPtr, ".txt");
- FILE *Profile = fopen(Temp, "rb");
- if(Profile!=NULL) {
- MkLowPoke = Temp;
- for(i=5;i!=EOF;) {
- i=fgetc(Profile);
- *MkLowPoke = i;
- if(i == '`'){*MkLowPoke = 0; break;}
- MkLowPoke++;
- }
- fclose(Profile);
- xchat_commandf(ph, "%s %s is: %s", ReplyCmd, ArgPtr, Temp);
- } else {
- xchat_commandf(ph, "%s Couldn't open the profile for %s", ReplyCmd, ArgPtr);
- }
- already = 1;
- }
- if(RecognizeCommand(MessageNoPF, ".furset ", &ArgPtr) && !already) {
- CreateDataPath2(Temp, "furprofile/", Nick, ".txt");
- FILE *Profile = fopen(Temp, "wb");
- if(Profile!=NULL) {
- fprintf(Profile, "%s`", ArgPtr);
- xchat_commandf(ph, "%s Saved :3", ReplyCmd);
- fclose(Profile);
- } else {
- xchat_commandf(ph, "%s Couldn't open your profile", ReplyCmd);
- }
- already = 1;
- }
- if(RecognizeCommand(MessageNoPF, ".zmulbyadd ", &ArgPtr) && !already) {
- z80FakeMultiply(Temp, strtol(ArgPtr,NULL,10));
- xchat_commandf(ph, "%s List: %s", ReplyCmd, Temp);
- already = 1;
- }
- if(RecognizeCommand(MessageNoPF, ".clean ", &ArgPtr) && !already) {
- xchat_commandf(ph, "me produces a hose and sprays down %s", ArgPtr); //Message+9);
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".beep") && !already ) {
- xchat_commandf(ph, "%s beep! \a",ReplyCmd);
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".wtf") && !already ) {
- xchat_commandf(ph, "%s Don't worry about it, go back to bed",ReplyCmd);
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".nickfix") && !already) {
- xchat_command(ph, "nick NovaBot");
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".getmeasoda") && !already) {
- xchat_commandf(ph, "me hands %s a soda",Nick);
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".help") && !already) {
- //xchat_commandf(ph, "%s Check out http://www.smwiki.net/wiki/NovaBot",ReplyCmd );
- xchat_commandf(ph, "%s Check out http://www.smwiki.net/wiki/NovaBot",ReplyCmd );
- already=1;
- //return XCHAT_EAT_NONE;
- }
- if(!strcasecmp(MessageNoPF,".getmeafuckingsoda") && !already) {
- xchat_commandf(ph, "me hands %s a soda which then fucks %s really hard",Nick, Nick);
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".getmeasexysoda") && !already) {
- xchat_commandf(ph, "me hands %s a soda which then has sex with %s", Nick, Nick);
- already=1;
- }
- if(RecognizeCommand(MessageNoPF, ".rand ", &ArgPtr) && !already) {
- int max = strtol(ArgPtr, NULL, 10);
- if(max != 0)
- xchat_commandf(ph, "%s Here's your random number (modulo %i, +1): %i",ReplyCmd,max,1+rand()%max);
- else
- xchat_commandf(ph, "%s I'm not going to divide by zero, sorry",ReplyCmd);
- already=1;
- }
- if(RecognizeCommand(MessageNoPF, ".dice ", &ArgPtr) && !already) {
- int dice = strtol(ArgPtr, &ArgPtr, 10);
- if(NULL != ArgPtr) {
- int sides = strtol(ArgPtr, &ArgPtr, 10);
- int total = 0;
- int num;
- if(dice > 300)
- xchat_commandf(ph, "%s I know better than to lag myself trying to roll that many", ReplyCmd);
- // else if (sides == 1)
- // xchat_commandf(ph, "%s What do you expect me to roll? Spheres?", ReplyCmd);
- else if (sides == 0)
- xchat_commandf(ph, "%s I don't have any dice with zero sides", ReplyCmd);
- // else if (sides < 2)
- // xchat_commandf(ph, "%s Is that even physically possible?", ReplyCmd);
- else if (dice < 1)
- xchat_commandf(ph, "%s I can't roll a negative number of dice", ReplyCmd);
- else {
- for(num = 0; num < dice; num++)
- total+=1+rand()%sides;
- char *DiceWord = "dice";
- if(sides == 2) DiceWord = "coins";
- if(sides == 1) DiceWord = "spheres";
- if(sides < 0) DiceWord = "negative dice";
- xchat_commandf(ph, "%s I %s %i %s, each with %i sides and got: %i",ReplyCmd,(sides!=2?"rolled":"flipped"),dice,DiceWord, sides, total);
- }
- }
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".rand") && !already) {
- sprintf(Temp,"%s Here's your random number: %i",ReplyCmd,rand());
- xchat_command(ph, Temp);
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".version") && !already) {
- sprintf(Temp,"%s Currently running NovaBot version %s",ReplyCmd,PVERSION);
- xchat_command(ph, Temp);
- already=1;
- }
- if(RecognizeCommand(MessageNoPF, ".convbase ", &ArgPtr) && !already) {
- int whatever;
- switch(*ArgPtr) {
- case '$':
- whatever = strtol(ArgPtr+1,NULL,16);
- break;
- case '%':
- whatever = strtol(ArgPtr+1,NULL,2);
- break;
- default:
- whatever = strtol(ArgPtr,NULL,10);
- break;
- }
- xchat_commandf(ph, "%s %i == $%x",ReplyCmd,whatever, whatever);
- }
- if(RecognizeCommand(MessageNoPF, ".zas ", &ArgPtr) && !already) {
- if(strlen(LowerBuffer) > 150) {
- xchat_commandf(ph,"%s Too many chars of ASM given",ReplyCmd);
- already=1;
- }
- else {
- char Hex[2048];
- z80Asm(ArgPtr,Hex);
- if(strlen(Hex)>400) {
- xchat_commandf(ph, "%s Assembled program is too many chars to read out",ReplyCmd);
- }
- else {
- sprintf(Temp,"%s %s",ReplyCmd, Hex);
- xchat_command(ph, Temp);
- }
- }
- }
- if(RecognizeCommand(MessageNoPF, ".pyiff ", &ArgPtr) && !already) {
- // if(Message[8] == 0 || Message[9] == 0) {
- // xchat_commandf(ph, "notice %s Please put the name of the person you want me to yiff after nb.pyiff",Nick);
- // already=1;
- // }
- // else {
- // xchat_commandf(ph,"say before");
- // MkLowPoke = ReadTextDataPath2(Temp, "furprofile/species/", ArgPtr, ".txt", NULL);
- // if(MkLowPoke == NULL)
- xchat_commandf(ph, "YIFF %s", ArgPtr);
- // else
- // xchat_commandf(ph, "YIFF %s -ys %s ???", ArgPtr, MkLowPoke);
- already=1;
- // }
- }
- //if(!strcasecmp(Message,"nb.nstftype")) {
- // xchat_commandf(ph, "%s okay %s", ReplyCmd, JuiceEffects[rand()%23]);
- // already=1;
- //}
- if(!strcasecmp(MessageNoPF,".lines") && !already) {
- sprintf(Temp,"NF:%i BP:%i ?:%i Cmd: %i ",NFLines, BPLines, OtherLines, CommandTriggers);
- xchat_commandf(ph, "%s %s", ReplyCmd, Temp);
- //return XCHAT_EAT_NONE;
- already=1;
- }
- if(!strcasecmp(MessageNoPF,".abuse")) {
- xchat_commandf(ph, "%s DO NOT ABUSE THE BOT. IF YOU ABUSE THE BOT, PINKIE PIE **WILL** FUCK YOUR SHIT UP! THEN SHE WILL VIOLATE YOU WITH CUPCAKES. TASTY, RAINBOW DASH FLAVOUR CUPCAKES!", ReplyCmd);
- already = 1;
- }
- if(RecognizeCommand(MessageNoPF, ".calc ", &ArgPtr) && !already) {
- if(strlen(LowerBuffer) > 100) {
- xchat_commandf(ph,"%s Nice try :3",ReplyCmd);
- already=1;
- }
- else {
- InfoQuit Test = RunRetardScript(ArgPtr,0,1);
- if(strlen(Test.Text) < 400)
- xchat_commandf(ph, "%s calc: %s", ReplyCmd, Test.Text);
- else
- xchat_commandf(ph, "%s calc - too much on the stack to display (%i chars)", ReplyCmd, Test.Text, strlen(Test.Text));
- already=1;
- }
- }
- if(already) return 2;
- ArgPtr = "";
- strcpy(Temp, MessageNoPF);
- char *Find = strchr(Temp, ' ');
- if(Find != NULL) {
- *Find = 0;
- if(Find[1]) ArgPtr = Find+1;
- }
- xchat_commandf(ph,"NB_ExtCmd \"%s\" \"%s\" \"%s\" -A %s", Temp+1, ReplyCmd, Nick, ArgPtr);
- return 1; // return already;
- }
- // Is someone PMing the bot?
- static int private_cb(char *word[], void *userdata) {
- static char Temp[512];
- if(!strncmp(word[2] ,"nb.", 3)) {
- char ReplyWith[100];
- sprintf(ReplyWith, "msg %s", word[1] );
- if(!ReactGlobalCommand(xchat_get_context(ph), word[1], word[2], ReplyWith))
- xchat_commandf(ph,"msg %s Unrecognized command >:(", word[1]);
- // sprintf(Temp,"MSG %s 'kay, recognized as MAYBE being a command but not implemented yet", word[1]);
- return XCHAT_EAT_NONE;
- }
- // Is this from a Bitlbee connection?
- // if(!strcasecmp(xchat_get_info(ph, "server"),BITLBEE_SERVER)) {
- // sprintf(Temp,"MSG %s :3 %s", word[1], word[2]);
- // xchat_command(ph, Temp);
- // return XCHAT_EAT_NONE;
- // }
- if(strncmp(word[2] ,"nb.", 3)) {
- sprintf(Temp,"MSG %s Not a valid command. Maybe you were trying to contact NovaYoshi instead? (use MemoServ if you have to)", word[1]);
- xchat_command(ph, Temp);
- }
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- /*
- Whenever someone talks in a channel, this code runs
- */
- static int message_cb(char *word[], void *userdata) {
- static char Temp[512];
- char LowerBuffer[512];
- char *MkLowPeek = word[2];
- char *MkLowPoke = LowerBuffer;
- int already = 0;
- xchat_context *BackTo = xchat_get_context(ph);
- IncChannelLines();
- Prep();
- sprintf(Temp,"SAY \2\2:%c\2\2%s\x0f: %s", word[1][0], word[1]+1,word[2]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- xchat_set_context(ph,BackTo);
- while(*MkLowPeek) {
- *(MkLowPoke++)=tolower(*(MkLowPeek++));
- }
- *MkLowPoke = 0;
- if( ( NULL != strstr(LowerBuffer,"lose") || NULL != strstr(LowerBuffer,"lost") ) && NULL != strstr(LowerBuffer," electron") ) xchat_commandf(ph, "SAY Are you sure?"); // Yes I'm positive
- if(!strcasecmp(xchat_get_info(ph,"channel"),"#novaforest")) {
- if(NULL != strstr(LowerBuffer,"what the fuck") ||
- NULL != strstr(LowerBuffer,"what the heck") ||
- NULL != strstr(LowerBuffer,"what the hell") ||
- NULL != strstr(LowerBuffer,"fucking sucks") ||
- NULL != strstr(LowerBuffer,"fuckin sucks") ||
- NULL != strstr(LowerBuffer,"wtf")
- ) {
- xchat_commandf(ph, "say Don't worry about it, go back to bed");
- }
- }
- if(!MyNickCmp(word[1], "root")) // Is Bitlbee trying to talk to us?
- { // automatically accept friend requests
- if(NULL != strstr(word[2],"wants to add you to his/her buddy list"))
- xchat_commandf(ph, "say yes");
- if(NULL != strstr(word[2],"is not in your buddy list yet. Do you want to add him/her now"))
- xchat_commandf(ph, "say yes");
- if(NULL != strstr(word[2],"Would you like to take over this session?"))
- xchat_commandf(ph, "say yes");
- }
- if(word[2][0] == 'n' && word[2][1] == 'b' && word[2][2] == '.'){
- CommandTriggers++;
- ReactGlobalCommand(BackTo, word[1], word[2], "say");
- // Crappy, useless commands
- /*
- if(!strcasecmp(word[2],"nb.xwho") && !already && 0 ) {
- char ServerN[512];
- char ChannelN[512];
- char TServer[512];
- char asshole[712];
- char poohole[712];
- xchat_commandf(ph, "notice %s okay, working on it", word[1]);
- strcpy(ServerN,xchat_get_info(ph,"server"));
- strcpy(ChannelN,xchat_get_info(ph,"channel"));
- xchat_list *list = xchat_list_get(ph, "channels");
- if(list) {
- // xchat_commandf(ph, "notice %s list works", word[1]);
- while(xchat_list_next(ph, list)) {
- if(!strcasecmp(xchat_list_str(ph, list, "channel"),ChannelN)) {
- if( strcasecmp(xchat_list_str(ph, list, "server"),ServerN)) {
- strcpy(TServer, xchat_list_str(ph, list, "server"));
- xchat_commandf(ph, "notice %s server %s - %i users", word[1], TServer, xchat_list_int(ph,list,"users"));
- if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) == 0) {
- xchat_printf(ph,"Oops! Bad context! \n");
- }
- else if( (xchat_context *)xchat_list_str(ph, list, "context") == NULL ) {
- xchat_printf(ph,"Oops! Bad context! \n");
- }
- else {
- xchat_list *nicks = xchat_list_get(ph, "users");
- if(nicks) {
- xchat_print(ph,"userlist start \n");
- sprintf(poohole, "%s ",TServer);
- while(xchat_list_next(ph, list)) {
- const char *pingas = xchat_list_str(ph, nicks, "nick");
- if(pingas != NULL) {
- // sprintf(asshole,"%s --, ", poohole ); //pingas);
- // strcpy(poohole, asshole);
- }
- }
- xchat_list_free(ph, nicks);
- xchat_set_context(ph,BackTo);
- xchat_commandf(ph, "notice %s TOTALLY RAD", word[1]);
- xchat_commandf(ph, "notice %s got %s", word[1], poohole);
- }
- }
- }
- }
- }
- }
- xchat_list_free(ph, list);
- xchat_set_context(ph,BackTo);
- // xchat_commandf(ph, "notice %s complete", word[1]);
- already=1;
- }
- */
- if(!strcasecmp(word[2],"nb.whatchannelisthis") && !already) {
- sprintf(Temp,"SAY umm, I think this is %s",xchat_get_info(ph,"channel"));
- xchat_command(ph, Temp);
- //return XCHAT_EAT_NONE;
- already=1;
- }
- if(NULL!=strstr(LowerBuffer,"nb.givejuice") && !already && (strlen(word[2])>14) ) {
- char *JuiceType = word[2]+13;
- if(strlen(JuiceType)<50) {
- if(strcasecmp(JuiceType,"Nova")) {
- xchat_commandf(ph, "me hands %s a cup of %s juice :3", word[1], JuiceType);
- } else {
- if(juiceenabled)
- xchat_commandf(ph, NovaJuiceMessage, JuiceEffects[rand()%23], word[1]);
- else
- xchat_commandf(ph, "say I'm not allowed to give that anymore :<",word[1]);
- }
- }
- already=1;
- }
- if(!strcasecmp(word[2],"nb.bridgetoggle") && !already) {
- if(IsBotOwner(word[1], xchat_get_context(ph))) {
- sprintf(Temp,"SAY Bridgebot has been %s", (Mute==0 ?"Muted":"Unmuted"));
- xchat_command(ph, Temp);
- Mute=1-Mute;
- }
- else {
- sprintf(Temp,"SAY \"%s\" isn't the owner of this bot", word[1]);
- xchat_command(ph, Temp);
- }
- //return XCHAT_EAT_NONE;
- }
- if(!strcasecmp(word[2],"nb.juicetoggle") && !already) {
- if(!strcasecmp(word[1],MyNick)) {
- sprintf(Temp,"SAY juce %i", juiceenabled);
- xchat_command(ph, Temp);
- juiceenabled = 1-juiceenabled;
- }
- else {
- sprintf(Temp,"SAY \"%s\" isn't the owner of this bot", word[1]);
- xchat_command(ph, Temp);
- }
- //return XCHAT_EAT_NONE;
- }
- if(NULL != strstr(LowerBuffer,"nb.ppuaddris " ) && !already) {
- char tiny[74];
- int Address = strtol(word[2]+13,NULL,16);
- strcpy(Temp,"(I don't know ;-;)");
- if(Address < 0x2000) {
- sprintf(Temp, "CHR tile page %i, number %i/$%x", Address / 0x1000, (Address / 16) & 255, (Address/16)&255);
- int Row = Address % 8;
- int Plane = Address & 8;
- if(Plane != 0)
- strcat(Temp, ", second plane");
- if(Row != 0) {
- sprintf(tiny,", row %i", Row);
- strcat(Temp,tiny);
- }
- }
- if(Address <= 0x2fff && Address >= 0x2000 && !already) {
- int tile = Address & 1023;
- if(tile < 0x3c0)
- sprintf(Temp, "Nametable %i, tile %i,%i", (Address-0x2000)/1024, tile&31, (tile/32)&31);
- else {
- sprintf(Temp, "Nametable %i, attribute %i,%i", (Address-0x2000)/1024, (tile & 7), (tile/8)&7);
- }
- }
- if(Address <= 0x301f && Address >= 0x3000 && !already) {
- sprintf(Temp, "%s palette %i, (color %i in palette)", (Address>=0x3010 ?"sprite":"background"), (Address>>2)&3, Address & 3);
- }
- xchat_commandf(ph, "say PPU address is: %s", Temp);
- already=1;
- //return XCHAT_EAT_NONE;
- }
- {
- if(!strcasecmp(word[2],"nb.yiffisillegal") && !already) {
- xchat_commandf(ph, "SAY Now I'm not horny anymore. Thanks for ruining it, %s! >:(", word[1]);
- xchat_commandf(ph, "SPARK horny 0");
- already=1;
- //return XCHAT_EAT_NONE;
- }
- if(!strcasecmp(word[2],"nb.myiff") && !already) {
- xchat_commandf(ph, "YIFF %s", word[1]);
- already=1;
- //return XCHAT_EAT_NONE;
- }
- if(!strcasecmp(word[2],"nb.syiff") && !already) {
- xchat_commandf(ph, "YIFF NovaBot");
- already=1;
- //return XCHAT_EAT_NONE;
- }
- if((strstr(LowerBuffer,"nb.syiff")!=NULL||strstr(LowerBuffer,"nb.myiff")!=NULL) && !already) {
- xchat_commandf(ph, "say That command takes no argument. Try nb.pyiff instead");
- already=1;
- //return XCHAT_EAT_NONE;
- }
- }
- }
- if(!strcasecmp(word[2],"!help") && !already) {
- xchat_commandf(ph, "KICK %s 8==========D~~~~~~~~~~~~~~~~~", word[1]);
- already=1;
- //return XCHAT_EAT_NONE;
- }
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- /*
- Whenever someone gets kicked from the channel, this code runs
- */
- static int kick_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- sprintf(Temp,"SAY \02%s\x0f has been kicked by \02%s\x0f (%s)", word[2],word[1],word[4]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- /*
- Whenever someone changes their name, this code runs
- */
- static int nick_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- sprintf(Temp,"SAY \02%s\x0f is now known as \02%s\x0f", word[1],word[2]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- /*
- Whenever someone quits, this code runs
- */
- static int quit_cb(char *word[], void *userdata) {
- static char Temp[512]; Prep();
- if(IsBotOwner(word[1], xchat_get_context(ph)))
- PowerTildeLock = 0;
- sprintf(Temp,"SAY \02%s\x0f has disconnected from %s, (%s)", word[1],xchat_get_info(ph,"server"),word[2]);
- if(PrepOkay==1)
- AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
- 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;
- }
- static int nb_extcmd_cb(char *word[], char *word_eol[], void *userdata) {
- xchat_printf(ph, "Unhandled ExtCmd: %s\n", word_eol[1]);
- if(NULL != word[3])
- xchat_commandf(ph, "%s Doesn't seem to be a valid command. Check http://www.smwiki.net/wiki/NovaBot", word[3]);
- /*
- if(NULL != word[1])
- xchat_printf(ph, "1 - %s \n", word[1]);
- if(NULL != word[2])
- xchat_printf(ph, "2 - %s \n", word[2]);
- if(NULL != word[3])
- xchat_printf(ph, "3 - %s \n", word[3]);
- if(NULL != word[4])
- xchat_printf(ph, "4 - %s \n", word[4]);
- */
- return XCHAT_EAT_ALL;
- }
- static int dangerous_cb(char *word[], char *word_eol[], void *userdata) {
- return XCHAT_EAT_ALL;
- }
- int xchat_plugin_init(xchat_plugin *plugin_handle,
- char **plugin_name,
- char **plugin_desc,
- char **plugin_version,
- char *arg)
- {
- /* we need to save this for use with any xchat_* functions */
- ph = plugin_handle;
- /* tell xchat our info */
- *plugin_name = PNAME;
- *plugin_desc = PDESC;
- *plugin_version = PVERSION;
- StartTime = (unsigned)time(NULL);
- xchat_hook_print(ph, "Join", XCHAT_PRI_NORM, join_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 Action Highlight", XCHAT_PRI_NORM, emote_cb, 0);
- xchat_hook_print(ph, "Channel Message", XCHAT_PRI_NORM, message_cb, 0);
- xchat_hook_print(ph, "Channel Message Hilight", XCHAT_PRI_NORM, message_cb, 0);
- xchat_hook_print(ph, "Channel Msg Hilight", XCHAT_PRI_NORM, message_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_hook_print(ph, "Notice", XCHAT_PRI_NORM, notice_cb, 0);
- xchat_hook_print(ph, "Private Message", XCHAT_PRI_NORM, private_cb, 0);
- xchat_hook_print(ph, "Private Message to Dialog", XCHAT_PRI_NORM, private_cb, 0);
- xchat_hook_print(ph, "Change Nick", XCHAT_PRI_NORM, nick_cb, 0);
- xchat_hook_print(ph, "You Kicked", XCHAT_PRI_NORM, kicked_cb, 0);
- xchat_hook_print(ph, "You Join", XCHAT_PRI_NORM, ijoin_cb, 0);
- xchat_hook_print(ph, "You Message", XCHAT_PRI_LOWEST, imessage_cb, 0);
- xchat_hook_print(ph, "You Action", XCHAT_PRI_LOWEST, iaction_cb, 0);
- xchat_hook_print(ph, "Your Message", XCHAT_PRI_LOWEST, imessage_cb, 0);
- xchat_hook_print(ph, "Your Action", XCHAT_PRI_LOWEST, iaction_cb, 0);
- xchat_hook_print(ph, "Invited", XCHAT_PRI_NORM, invited_cb, 0);
- xchat_hook_command(ph, "exec", XCHAT_PRI_HIGH, dangerous_cb, "dangerous", 0);
- xchat_hook_command(ph, "NB_ExtCmd", XCHAT_PRI_LOWEST, nb_extcmd_cb, "Used internally by NovaBot", 0);
- xchat_print(ph, "Hello from NovaBot!\n");
- return 1; /* return 1 for success */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement