Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include "xchat-plugin.h"
- #define PNAME "ColorfulText"
- #define PDESC "Colorize your sending text"
- #define PVERSION "0.1.2"
- static char *color_names[]={"DEFAULT","BLACK","DARKBLUE","DARKGREEN","PINK","RED","DARKPURPLE","BROWN","YELLOW","LIGHTGREEN","DARKCYAN","LIGHTCYAN","LIGHTBLUE","LIGHTPURPLE","DARKGRAY","LIGHTGRAY"};
- static xchat_plugin *ph; /* plugin handle */
- static int color_index = 6;
- static int enable = 1;
- static char buffer[2048];
- static int your_message_callback(char *word[], char *userdata)
- {
- if(enable)
- {
- sprintf(buffer,"\003%02d%s",color_index,word[2]);
- strcpy(word[2],buffer);
- //hope word[2] is long enough to
- //add 3 bytes!
- }
- return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */
- }
- static int colorfultext_cb(char *word[], char *word_eol[], void *userdata)
- {
- int i;
- if(word[2][0]=='\0')
- {
- xchat_print(ph,"Usage: colorfultext <ColorName | toggle >, change text color to specified ColorName, or toggle on/off of colorfultext. All available color are: \nDEFAULT BLACK DARKBLUE DARKGREEN PINK RED DARKPURPLE BROWN YELLOW LIGHTGREEN DARKCYAN LIGHTCYAN LIGHTBLUE LIGHTPURPLE DARKGRAY LIGHTGRAY\n");
- xchat_printf(ph, "Current color for text is %s\n",color_names[color_index]);
- xchat_printf(ph, "Currently ColorfulText is %s\n",(enable)?"enabled":"disabled");
- }
- else
- {
- for(i=0;word[2][i]!='\0';i++)
- {
- word[2][i]=toupper(word[2][i]);
- }
- for(i=0; i< 16; i++)
- {
- if(strcmp(color_names[i],word[2])== 0)
- {
- break;
- }
- }
- if(i<16)
- {
- color_index=i;
- xchat_printf(ph, "You have changed Colorful Text's color to %s\n",color_names[color_index]);
- }
- else if(strcmp(word[2], "TOGGLE") == 0)
- {
- if(enable)
- {
- enable = 0;
- xchat_print(ph, "Colorful Text is disabled.\n");
- }
- else
- {
- enable = 1;
- xchat_print(ph, "Colorful Text is enabled.\n");
- }
- }
- else
- {
- xchat_print(ph, "Unsupported color name.\n");
- xchat_printf(ph, "Current color for text is %s\n",color_names[color_index]);
- }
- }
- return XCHAT_EAT_ALL; /* eat this command so xchat and other plugins can't process 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;
- /* tell xchat our info */
- *plugin_name = PNAME;
- *plugin_desc = PDESC;
- *plugin_version = PVERSION;
- xchat_hook_command(ph, "colorfultext", XCHAT_PRI_NORM, colorfultext_cb, "Usage: colorfultext <ColorName>, change text color to specified ColorName. All available color are: \nDEFAULT BLACK DARKBLUE DARKGREEN PINK RED DARKPURPLE BROWN YELLOW LIGHTGREEN DARKCYAN LIGHTCYAN LIGHTBLUE LIGHTPURPLE DARKGRAY LIGHTGRAY\n", 0);
- xchat_hook_print(ph, "Your Message", XCHAT_PRI_NORM, your_message_callback, 0);
- xchat_print(ph, "Colorful Text Plugin loaded successfully!\n");
- return 1; /* return 1 for success */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement