Advertisement
NovaYoshi

NovaBot

Apr 18th, 2011
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 37.23 KB | None | 0 0
  1. #include "xchat-plugin.h"
  2.  
  3. // Config settings
  4. #define MyNick "NovaYoshi"
  5. #define Enable_System 1
  6. #define Enable_Direct 1
  7. #define BITLBEE_SERVER "im.bitlbee.org"
  8.  
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include <time.h>
  12. #include <ctype.h>
  13. #include <stdlib.h>
  14. #define PNAME "NovaBot"
  15. #define PDESC "Yiffs people and does ASM stuff"
  16. #define PVERSION "5.0.1a"
  17.  
  18. static unsigned int PowerTildeLock = 1;
  19. //static char PowerTildeUnlocker[128];
  20. static int juiceenabled = 0;
  21. static int NFLines = 0;
  22. static int BPLines = 0;
  23. static int OtherLines = 0;
  24. static int CommandTriggers = 0;
  25. static int StartTime;
  26. static int Mute=0;
  27. static xchat_plugin *ph;   /* plugin handle */
  28. static int PrepOkay;
  29. static xchat_plugin *ph;   /* plugin handle, needed for any XChat call */
  30.  
  31. #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':
  32. #define any_decimal_digit    case '0':case '1':case'2':case'3':case'4':case'5':case '6':case '7': case '8':case '9':
  33. #include "rscript.c"
  34. #include "juicetypes.h"
  35.  
  36. // Change for whatever path you wanna store user data in
  37. static const char *BaseDataPath = "/home/joshua/Desktop/NovaBot/data/";
  38.  
  39. // Create a pointer to someone's database entry
  40. static char *CreateDataPath2(char *Buffer, char *Group, char *Nick, char *FileType) {
  41.   char NickBuf[64];
  42.   int i=0;
  43.   while(1) {
  44.     NickBuf[i]=tolower(Nick[i]);
  45.     if(NickBuf[i]=='/' || NickBuf[i]=='\\')
  46.       NickBuf[i] = '-';
  47.     if(0==Nick[i++])
  48.       break;
  49.   }
  50.   sprintf(Buffer, "%s%s%s%s", BaseDataPath,Group,NickBuf,FileType);
  51.   return(Buffer);
  52. }
  53.  
  54. // Check if a message starts with a given command, and if so, return the argument
  55. static int RecognizeCommand(char *Msg, const char *Cmd, char **ArgPtr) {
  56.    if(!memcmp(Msg, Cmd, strlen(Cmd))) {
  57.      *ArgPtr = Msg+strlen(Cmd);
  58.      if(**ArgPtr == 0) return(0);
  59.      return(1);
  60.    }
  61.    return(0);
  62. }
  63.  
  64. // Does CreateDataPath2() and also reads from the file
  65. static char *ReadTextDataPath2(char *Output, char *Group, char *Nick, char *FileType, char *Default) {
  66.   char Temp[512];
  67.   char *Poke;
  68.   int i;
  69.  
  70.   CreateDataPath2(Temp, Group, Nick, FileType);
  71.   FILE *Profile = fopen(Temp, "rb");
  72.   if(Profile!=NULL) {
  73.     Poke = Output;
  74.     for(i=5;i!=EOF;) {
  75.       i=fgetc(Profile);
  76.       *Poke = i;
  77.       if(i == '`'){*Poke = 0; break;}
  78.       Poke++;
  79.     }
  80.     fclose(Profile);
  81.     return(Output);
  82.   } else {
  83.     return(Default);
  84.   }
  85. }
  86.  
  87.  
  88. static void IncChannelLines() {
  89.   const char *Chan = xchat_get_info(ph,"channel");
  90.   if (Chan==NULL) return;
  91.   if(!strcasecmp(Chan,"#NovaForest")) NFLines++;
  92.   else if(!strcasecmp(Chan,"#Botplace")) BPLines++;
  93.   else OtherLines++;
  94. }
  95. static char *z80FakeMultiply(char *Result, int Find) { // nb.zmulbyadd
  96.   char Temp[100];
  97.   Temp[99]=0;     // String end
  98.   if(Find==-1){strcpy(Result,"neg");    return(Result);}
  99.   if(Find==0){strcpy(Result,"xor a");   return(Result);}
  100.   if(Find==1){strcpy(Result,"nop");     return(Result);}
  101.   if(Find<0){strcpy(Result,"Only positive numbers, please");  return(Result);}
  102.  
  103.   char *Poke = Temp+98;
  104.   while(Find != 1) {
  105.     if(Find & 1) {
  106.       Find--;
  107.       *(Poke--) = 'y';
  108.     } else {
  109.       Find>>=1;
  110.       *(Poke--) = 'x';
  111.     }
  112.     printf("%i ", Find);
  113.   }
  114.   strcpy(Result, ++Poke);
  115.   printf("\nResult is %s \n", Poke);
  116.   return(Result);
  117. }
  118.  
  119. static void z80Asm(char *Input, char *Output) {
  120.   remove("lazyass.bin");
  121.   // First we need to create a file to feed z80asm
  122.   FILE *MyFile = fopen("lazyass.asm","w");
  123.   if(MyFile==NULL) {
  124.     strcpy(Output,"unable to open lazyass.asm");
  125.     return;
  126.   }
  127.  
  128.   // Intercept all '\'s and turn them into newlines
  129.   char *Peek = Input;
  130.   while(*Peek) {
  131.     char got = *Peek;
  132.     if(got == '\\') { // new line
  133.       fputc('\r',MyFile);
  134.       fputc('\n',MyFile);
  135.     }
  136.     else
  137.       fputc(got, MyFile);
  138.     Peek++;
  139.   }
  140.  
  141.   // Now we have a file to feed z80asm
  142.   fclose(MyFile);
  143.  
  144.   char Command[512];
  145.   sprintf(Command, "z80asm -i lazyass.asm -o lazyass.bin");
  146.   int Status = system(Command);
  147.  
  148.   // Open the assembled code
  149.   MyFile = fopen("lazyass.bin","rb");
  150.   if(MyFile==NULL) {
  151.     sprintf(Output,"Unable to open lazyass.bin. (system() returned %i) I'm guessing you made a mistake in your code", Status);
  152.     return;
  153.   }
  154.  
  155.   // Now get the hex values from the compiled code
  156.   strcpy(Output,"");
  157.   char *Poke = Output;
  158.   // int len=0; // code length
  159.   int ch;
  160.   do {
  161.     char Small[7];
  162.     ch = fgetc(MyFile);
  163.     if(ch==EOF)
  164.       break;
  165.     if(ch < 16)
  166.       sprintf(Small, "0%x ",ch);
  167.     else
  168.       sprintf(Small, "%x ",ch);
  169.  
  170.     strcat(Poke,Small);
  171.   } while(ch != EOF);
  172. }
  173.  
  174. static char *text_unescape(char *Poke, char *Peek) {
  175. // Takes a string given, and interprets \n and friends
  176.   unsigned char Safe;
  177.   while(*Peek != 0) {
  178.     *Poke++ = *Peek;
  179.     if(*Peek == '\r') *(Poke-1) = ':';
  180.     if(*Peek == '\n') *(Poke-1) = '3';
  181.  
  182.     if(*Peek == '\\') {
  183.       Peek++;
  184.       switch(*Peek) {
  185.         case '\\': *(Poke-1) = '\\'; break; // Escaped '\'
  186.         case 'i': *(Poke-1)  = 0x16; break; // Italic
  187.         case 'u': *(Poke-1)  = 0x1f; break; // Underline
  188.         case 'b': *(Poke-1)  = 0x02; break; // Bold
  189.         case 'c': *(Poke-1)  = 0x03; break; // Colored
  190.         case 'p': *(Poke-1)  = 0x0f; break; // Plain
  191.        
  192.         case 'a': *(Poke-1)  = '\a'; break; // Bell
  193.         case 't': *(Poke-1)  = '\t'; break; // Tab
  194.         case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':  case '8':  case '9':
  195.           Safe = strtol(Peek,&Peek,10);
  196.           if(Safe == '\n') Safe = '$';
  197.           if(Safe == '\r') Safe = '$';
  198.           *(Poke-1) = Safe;
  199.           break;
  200.         default: *(Poke-1)   =  '?'; break; // Unrecognized
  201.       }
  202.     }
  203.     Peek++;
  204.   }
  205.   *Poke = 0;
  206.   return Poke;
  207. }
  208.  
  209. //  Look in current context to see what access level the user has
  210. static int UserMode_local(char *who) {
  211.   return 0; // Too lazy to finish the function because I don't need it just yet
  212. }
  213.  
  214. // Strips out any colors or text effects, then does a nick comparison
  215. static int MyNickCmp(char *N1, char *N2) {
  216.    static char *StripName;
  217.    StripName = xchat_strip(ph, N1, -1, 3);
  218.    if(!strcasecmp(StripName, N2)) {
  219.      xchat_free(ph, StripName);
  220.      return 0;
  221.    }
  222.    xchat_free(ph, StripName);
  223.    return 1;
  224. }
  225. static int IsBotOwner(char *Nick, xchat_context *Context) {
  226.   if(!MyNickCmp(Nick,"NovaYoshi")) return 1;
  227.   if(!MyNickCmp(Nick,"NovaRooey")) return 1;
  228.   return 0;
  229. }
  230.  
  231. static void AllOthers(char *String, const char *Origin, const char *PassServer)
  232. //Emit the command in every suitable channel but the origin
  233. {
  234.    xchat_list *list = xchat_list_get(ph, "channels");
  235.    if(list) {
  236.       while(xchat_list_next(ph, list)) {
  237.          if(!strcasecmp(xchat_list_str(ph, list, "channel"),Origin)) {
  238.                  if( strcasecmp(xchat_list_str(ph, list, "server"),PassServer)) {
  239.                 if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) == 0) {
  240.                  xchat_printf(ph,"Oops! Bad context! \n");
  241.                 }
  242.                 else {
  243.                  xchat_command(ph, String);
  244.                 }
  245.              }
  246.          }
  247.       }
  248.       xchat_list_free(ph, list);
  249.    }
  250. }
  251.  
  252. // Left over from when NovaBot was a bridgebot and not a yiffbot
  253. static void Prep() { // Make sure this context is okay
  254.     PrepOkay=0;
  255.     if(xchat_get_info(ph,"channel")==NULL) {
  256.         xchat_print(ph, "Channel returned null! \n");
  257.         return;
  258.     }
  259.     if(xchat_get_info(ph,"server")==NULL) {
  260.         xchat_print(ph, "Server returned null! \n");
  261.         return;
  262.     }
  263.     if(Mute==1)
  264.         return;
  265.     PrepOkay=1;
  266. }
  267.  
  268. // Doesn't do anything yet
  269. static int ijoin_cb(char *word[], void *userdata) {
  270.   return XCHAT_EAT_NONE;
  271. }
  272.  
  273. // Hook for receiving notices
  274. static int notice_cb(char *word[], void *userdata) {
  275.   int FindIt;
  276.   FILE *ReadPass;
  277.  
  278.   char SecurityBuff[512];
  279.   int i=0;
  280.   for(i=0;;) {
  281.     SecurityBuff[i]=tolower(word[2][i]);
  282.     if(0==word[2][i++])
  283.       break;
  284.   }
  285.  
  286.   int ErrSecurity=0;
  287.   if(RecognizeCommand(word[2], "ns ", NULL)) ErrSecurity = 1;
  288.   if(RecognizeCommand(word[2], "cs ", NULL)) ErrSecurity = 1;
  289.   if(RecognizeCommand(word[2], "msg nickserv ", NULL)) ErrSecurity = 1;
  290.   if(RecognizeCommand(word[2], "msg chanserv ", NULL)) ErrSecurity = 1;
  291.  
  292.   if(NULL!=strstr(SecurityBuff,"nickserv ")) ErrSecurity = 1;
  293.   if(NULL!=strstr(SecurityBuff,"chanserv ")) ErrSecurity = 1;
  294.   if(NULL!=strstr(SecurityBuff,"botserv "))  ErrSecurity = 1;
  295.   if(NULL!=strstr(SecurityBuff,"memoserv ")) ErrSecurity = 1;
  296.   if(NULL!=strstr(SecurityBuff,"hostserv ")) ErrSecurity = 1;
  297.   if(NULL!=strstr(SecurityBuff,"drop "))     ErrSecurity = 1;
  298.   if(NULL!=strstr(SecurityBuff,"access "))   ErrSecurity = 1;
  299.   if(NULL!=strstr(SecurityBuff,"ms "))      ErrSecurity = 1;
  300.   if(NULL!=strstr(SecurityBuff,"hs "))      ErrSecurity = 1;
  301.   if(NULL!=strstr(SecurityBuff,"bs "))      ErrSecurity = 1;
  302.   if(NULL!=strstr(SecurityBuff,"cs "))      ErrSecurity = 1;
  303.   if(NULL!=strstr(SecurityBuff,"ns "))      ErrSecurity = 1;
  304.  
  305.   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; }
  306.  
  307.   FindIt=0;
  308.  
  309.   char *ArgPtr;  
  310.  
  311.   if(IsBotOwner(word[1], xchat_get_context(ph))) { // Ignore comands if given by someone who isn't me
  312.     if(RecognizeCommand(word[2], "^~", &ArgPtr)) {
  313.       if(PowerTildeLock == 0)
  314.         xchat_commandf(ph, "NOTICE %s PowerTilde is locked right now",word[1]);
  315.       else
  316.         xchat_commandf(ph, "%s", ArgPtr);
  317.       return XCHAT_EAT_NONE;
  318.     }
  319.  
  320.     if(RecognizeCommand(word[2], "lock ", &ArgPtr)) {
  321.       ReadPass = fopen("/home/joshua/Desktop/NovaBot/tildepass.txt","rb");
  322.       if(ReadPass != NULL) {
  323.         char CheckBuffer[50];
  324.         char *PokePass = CheckBuffer;
  325.         for(i=5;i!=EOF;) {
  326.           i=fgetc(ReadPass);
  327.           *PokePass = i;
  328.           if(i == '~'){*PokePass = 0; break;}
  329.             PokePass++;
  330.         }
  331.         if(!strcasecmp(ArgPtr, CheckBuffer)) {
  332.           PowerTildeLock = 1-PowerTildeLock;
  333.           xchat_commandf(ph, "notice %s a winrar is you (%i)", word[1], PowerTildeLock);
  334.         }
  335.         else {
  336.           xchat_commandf(ph, "notice %s That isn't my password", word[1]);
  337.         }
  338.         fclose(ReadPass);
  339.       } else
  340.         xchat_commandf(ph, "notice %s file didn't open", word[1]);    
  341.     }
  342.   }
  343.  
  344.   return XCHAT_EAT_NONE;
  345. }
  346.  
  347. // Hook for when NovaBot talks
  348. static int imessage_cb(char *word[], void *userdata) {
  349.     static char Temp[512];  Prep();
  350.     // sloppy check to see if it is a bridged message already
  351.         if(word[2][0] == '*')       return XCHAT_EAT_NONE;
  352.         if(word[2][1] == '*')       return XCHAT_EAT_NONE;
  353.         if(word[2][0] == ':')       return XCHAT_EAT_NONE;
  354.         if(word[2][1] == ':')       return XCHAT_EAT_NONE;
  355.         if(word[2][0] == 2)     return XCHAT_EAT_NONE;
  356.         if(word[2][1] == 2)     return XCHAT_EAT_NONE;
  357.         sprintf(Temp, "SAY \2\2:NovaBot: %s", word[2]);
  358.     if(PrepOkay==1)
  359.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  360.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  361. }
  362.  
  363. // Hook for when NovaBot yiffs
  364. static int iaction_cb(char *word[], void *userdata) {
  365.     static char Temp[512];  Prep();
  366.     // sloppy check to see if it is a bridged message already
  367.         if(word[2][0] == '*')       return XCHAT_EAT_NONE;
  368.         if(word[2][1] == '*')       return XCHAT_EAT_NONE;
  369.         if(word[2][0] == ':')       return XCHAT_EAT_NONE;
  370.         if(word[2][1] == ':')       return XCHAT_EAT_NONE;
  371.         if(word[2][0] == 2)     return XCHAT_EAT_NONE;
  372.         if(word[2][1] == 2)     return XCHAT_EAT_NONE;
  373.         sprintf(Temp, "SAY *NovaBot %s", word[2]);
  374.     if(PrepOkay==1)
  375.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  376.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  377. }
  378.  
  379. // Handler for when someone joins so we can voice aginas
  380. static int join_cb(char *word[], void *userdata) {
  381.     static char Temp[512];  Prep();
  382.     sprintf(Temp,"SAY \02%s\x0f has joined this channel on %s", word[1],xchat_get_info(ph,"server"));
  383.         if(NULL !=strstr(word[1],"agina"))
  384.           xchat_commandf(ph, "VOICE %s", word[1]);        
  385.         if((!MyNickCmp(word[1],"agina")))
  386.           xchat_commandf(ph, "VOICE agina"); // set mode +v agina
  387.         if((!MyNickCmp(word[1],"irgin")))
  388.           xchat_commandf(ph, "VOICE irgin"); // set mode +v irgin
  389.         if((!MyNickCmp(word[1],"irgin_mobile")))
  390.           xchat_commandf(ph, "VOICE irgin_mobile"); // set mode +v irgin
  391.         if((!MyNickCmp(word[1],"iagra")))
  392.           xchat_commandf(ph, "VOICE iagra"); // set mode +v iagra
  393.  
  394.     if(PrepOkay==1)
  395.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  396.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  397. }
  398.  
  399. // For when someone leaves
  400. static int part_cb(char *word[], void *userdata) {
  401.     static char Temp[512];  Prep();
  402.     sprintf(Temp,"SAY \02%s\x0f has left this channel on %s", word[1],xchat_get_info(ph,"server"));
  403.     if(PrepOkay==1)
  404.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  405.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  406. }
  407.  
  408. // For when someone leaves and gives a reason
  409. static int partr_cb(char *word[], void *userdata) {
  410.     static char Temp[512];  Prep();
  411.     sprintf(Temp,"SAY \02%s\x0f has left this channel on %s (%s)", word[1], xchat_get_info(ph,"server"), word[4]);
  412.     if(PrepOkay==1)
  413.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  414.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  415. }
  416.  
  417. /* When the bot gets kicked, this code runs */
  418. static int kicked_cb(char *word[], void *userdata) {
  419.         if(!strcasecmp(xchat_get_info(ph, "server"),BITLBEE_SERVER))
  420.            xchat_command(ph, "JOIN &bitlbee"); // for taking over old connections
  421.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  422. }
  423.  
  424. //  Whenever someone uses /me in a channel, this code runs
  425. static int emote_cb(char *word[], void *userdata) {
  426.   static char Temp[512];  IncChannelLines(); Prep();
  427.   sprintf(Temp,"SAY *%s\x0f %s", word[1],word[2]);
  428.   if(PrepOkay==1)
  429.     AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  430.   return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  431. }
  432.  
  433. // NovaBot should join when invited
  434. static int invited_cb(char *word[], void *userdata) {
  435.   xchat_commandf(ph,"join %s",word[1]);
  436.   return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  437. }
  438.  
  439. // Pretty much the core of NovaBot
  440. static int ReactGlobalCommand(xchat_context *Context, char *Nick, char *Message, char *ReplyCmd) {
  441.    static char Temp[512];
  442.    int already = 0;
  443.    int i;
  444.    xchat_set_context(ph,Context);
  445.  
  446.    char LowerBuffer[512];
  447.    char *MkLowPeek = Message;
  448.    char *MkLowPoke = LowerBuffer;
  449.  
  450.  
  451.    while(*MkLowPeek) {
  452.      *(MkLowPoke++)=tolower(*(MkLowPeek++));
  453.    }
  454.    *MkLowPoke = 0;
  455.  
  456.    char *MessageNoPF = Message+2; // add more sophisticated way of skipping the prefix later
  457.    char *ArgPtr;                  // pass to RecognzieCommand
  458.  
  459.   if(!strcasecmp(MessageNoPF,".jumpengine")) {
  460.     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);
  461.   }
  462.   if(!strcasecmp(MessageNoPF,".episodes")) {
  463.     xchat_commandf(ph, "%s All episodes currently on Youtube: http://bit.ly/mlplist", ReplyCmd);
  464.     already = 1;
  465.   }
  466.  
  467.   if((RecognizeCommand(MessageNoPF, ".furget ", &ArgPtr)|| !strcasecmp(MessageNoPF,".furget")) && !already) {
  468.     if(!strcasecmp(MessageNoPF, ".furget")) ArgPtr = Nick;
  469.     CreateDataPath2(Temp, "furprofile/", ArgPtr, ".txt");
  470.     FILE *Profile = fopen(Temp, "rb");
  471.     if(Profile!=NULL) {
  472.       MkLowPoke = Temp;
  473.       for(i=5;i!=EOF;) {
  474.         i=fgetc(Profile);
  475.         *MkLowPoke = i;
  476.         if(i == '`'){*MkLowPoke = 0; break;}
  477.         MkLowPoke++;
  478.       }
  479.      fclose(Profile);
  480.      xchat_commandf(ph, "%s %s is: %s", ReplyCmd, ArgPtr, Temp);
  481.     } else {
  482.       xchat_commandf(ph, "%s Couldn't open the profile for %s", ReplyCmd, ArgPtr);
  483.     }
  484.     already = 1;
  485.   }
  486.  
  487.   if(RecognizeCommand(MessageNoPF, ".furset ", &ArgPtr) && !already) {
  488.     CreateDataPath2(Temp, "furprofile/", Nick, ".txt");
  489.     FILE *Profile = fopen(Temp, "wb");
  490.     if(Profile!=NULL) {
  491.      fprintf(Profile, "%s`", ArgPtr);
  492.      xchat_commandf(ph, "%s Saved :3", ReplyCmd);
  493.      fclose(Profile);
  494.     } else {
  495.       xchat_commandf(ph, "%s Couldn't open your profile", ReplyCmd);
  496.     }
  497.     already = 1;
  498.   }
  499.  
  500.  
  501.   if(RecognizeCommand(MessageNoPF, ".zmulbyadd ", &ArgPtr) && !already) {
  502.     z80FakeMultiply(Temp, strtol(ArgPtr,NULL,10));
  503.     xchat_commandf(ph, "%s List: %s", ReplyCmd, Temp);
  504.     already = 1;
  505.   }
  506.   if(RecognizeCommand(MessageNoPF, ".clean ", &ArgPtr) && !already) {
  507.     xchat_commandf(ph, "me produces a hose and sprays down %s", ArgPtr); //Message+9);
  508.     already=1;
  509.   }
  510.   if(!strcasecmp(MessageNoPF,".beep") && !already ) {
  511.     xchat_commandf(ph, "%s beep! \a",ReplyCmd);
  512.     already=1;
  513.   }
  514.   if(!strcasecmp(MessageNoPF,".wtf") && !already ) {
  515.     xchat_commandf(ph, "%s Don't worry about it, go back to bed",ReplyCmd);
  516.     already=1;
  517.   }
  518.   if(!strcasecmp(MessageNoPF,".nickfix") && !already) {
  519.     xchat_command(ph, "nick NovaBot");
  520.     already=1;
  521.   }
  522.   if(!strcasecmp(MessageNoPF,".getmeasoda") && !already) {
  523.     xchat_commandf(ph, "me hands %s a soda",Nick);
  524.     already=1;
  525.   }
  526.  
  527.   if(!strcasecmp(MessageNoPF,".help") && !already) {
  528.     //xchat_commandf(ph, "%s Check out http://www.smwiki.net/wiki/NovaBot",ReplyCmd );
  529.         xchat_commandf(ph, "%s Check out http://www.smwiki.net/wiki/NovaBot",ReplyCmd );
  530.         already=1;
  531.     //return XCHAT_EAT_NONE;
  532.   }
  533.  
  534.   if(!strcasecmp(MessageNoPF,".getmeafuckingsoda") && !already) {
  535.     xchat_commandf(ph, "me hands %s a soda which then fucks %s really hard",Nick, Nick);
  536.     already=1;
  537.   }
  538.   if(!strcasecmp(MessageNoPF,".getmeasexysoda") && !already) {
  539.     xchat_commandf(ph, "me hands %s a soda which then has sex with %s", Nick, Nick);
  540.     already=1;
  541.   }
  542.   if(RecognizeCommand(MessageNoPF, ".rand ", &ArgPtr) && !already) {
  543.     int max = strtol(ArgPtr, NULL, 10);
  544.     if(max != 0)
  545.       xchat_commandf(ph, "%s Here's your random number (modulo %i, +1): %i",ReplyCmd,max,1+rand()%max);
  546.     else
  547.       xchat_commandf(ph, "%s I'm not going to divide by zero, sorry",ReplyCmd);
  548.     already=1;
  549.   }
  550.  
  551.   if(RecognizeCommand(MessageNoPF, ".dice ", &ArgPtr) && !already) {
  552.     int dice = strtol(ArgPtr, &ArgPtr, 10);
  553.     if(NULL != ArgPtr) {
  554.       int sides = strtol(ArgPtr, &ArgPtr, 10);
  555.       int total = 0;
  556.       int num;    
  557.  
  558.       if(dice > 300)
  559.         xchat_commandf(ph, "%s I know better than to lag myself trying to roll that many", ReplyCmd);
  560. //      else if (sides == 1)
  561. //        xchat_commandf(ph, "%s What do you expect me to roll? Spheres?", ReplyCmd);
  562.       else if (sides == 0)
  563.         xchat_commandf(ph, "%s I don't have any dice with zero sides", ReplyCmd);
  564. //      else if (sides < 2)
  565. //        xchat_commandf(ph, "%s Is that even physically possible?", ReplyCmd);
  566.       else if (dice < 1)
  567.         xchat_commandf(ph, "%s I can't roll a negative number of dice", ReplyCmd);
  568.       else {
  569.         for(num = 0; num < dice; num++)
  570.           total+=1+rand()%sides;
  571.         char *DiceWord = "dice";
  572.         if(sides == 2) DiceWord = "coins";
  573.         if(sides == 1) DiceWord = "spheres";
  574.         if(sides < 0) DiceWord = "negative dice";
  575.         xchat_commandf(ph, "%s I %s %i %s, each with %i sides and got: %i",ReplyCmd,(sides!=2?"rolled":"flipped"),dice,DiceWord, sides, total);
  576.       }
  577.     }
  578.     already=1;
  579.   }
  580.  
  581.   if(!strcasecmp(MessageNoPF,".rand")  && !already) {
  582.     sprintf(Temp,"%s Here's your random number: %i",ReplyCmd,rand());
  583.     xchat_command(ph, Temp);
  584.     already=1;
  585.   }
  586.   if(!strcasecmp(MessageNoPF,".version") && !already) {
  587.     sprintf(Temp,"%s Currently running NovaBot version %s",ReplyCmd,PVERSION);
  588.     xchat_command(ph, Temp);
  589.     already=1;
  590.   }
  591.   if(RecognizeCommand(MessageNoPF, ".convbase ", &ArgPtr) && !already) {
  592.     int whatever;
  593.     switch(*ArgPtr) {
  594.       case '$':
  595.         whatever = strtol(ArgPtr+1,NULL,16);
  596.         break;
  597.       case '%':
  598.         whatever = strtol(ArgPtr+1,NULL,2);
  599.         break;
  600.       default:
  601.         whatever = strtol(ArgPtr,NULL,10);
  602.         break;
  603.     }
  604.     xchat_commandf(ph, "%s %i == $%x",ReplyCmd,whatever, whatever);
  605.   }
  606.   if(RecognizeCommand(MessageNoPF, ".zas ", &ArgPtr) && !already) {
  607.     if(strlen(LowerBuffer) > 150) {
  608.       xchat_commandf(ph,"%s Too many chars of ASM given",ReplyCmd);
  609.       already=1;
  610.     }  
  611.     else {
  612.       char Hex[2048];
  613.       z80Asm(ArgPtr,Hex);
  614.       if(strlen(Hex)>400) {
  615.         xchat_commandf(ph, "%s Assembled program is too many chars to read out",ReplyCmd);
  616.       }
  617.       else {
  618.         sprintf(Temp,"%s %s",ReplyCmd, Hex);
  619.         xchat_command(ph, Temp);
  620.       }
  621.     }
  622.   }
  623.   if(RecognizeCommand(MessageNoPF, ".pyiff ", &ArgPtr) && !already) {
  624. //    if(Message[8] == 0 || Message[9] == 0) {
  625. //      xchat_commandf(ph, "notice %s Please put the name of the person you want me to yiff after nb.pyiff",Nick);
  626. //      already=1;
  627. //    }
  628. //    else {
  629. //      xchat_commandf(ph,"say before");
  630. //      MkLowPoke = ReadTextDataPath2(Temp, "furprofile/species/", ArgPtr, ".txt", NULL);
  631. //      if(MkLowPoke == NULL)
  632.         xchat_commandf(ph, "YIFF %s", ArgPtr);
  633. //      else
  634. //        xchat_commandf(ph, "YIFF %s -ys %s ???", ArgPtr, MkLowPoke);
  635.      
  636.       already=1;
  637. //    }
  638.   }
  639.   //if(!strcasecmp(Message,"nb.nstftype")) {
  640.   //    xchat_commandf(ph, "%s okay %s", ReplyCmd, JuiceEffects[rand()%23]);
  641.   //    already=1;
  642.   //}
  643.  
  644.   if(!strcasecmp(MessageNoPF,".lines") && !already) {
  645.         sprintf(Temp,"NF:%i   BP:%i   ?:%i   Cmd: %i ",NFLines, BPLines, OtherLines, CommandTriggers);
  646.         xchat_commandf(ph, "%s %s", ReplyCmd, Temp);
  647.         //return XCHAT_EAT_NONE;
  648.                  already=1;
  649.   }
  650.  
  651.   if(!strcasecmp(MessageNoPF,".abuse")) {
  652.    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);
  653.   already = 1;
  654.   }
  655.   if(RecognizeCommand(MessageNoPF, ".calc ", &ArgPtr) && !already) {
  656.     if(strlen(LowerBuffer) > 100) {
  657.       xchat_commandf(ph,"%s Nice try :3",ReplyCmd);
  658.       already=1;
  659.     }
  660.     else {
  661.       InfoQuit Test = RunRetardScript(ArgPtr,0,1);
  662.       if(strlen(Test.Text) < 400)
  663.         xchat_commandf(ph, "%s calc: %s", ReplyCmd, Test.Text);
  664.       else
  665.         xchat_commandf(ph, "%s calc - too much on the stack to display (%i chars)", ReplyCmd, Test.Text, strlen(Test.Text));
  666.         already=1;
  667.       }
  668.   }
  669.   if(already) return 2;
  670.  
  671.   ArgPtr = "";
  672.   strcpy(Temp, MessageNoPF);
  673.   char *Find = strchr(Temp, ' ');
  674.   if(Find != NULL) {
  675.     *Find = 0;
  676.     if(Find[1]) ArgPtr = Find+1;
  677.   }
  678.   xchat_commandf(ph,"NB_ExtCmd \"%s\" \"%s\" \"%s\" -A %s", Temp+1, ReplyCmd, Nick, ArgPtr);
  679.  
  680.   return 1;    //  return already;
  681. }
  682.  
  683. // Is someone PMing the bot?
  684. static int private_cb(char *word[], void *userdata) {
  685.   static char Temp[512];
  686.   if(!strncmp(word[2] ,"nb.", 3)) {
  687.     char ReplyWith[100];
  688.     sprintf(ReplyWith, "msg %s", word[1] );
  689.     if(!ReactGlobalCommand(xchat_get_context(ph), word[1], word[2], ReplyWith))
  690.      xchat_commandf(ph,"msg %s Unrecognized command >:(", word[1]);    
  691. //    sprintf(Temp,"MSG %s 'kay, recognized as MAYBE being a command but not implemented yet", word[1]);
  692.     return XCHAT_EAT_NONE;
  693.   }
  694. // Is this from a Bitlbee connection?
  695. //  if(!strcasecmp(xchat_get_info(ph, "server"),BITLBEE_SERVER)) {
  696. //      sprintf(Temp,"MSG %s :3 %s", word[1], word[2]);
  697. //      xchat_command(ph, Temp);
  698. //    return XCHAT_EAT_NONE;
  699. //  }
  700.   if(strncmp(word[2] ,"nb.", 3)) {
  701.     sprintf(Temp,"MSG %s Not a valid command. Maybe you were trying to contact NovaYoshi instead? (use MemoServ if you have to)", word[1]);
  702.     xchat_command(ph, Temp);
  703.   }
  704.   return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  705. }
  706. /*
  707.   Whenever someone talks in a channel, this code runs
  708. */
  709. static int message_cb(char *word[], void *userdata) {
  710.    static char Temp[512];
  711.    char LowerBuffer[512];
  712.    char *MkLowPeek = word[2];  
  713.    char *MkLowPoke = LowerBuffer;
  714.    int already = 0;
  715.  
  716.    xchat_context *BackTo = xchat_get_context(ph);
  717.    IncChannelLines();
  718.  
  719.    Prep();
  720.    sprintf(Temp,"SAY \2\2:%c\2\2%s\x0f: %s", word[1][0], word[1]+1,word[2]);
  721.    if(PrepOkay==1)
  722.     AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  723.    xchat_set_context(ph,BackTo);
  724.  
  725.    while(*MkLowPeek) {
  726.      *(MkLowPoke++)=tolower(*(MkLowPeek++));
  727.    }
  728.    *MkLowPoke = 0;
  729.  
  730.    if( ( NULL != strstr(LowerBuffer,"lose") || NULL != strstr(LowerBuffer,"lost") )  && NULL != strstr(LowerBuffer," electron") )     xchat_commandf(ph, "SAY Are you sure?"); // Yes I'm positive
  731.    
  732.    if(!strcasecmp(xchat_get_info(ph,"channel"),"#novaforest")) {
  733.      if(NULL != strstr(LowerBuffer,"what the fuck") ||
  734.         NULL != strstr(LowerBuffer,"what the heck") ||
  735.         NULL != strstr(LowerBuffer,"what the hell") ||
  736.         NULL != strstr(LowerBuffer,"fucking sucks") ||
  737.         NULL != strstr(LowerBuffer,"fuckin sucks") ||
  738.         NULL != strstr(LowerBuffer,"wtf")
  739.       ) {
  740.        xchat_commandf(ph, "say Don't worry about it, go back to bed");
  741.      }
  742.    }  
  743.  
  744.    if(!MyNickCmp(word[1], "root")) // Is Bitlbee trying to talk to us?
  745.    { // automatically accept friend requests
  746.      if(NULL != strstr(word[2],"wants to add you to his/her buddy list"))
  747.        xchat_commandf(ph, "say yes");
  748.      if(NULL != strstr(word[2],"is not in your buddy list yet. Do you want to add him/her now"))
  749.        xchat_commandf(ph, "say yes");
  750.      if(NULL != strstr(word[2],"Would you like to take over this session?"))
  751.        xchat_commandf(ph, "say yes");
  752.    }
  753.  
  754.      if(word[2][0] == 'n' && word[2][1] == 'b' && word[2][2] == '.'){
  755.         CommandTriggers++;
  756.         ReactGlobalCommand(BackTo, word[1], word[2], "say");
  757.         // Crappy, useless commands
  758.  
  759. /*
  760.         if(!strcasecmp(word[2],"nb.xwho") && !already && 0 ) {
  761.                 char ServerN[512];
  762.                 char ChannelN[512];
  763.                 char TServer[512];
  764.                 char asshole[712];
  765.                 char poohole[712];
  766.                 xchat_commandf(ph, "notice %s okay, working on it", word[1]);                
  767.                 strcpy(ServerN,xchat_get_info(ph,"server"));
  768.                 strcpy(ChannelN,xchat_get_info(ph,"channel"));
  769.                 xchat_list *list = xchat_list_get(ph, "channels");
  770.                 if(list) {
  771. //                  xchat_commandf(ph, "notice %s list works", word[1]);        
  772.                   while(xchat_list_next(ph, list)) {
  773.                     if(!strcasecmp(xchat_list_str(ph, list, "channel"),ChannelN)) {
  774.                       if( strcasecmp(xchat_list_str(ph, list, "server"),ServerN)) {      
  775.                         strcpy(TServer, xchat_list_str(ph, list, "server"));
  776.                         xchat_commandf(ph, "notice %s server %s - %i users", word[1], TServer, xchat_list_int(ph,list,"users"));  
  777.                        
  778.                         if( xchat_set_context(ph,(xchat_context *)xchat_list_str(ph, list, "context")) == 0) {
  779.                       xchat_printf(ph,"Oops! Bad context! \n");
  780.                     }
  781.                     else if( (xchat_context *)xchat_list_str(ph, list, "context") == NULL ) {
  782.                       xchat_printf(ph,"Oops! Bad context! \n");
  783.                     }
  784.                         else {
  785.                           xchat_list *nicks = xchat_list_get(ph, "users");
  786.                           if(nicks) {
  787.                             xchat_print(ph,"userlist start \n");
  788.                             sprintf(poohole, "%s ",TServer);
  789.                             while(xchat_list_next(ph, list)) {
  790.                                 const char *pingas = xchat_list_str(ph, nicks, "nick");
  791.                                 if(pingas != NULL) {
  792. //                                  sprintf(asshole,"%s --, ", poohole ); //pingas);
  793. //                                  strcpy(poohole, asshole);
  794.                                 }
  795.                             }
  796.                             xchat_list_free(ph, nicks);
  797.                             xchat_set_context(ph,BackTo);
  798.                             xchat_commandf(ph, "notice %s TOTALLY RAD", word[1]);
  799.                             xchat_commandf(ph, "notice %s got %s", word[1], poohole);
  800.                           }
  801.                 }
  802.  
  803.                       }
  804.                     }
  805.                   }
  806.                 }
  807.                 xchat_list_free(ph, list);
  808.                 xchat_set_context(ph,BackTo);
  809. //                xchat_commandf(ph, "notice %s complete", word[1]);
  810.                 already=1;
  811.         }
  812. */
  813.     if(!strcasecmp(word[2],"nb.whatchannelisthis") && !already) {
  814.         sprintf(Temp,"SAY umm, I think this is %s",xchat_get_info(ph,"channel"));
  815.         xchat_command(ph, Temp);
  816.         //return XCHAT_EAT_NONE;
  817.                  already=1;
  818.         }
  819.        
  820.     if(NULL!=strstr(LowerBuffer,"nb.givejuice") && !already && (strlen(word[2])>14) ) {
  821.                 char *JuiceType = word[2]+13;
  822.                 if(strlen(JuiceType)<50) {
  823.                     if(strcasecmp(JuiceType,"Nova")) {
  824.                         xchat_commandf(ph, "me hands %s a cup of %s juice :3", word[1],     JuiceType);
  825.             } else {
  826.                 if(juiceenabled)
  827.                             xchat_commandf(ph, NovaJuiceMessage, JuiceEffects[rand()%23], word[1]);
  828.                             else
  829.                             xchat_commandf(ph, "say I'm not allowed to give that anymore :<",word[1]);
  830.             }
  831.             }
  832.                 already=1;
  833.         }
  834.     if(!strcasecmp(word[2],"nb.bridgetoggle") && !already) {
  835.         if(IsBotOwner(word[1], xchat_get_context(ph))) {
  836.             sprintf(Temp,"SAY Bridgebot has been %s", (Mute==0 ?"Muted":"Unmuted"));
  837.             xchat_command(ph, Temp);
  838.             Mute=1-Mute;       
  839.         }
  840.         else {
  841.             sprintf(Temp,"SAY \"%s\" isn't the owner of this bot", word[1]);
  842.             xchat_command(ph, Temp);
  843.         }
  844.         //return XCHAT_EAT_NONE;
  845.     }
  846.     if(!strcasecmp(word[2],"nb.juicetoggle") && !already) {
  847.         if(!strcasecmp(word[1],MyNick)) {
  848.             sprintf(Temp,"SAY juce %i", juiceenabled);
  849.             xchat_command(ph, Temp);
  850.             juiceenabled = 1-juiceenabled;     
  851.         }
  852.         else {
  853.             sprintf(Temp,"SAY \"%s\" isn't the owner of this bot", word[1]);
  854.             xchat_command(ph, Temp);
  855.         }
  856.         //return XCHAT_EAT_NONE;
  857.     }
  858.     if(NULL != strstr(LowerBuffer,"nb.ppuaddris " ) && !already) {
  859.            char tiny[74];
  860.            int Address = strtol(word[2]+13,NULL,16);
  861.            strcpy(Temp,"(I don't know ;-;)");
  862.            if(Address < 0x2000) {
  863.              sprintf(Temp, "CHR tile page %i, number %i/$%x", Address / 0x1000, (Address / 16) & 255, (Address/16)&255);
  864.              int Row = Address % 8;
  865.              int Plane = Address & 8;
  866.              if(Plane != 0)
  867.                strcat(Temp, ", second plane");
  868.              if(Row != 0) {
  869.                sprintf(tiny,", row %i", Row);
  870.                strcat(Temp,tiny);
  871.              }
  872.            }
  873.            if(Address <= 0x2fff && Address >= 0x2000 && !already) {
  874.              int tile = Address & 1023;
  875.              if(tile < 0x3c0)
  876.                sprintf(Temp, "Nametable %i, tile %i,%i", (Address-0x2000)/1024, tile&31, (tile/32)&31);
  877.              else {
  878.                sprintf(Temp, "Nametable %i, attribute %i,%i", (Address-0x2000)/1024, (tile & 7), (tile/8)&7);
  879.              }
  880.            }
  881.            if(Address <= 0x301f && Address >= 0x3000 && !already) {
  882.              sprintf(Temp, "%s palette %i, (color %i in palette)", (Address>=0x3010 ?"sprite":"background"), (Address>>2)&3, Address & 3);
  883.            }
  884.            xchat_commandf(ph, "say PPU address is: %s", Temp);
  885.             already=1;          
  886.            //return XCHAT_EAT_NONE;
  887.     }
  888.         {
  889.             if(!strcasecmp(word[2],"nb.yiffisillegal") && !already) {
  890.             xchat_commandf(ph, "SAY Now I'm not horny anymore. Thanks for ruining it, %s! >:(", word[1]);
  891.             xchat_commandf(ph, "SPARK horny 0");
  892.                      already=1;
  893.             //return XCHAT_EAT_NONE;
  894.         }
  895.         if(!strcasecmp(word[2],"nb.myiff") && !already) {
  896.             xchat_commandf(ph, "YIFF %s", word[1]);
  897.                      already=1;
  898.             //return XCHAT_EAT_NONE;
  899.         }
  900.         if(!strcasecmp(word[2],"nb.syiff") && !already) {
  901.             xchat_commandf(ph, "YIFF NovaBot");
  902.                      already=1;
  903.             //return XCHAT_EAT_NONE;
  904.         }
  905.         if((strstr(LowerBuffer,"nb.syiff")!=NULL||strstr(LowerBuffer,"nb.myiff")!=NULL) && !already) {
  906.             xchat_commandf(ph, "say That command takes no argument. Try nb.pyiff instead");
  907.                     already=1;
  908.             //return XCHAT_EAT_NONE;       
  909.         }
  910.     }
  911.  
  912.      }
  913.     if(!strcasecmp(word[2],"!help") && !already) {
  914.         xchat_commandf(ph, "KICK %s 8==========D~~~~~~~~~~~~~~~~~", word[1]);
  915.                 already=1;
  916.         //return XCHAT_EAT_NONE;
  917.     }
  918.  
  919.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  920. }
  921. /*
  922.   Whenever someone gets kicked from the channel, this code runs
  923. */
  924. static int kick_cb(char *word[], void *userdata) {
  925.     static char Temp[512]; Prep();
  926.     sprintf(Temp,"SAY \02%s\x0f has been kicked by \02%s\x0f (%s)", word[2],word[1],word[4]);
  927.     if(PrepOkay==1)
  928.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  929.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  930. }
  931. /*
  932.   Whenever someone changes their name, this code runs
  933. */
  934. static int nick_cb(char *word[], void *userdata) {
  935.     static char Temp[512]; Prep();
  936.     sprintf(Temp,"SAY \02%s\x0f is now known as \02%s\x0f", word[1],word[2]);
  937.     if(PrepOkay==1)
  938.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  939.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  940. }
  941. /*
  942.   Whenever someone quits, this code runs
  943. */
  944. static int quit_cb(char *word[], void *userdata) {
  945.     static char Temp[512]; Prep();
  946.  
  947.         if(IsBotOwner(word[1], xchat_get_context(ph)))
  948.           PowerTildeLock = 0;
  949.  
  950.     sprintf(Temp,"SAY \02%s\x0f has disconnected from %s, (%s)", word[1],xchat_get_info(ph,"server"),word[2]);
  951.     if(PrepOkay==1)
  952.         AllOthers(Temp,xchat_get_info(ph,"channel"),xchat_get_info(ph,"server"));
  953.     return XCHAT_EAT_NONE;  /* don't eat this event, xchat needs to see it! */
  954. }
  955.  
  956. void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) {
  957.     *name = PNAME;
  958.     *desc = PDESC;
  959.     *version = PVERSION;
  960. }
  961. static int nb_extcmd_cb(char *word[], char *word_eol[], void *userdata) {
  962.    xchat_printf(ph, "Unhandled ExtCmd: %s\n", word_eol[1]);
  963.    if(NULL != word[3])
  964.      xchat_commandf(ph, "%s Doesn't seem to be a valid command. Check http://www.smwiki.net/wiki/NovaBot", word[3]);
  965.  
  966. /*
  967.    if(NULL != word[1])
  968.      xchat_printf(ph, "1 - %s \n", word[1]);
  969.    if(NULL != word[2])
  970.      xchat_printf(ph, "2 - %s \n", word[2]);
  971.    if(NULL != word[3])
  972.      xchat_printf(ph, "3 - %s \n", word[3]);
  973.    if(NULL != word[4])
  974.      xchat_printf(ph, "4 - %s \n", word[4]);
  975. */
  976.  
  977.    return XCHAT_EAT_ALL;
  978. }
  979. static int dangerous_cb(char *word[], char *word_eol[], void *userdata) {
  980.    return XCHAT_EAT_ALL;
  981. }
  982. int xchat_plugin_init(xchat_plugin *plugin_handle,
  983.                       char **plugin_name,
  984.                       char **plugin_desc,
  985.                       char **plugin_version,
  986.                       char *arg)
  987. {
  988.    /* we need to save this for use with any xchat_* functions */
  989.    ph = plugin_handle;
  990.    
  991.    /* tell xchat our info */
  992.    *plugin_name = PNAME;
  993.    *plugin_desc = PDESC;
  994.    *plugin_version = PVERSION;
  995.  
  996.    StartTime = (unsigned)time(NULL);
  997.  
  998.    xchat_hook_print(ph, "Join", XCHAT_PRI_NORM, join_cb, 0);
  999.    xchat_hook_print(ph, "Part", XCHAT_PRI_NORM, part_cb, 0);
  1000.    xchat_hook_print(ph, "Part with reason", XCHAT_PRI_NORM, partr_cb, 0);
  1001.    xchat_hook_print(ph, "Channel Action", XCHAT_PRI_NORM, emote_cb, 0);
  1002.    xchat_hook_print(ph, "Channel Action Highlight", XCHAT_PRI_NORM, emote_cb, 0);
  1003.    xchat_hook_print(ph, "Channel Message", XCHAT_PRI_NORM, message_cb, 0);
  1004.    xchat_hook_print(ph, "Channel Message Hilight", XCHAT_PRI_NORM, message_cb, 0);
  1005.    xchat_hook_print(ph, "Channel Msg Hilight", XCHAT_PRI_NORM, message_cb, 0);
  1006.    xchat_hook_print(ph, "Kick", XCHAT_PRI_NORM, kick_cb, 0);
  1007.    xchat_hook_print(ph, "Quit", XCHAT_PRI_NORM, quit_cb, 0);
  1008.    xchat_hook_print(ph, "Notice", XCHAT_PRI_NORM, notice_cb, 0);
  1009.    xchat_hook_print(ph, "Private Message", XCHAT_PRI_NORM, private_cb, 0);
  1010.    xchat_hook_print(ph, "Private Message to Dialog", XCHAT_PRI_NORM, private_cb, 0);
  1011.    xchat_hook_print(ph, "Change Nick", XCHAT_PRI_NORM, nick_cb, 0);
  1012.    xchat_hook_print(ph, "You Kicked", XCHAT_PRI_NORM, kicked_cb, 0);
  1013.    xchat_hook_print(ph, "You Join", XCHAT_PRI_NORM, ijoin_cb, 0);
  1014.    xchat_hook_print(ph, "You Message", XCHAT_PRI_LOWEST, imessage_cb, 0);
  1015.    xchat_hook_print(ph, "You Action", XCHAT_PRI_LOWEST, iaction_cb, 0);
  1016.    xchat_hook_print(ph, "Your Message", XCHAT_PRI_LOWEST, imessage_cb, 0);
  1017.    xchat_hook_print(ph, "Your Action", XCHAT_PRI_LOWEST, iaction_cb, 0);
  1018.    xchat_hook_print(ph, "Invited", XCHAT_PRI_NORM, invited_cb, 0);  
  1019.    xchat_hook_command(ph, "exec", XCHAT_PRI_HIGH, dangerous_cb, "dangerous", 0);
  1020.    xchat_hook_command(ph, "NB_ExtCmd", XCHAT_PRI_LOWEST, nb_extcmd_cb, "Used internally by NovaBot", 0);
  1021.  
  1022.    xchat_print(ph, "Hello from NovaBot!\n");
  1023.    return 1;       /* return 1 for success */
  1024. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement