diff --git a/share/doc/plugins.html b/share/doc/plugins.html deleted file mode 100644 index e17f3346..00000000 --- a/share/doc/plugins.html +++ /dev/null @@ -1,1141 +0,0 @@ - - - -HexChat 2 Plugin Interface - - - - -

HexChat 2 Plugin Interface

- - -plugin20.html revision 2.9.1 -
Latest version of this document is available at: https://github.com/hexchat/hexchat/wiki/Plugins
- -

1. Documentation:

-
-1.0 Introduction -
1.1 Sample plugin -
1.2 What is word and word_eol? -
1.3 Lists and fields -
1.4 Plugins on Windows (Win32) -
1.5 Controlling the GUI -
  1.5.1 Basic Control -
  1.5.2 Custom Menu Items -
  1.5.3 System Tray -
1.6 Handling UTF-8/Unicode strings -
- -

2. Function reference:

-
-xchat_hook_command -
xchat_hook_fd -
xchat_hook_print -
xchat_hook_server -
xchat_hook_timer -
xchat_unhook -
-
xchat_command -
xchat_commandf -
xchat_print -
xchat_printf -
xchat_emit_print -
xchat_send_modes -
-
xchat_find_context -
xchat_get_context -
xchat_get_info -
xchat_get_prefs -
xchat_set_context -
-
xchat_nickcmp -
xchat_strip -
xchat_free -
-
xchat_pluginpref_set_str -
xchat_pluginpref_get_str -
xchat_pluginpref_set_int -
xchat_pluginpref_get_int -
xchat_pluginpref_delete -
xchat_pluginpref_list -
-
xchat_list_get -
xchat_list_free -
xchat_list_fields (not documented yet) -
xchat_list_next -
xchat_list_str -
xchat_list_int -
xchat_list_time -
-
xchat_plugingui_add (not documented yet) -
xchat_plugingui_remove (not documented yet) -

- -

Introduction

-Plugins for HexChat are written in C. The interface aims to keep 100% -binary compatability. This means that if you upgrade HexChat, you will -not need to recompile your plugins, they'll continue to work. The -interface doesn't depend on any structures and offsets, so compiler -versions shouldn't have an impact either. The only real requirement of -an HexChat plugin, is that it define a "xchat_plugin_init" symbol. This -is your entry point function, see the example below. You should make -all your global variables and functions static, so that a symbol -is not exported. There is no harm in exporting these symbols, but they -are not necessary and only pollute the name-space. Plugins are compiled as shared objects -(.so files), for example: -

-Most UNIX systems:
-	gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC myplugin.c -o myplugin.so
-
-MacOSX:
-	gcc -no-cpp-precomp -g -O2 -Wall -bundle -flat_namespace -undefined suppress -o myplugin.so myplugin.c
-
- -See the Windows section on how to compile a plugin -using visual studio. -

-All strings passed to and from plugins are encoded in UTF-8, regardless -of locale. What does this mean? -


- -

Sample plugin

-This simple plugin autoOps anyone who joins a channel you're in. It also -adds a new command /AUTOOPTOGGLE, which can be used to turn the feature ON -or OFF. Every HexChat plugin must define an xchat_plugin_init function, this -is the normal entry point. xchat_plugin_deinit is optional. -
-
-
-
-#include "xchat-plugin.h"
-
-#define PNAME "AutoOp"
-#define PDESC "Auto Ops anyone that joins"
-#define PVERSION "0.1"
-
-static hexchat_plugin *ph;   /* plugin handle */
-static int enable = 1;
-
-static int join_cb(char *word[], void *userdata)
-{
-   if (enable)
-      /* Op ANYONE who joins */
-      xchat_commandf(ph, "OP %s", word[1]);
-   /* word[1] is the nickname, as in the Settings->Advanced->TextEvents window in xchat */
-
-   return XCHAT_EAT_NONE;  /* don't eat this event, HexChat needs to see it! */
-}
-
-static int autooptoggle_cb(char *word[], char *word_eol[], void *userdata)
-{
-   if (!enable)
-   {
-      enable = 1;
-      xchat_print(ph, "AutoOping now enabled!\n");
-   } else
-   {
-      enable = 0;
-      xchat_print(ph, "AutoOping now disabled!\n");
-   }
-
-   return XCHAT_EAT_ALL;   /* eat this command so HexChat 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 HexChat our info */
-   *plugin_name = PNAME;
-   *plugin_desc = PDESC;
-   *plugin_version = PVERSION;
-
-   xchat_hook_command(ph, "AutoOpToggle", XCHAT_PRI_NORM, autooptoggle_cb, "Usage: AUTOOPTOGGLE, Turns OFF/ON Auto Oping", 0);
-   xchat_hook_print(ph, "Join", XCHAT_PRI_NORM, join_cb, 0);
-
-   xchat_print(ph, "AutoOpPlugin loaded successfully!\n");
-
-   return 1;       /* return 1 for success */
-}
-
-
-
- -

What's word and word_eol?

- -They are arrays of strings. They contain the parameters the user entered -for the particular command. For example, if you executed: - -
-/command NICK hi there
-
-word[1] is command
-word[2] is NICK
-word[3] is hi
-word[4] is there
-
-word_eol[1] is command NICK hi there
-word_eol[2] is NICK hi there
-word_eol[3] is hi there
-word_eol[4] is there
-
-These arrays are simply provided for your convenience. You are NOT allowed -to alter them. Both arrays are limited to 32 elements (index 31). word[0] and -word_eol[0] are reserved and should not be read. -


-

Lists and Fields

-Lists of information (DCCs, Channels, Userlist etc) can be retreived -with xchat_list_get. All fields are READ ONLY and must be copied if -needed for a long time after calling xchat_list_str. The types of lists and fields available are: -
- -"channels" - list of channels, querys and their servers. -
- - - - - - - - - - - - - - - -
NameDescriptionType
channelChannel or query namestring
chantypesChannel types e.g. "#!&"
(Added in version 2.0.9. Older versions will return NULL)
string
context(xchat_context *) pointer. Can be used with xchat_set_contextstring
flagsServer/Channel Bits:
- - - - - - - - - - - - - -
Bit #ValueDescription
01Connected
12Connecting in Progress
24You are away
38End of MOTD (Login complete)
416Has WHOX (ircu)
532Has IDMSG (FreeNode)
664Hide Join/Part Messages
7128unused (was Color Paste in old versions)
8256Beep on Message
9512Blink Tray
101024Blink Task Bar
-
(Bits 0-5 added in 2.0.9. Bits 6-8 added in 2.6.6. Bit 9 added in 2.8.0. Bit 10 in 2.8.6)
int
idUnique server ID
(Added in version 2.0.8. Older versions will return -1)
int
lagLag in milliseconds
(Added in version 2.6.8. Older versions will return -1)
int
maxmodesMaximum modes per line
(Added in version 2.0.9. Older versions will return -1)
int
networkNetwork name to which this channel belongs
(Added in version 2.0.2. Older versions will return NULL)
string
nickprefixesNickname prefixes e.g. "@+"
(Added in version 2.0.9. Older versions will return NULL)
string
nickmodesNickname mode chars e.g. "ov"
(Added in version 2.0.9. Older versions will return NULL)
string
queueNumber of bytes in the send-queue
(Added in version 2.6.8. Older versions will return -1)
int
serverServer name to which this channel belongsstring
typeType of context this is: 1-Server 2-Channel 3-Dialog
(Added in version 2.0.2. Older versions will return -1)
int
usersNumber of users in this channel
(Added in version 2.0.8. Older versions will return -1)
int
-
- -"dcc" - list of DCC file transfers. Fields: -
- - - - - - - - - - - - - - - -
NameDescriptionType
address32Address of the remote user (ipv4 address)int
cpsBytes per second (speed)int
destfileDestination full pathnamestring
fileFile namestring
nickNickname of person who the file is from/tostring
portTCP port numberint
posBytes sent/receivedint
poshighBytes sent/received, high order 32 bitsint
resumePoint at which this file was resumed (or zero if it was not resumed)int
resumehighPoint at which this file was resumed, high order 32 bitsint
sizeFile size in bytes, low order 32 bits (cast it to unsigned)int
sizehighFile size in bytes, high order 32 bitsint
statusDCC Status: 0-Queued 1-Active 2-Failed 3-Done 4-Connecting 5-Abortedint
typeDCC Type: 0-Send 1-Receive 2-ChatRecv 3-ChatSendint
-
- -"ignore" - current ignore list. -
- - - -
NameDescriptionType
maskIgnore mask. .e.g: *!*@*.aol.comstring
flagsBit field of flags. 0=Private 1=Notice 2=Channel 3=Ctcp
-4=Invite 5=UnIgnore 6=NoSave 7=DCC
int
-
- -"notify" - list of people on notify. -
- - - - - - - -
NameDescriptionType
networksNetworks to which this nick applies. Comma separated. May be NULL. -
(Added in version 2.6.8)
string
nickNicknamestring
flagsBit field of flags. 0=Is online.int
onTime when user came online.time_t
offTime when user went offline.time_t
seenTime when user the user was last verified still online.time_t
-The entire "notify" list was added in xchat 2.0.8. Fields are -only valid for the context when xchat_list_get() was called -(i.e. you get information about the user ON THAT ONE SERVER ONLY). You -may cycle through the "channels" list to find notify information for every -server. -
- -"users" - list of users in the current channel. -
- - - - - - - - -
NameDescriptionType
awayAway status (boolean)
(Added in version 2.0.6. Older versions will return -1)
int
lasttalkLast time the user was seen talking
(Added in version 2.4.2. Older versions will return -1)
time_t
nickNick namestring
hostHost name in the form: user@host (or NULL if not known).string
prefixPrefix character, .e.g: @ or +. Points to a single char.string
realnameReal name or NULL
(Added in version 2.8.6)
string
selectedSelected status in the user list, only works for retrieving the user list of the focused tab
(Added in version 2.6.1. Older versions will return -1)
int
-
- -
- -Example: -
-
-   list = xchat_list_get(ph, "dcc");
-   if(list)
-   {
-      xchat_print(ph, "--- DCC LIST ------------------\n"
-                      "File  To/From   KB/s   Position\n");
-
-      while(xchat_list_next(ph, list))
-      {
-         xchat_printf(ph, "%6s %10s %.2f  %d\n",
-             xchat_list_str(ph, list, "file"),
-             xchat_list_str(ph, list, "nick"),
-             xchat_list_int(ph, list, "cps") / 1024,
-             xchat_list_int(ph, list, "pos"));
-      }
-
-      xchat_list_free(ph, list);
-   }
-
- -
- -

Plugins on Windows (Win32)

-Yes, it can be done. All you need is either -MSVC (Visual Studio) or -MINGW, both these compilers are free to download. -Simply compile your plugin as a DLL. You should have the following files: - - -
-EXPORTS
-  xchat_plugin_init
-  xchat_plugin_deinit
-  xchat_plugin_get_info
-
- -
Leave out xchat_plugin_deinit if you don't intend to define that -function. Then, to compile, type this at your command prompt:

-
-MSVC -
 cl -O1 -MD -G5 -DWIN32 -c plugin.c
-
 link /DLL /out:plugin.dll /SUBSYSTEM:WINDOWS plugin.obj /def:plugin.def /base:0x00d40000 -

-GCC (MINGW) -
 gcc -Wall -Os -DWIN32 -c plugin.c
-
 dllwrap --def plugin.def --dllname plugin.dll plugin.o

-
-
For a complete example, have a look at the source code of the DNS Plugin, which also contains a Makefile. -

-Caveat: Plugins compiled on Win32 MUST have a -global variable called ph, which is the plugin_handle, much like -in the sample plugin above. -

- -

Controlling the GUI

-

-A simple way to perform basic GUI functions is to use the /GUI command. -You can execute this command through the input-box, or by calling -xchat_command(ph, "GUI .....");. -

-
- - - - - - - - - - - -
GUI ATTACHSame function as "Attach Window" in the HexChat menu (new for 2.6.2).
GUI DETACHSame function as "Detach Tab" in the HexChat menu (new for 2.6.2).
GUI APPLYSimilar to clicking OK in the settings window. Execute this after /SET to activate GUI changes (new for 2.8.0)
GUI COLOR nChange the tab color of the current context, where n is a number from 0 to 3.
GUI FOCUSFocus the current window or tab.
GUI FLASHFlash the taskbar button. It will flash only if the window isn't focused and will stop when it is focused by the user.
GUI HIDEHide the main HexChat window completely (this is used by the Systray plugin).
GUI ICONIFYIconify (minimize to taskbar) the current HexChat window.
GUI MSGBOX textDisplays a asynchronous message box with your text (new for 2.4.5).
GUI SHOWShow the main HexChat window (if currently hidden).
-
-

-Note, the FLASH, ICONIFY and COLOR args were added in xchat 2.0.8, they -will not work with previous versions. -

-Starting from 2.4.5 you can add your own items to the menu bar. The menu command has this syntax: -
-	MENU [-eX] [-i<ICONFILE>] [-k<mod>,<key>] [-m] [-pX] [-rX,group] [-tX] {ADD|DEL} <path> [command] [unselect command]
-For example: -
-	MENU -p5 ADD FServe
-	MENU ADD "FServe/Show File List" "fs list"
-	MENU ADD FServe/-
-	MENU -k4,101 -t1 ADD "FServe/Enabled" "fs on" "fs off"
-	MENU -e0 ADD "FServe/Do Something" "fs action"
-
-In the example above, it would be recommended to execute "MENU DEL FServe" inside your xchat_plugin_deinit function. The special item with name "-" will add a separator line. -

-Parameters and flags: -
- - - - - - - - -
-eXSet enable flag to X. -e0 for disable, -e1 for enable. This lets you create a disabled (shaded) item.
-iFILEUse an icon filename FILE (new for 2.8.0). Not supported for toggles or radio items.
-k<mod>,<key>Specify a keyboard shortcut. "mod" is the modifier which is a bitwise OR of: 1-SHIFT 4-CTRL 8-ALT in decimal. "key" is the key value in decimal, e.g. -k5,101 would specify SHIFT-CTRL-E.
-mSpecify that this label should be treated as Pango Markup language. Since forward slash ("/") is already used in menu paths, you should replace closing tags with an ASCII 003 instead e.g.: xchat_command(ph, "MENU -m ADD \"<b>Bold Menu<\003b>\""); (new for 2.6.6).
-pXSpecify a menu item's position number. e.g. -p5 will cause the item to be inserted in the 5th place. New for 2.8.0: If the position is a negative number, it will be used as an offset from the bottom/right-most item.
-rX,groupSpecify a radio menu item, with initial state X and a group name (new for 2.8.0). The group name should be the exact label of another menu item (without the path) that this item will be grouped with. For radio items, only a select command will be executed (no unselect command).
-tXSpecify a toggle menu item with an initial state. -t0 for an "unticked" item and -t1 for a "ticked" item.
-
- -If you want to change an item's toggle state or enabled flag, -just ADD an item with exactly the same name and command and specify the -tX -eX parameters you need. -

It's also possible to add items to HexChat's existing menus, for example:
-
	MENU ADD "Settings/Sub Menu"
-	MENU -t0 ADD "Settings/Sub Menu/My Setting" myseton mysetoff
-
-However, internal names and layouts of HexChat's menu may change in the future, so use at own risk. -

-Here is an example of Radio items: -
	MENU ADD "Language"
-	MENU -r1,"English" ADD "Language/English" cmd1
-	MENU -r0,"English" ADD "Language/Spanish" cmd2
-	MENU -r0,"English" ADD "Language/German" cmd3
-
-From 2.8.0, you can also change menus other than the main one (i.e popup menus). Currently they are: -
- - - - - - - - -
Root NameMenu
$TABTab menu (right click a channel/query tab or treeview row)
$TRAYSystem Tray menu
$URLURL link menu
$NICKUserlist nick-name popup menu
$CHANMenu when clicking a channel in the text area (since 2.8.4)
-
-
-	Example: MENU -p0 ADD "$TAB/Cycle Channel" cycle
-
- -
-Starting from 2.8.0 you can manipulate HexChat's system tray icon using the /TRAY command: -
- Usage: 
- TRAY -f <timeout> <file1> [<file2>] Flash tray between two icons. Leave off file2 to use default HexChat icon.
- TRAY -f <filename>                  Set tray to a fixed icon.
- TRAY -i <number>                    Flash tray with an internal icon.
-                                     2=Message 5=Highlight 8=Private 11=File
- TRAY -t <text>                      Set the tray tooltip.
- TRAY -b <title> <text>              Set the tray balloon.
-                                     Supported on Windows from 2.8.1 and 2.8.2 on Linux (libnotify required on Linux).
-
-Filenames can be ICO or PNG format. PNG format is supported on Linux/BSD and Windows XP (but requires installation of GDI+ on Windows 2000). Set a timeout of -1 to use HexChat's default. -

- -

Handling UTF-8/Unicode strings

-

-The HexChat plugin API specifies that strings passed to and from HexChat must be encoded in UTF-8. -

-What does this mean for the plugin programmer? You just have to be a little careful when -passing strings obtained from IRC to system calls. For example, if you're writing a file-server -bot, someone might message you a filename. Can you pass this filename directly to open()? Maybe! -If you're lazy... The correct thing to do is to convert the string to "system locale encoding", -otherwise your plugin will fail on non-ascii characters. -

-Here are examples on how to do this conversion on Unix and Windows. In this example, someone will -CTCP you the message "SHOWFILE <filename>". -

-

-
-static int ctcp_cb(char *word[], char *word_eol[], void *userdata)
-{
-	if(strcmp(word[1], "SHOWFILE") == 0)
-	{
-		get_file_name(nick, word[2]);
-	}
-
-	return XCHAT_EAT_XCHAT;
-}
-
-static void get_file_name(char *nick, char *fname)
-{
-	char buf[256];
-	FILE *fp;
-
-	/* the fname is in UTF-8, because it came from the HexChat API */
-
#ifdef _WIN32
-	wchar_t wide_name[MAX_PATH];
-
-	/* convert UTF-8 to WIDECHARs (aka UTF-16LE) */
-	if (MultiByteToWideChar(CP_UTF8, 0, fname, -1, wide_name, MAX_PATH) < 1)
-		return;
-
-	/* now we have WIDECHARs, so we can _wopen() or CreateFileW(). */
-	/* _wfopen actually requires NT4, Win2000, XP or newer. */
-	fp = _wfopen(wide_name, "r");
-
#else
-	char *loc_name;
-
-	/* convert UTF-8 to System Encoding */
-	loc_name = g_filename_from_utf8(fname, -1, 0, 0, 0);
-	if(!loc_name)
-		return;
-
-	/* now open using the system's encoding */
-	fp = fopen(loc_name, "r");
-	g_free(loc_name);
-
#endif
-	if (fp)
-	{
-		while (fgets (buf, sizeof(buf), fp))
-		{
-			/* send every line to the user that requested it */
-			xchat_commandf (ph, "QUOTE NOTICE %s :%s", nick, buf);
-		}
-		fclose (fp);
-	}
-}
-
- - - -

- -

Functions

- -

 xchat_hook_command() 

-Prototype: xchat_hook *xchat_hook_command(xchat_plugin *ph, const char *name, int pri, xchat_cmd_cb *callb, const char *help_text, void *userdata); -
-
Description: Adds a new /command. This allows your program to -handle commands entered at the input box. To capture text without a "/" at -the start (non-commands), you may hook a special name of "". i.e xchat_hook_command(ph, "", ...);. -
-Starting from version 2.6.8, commands hooked that begin with a period ('.') will be hidden in /HELP and /HELP -l. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
name: Name of the command (without the forward slash). -
pri: Priority of this command. Use XCHAT_PRI_NORM. -
callb: Callback function. This will be called when the user executes the given command name. -
help_text: String of text to display when the user executes /help for this command. May be NULL if you're lazy. -
userdata: Pointer passed to the callback function.
-Returns: Pointer to the hook. Can be passed to xchat_unhook. -
-
Example: -
-
-static int onotice_cb(char *word[], char *word_eol[], void *userdata)
-{
-	if(word_eol[2][0] == 0)
-	{
-		xchat_printf(ph, "Second arg must be the message!\n");
-		return XCHAT_EAT_ALL;
-	}
-
-	xchat_commandf(ph, "NOTICE @%s :%s", xchat_get_info(ph, "channel"), word_eol[2]);
-	return XCHAT_EAT_ALL;
-}
-
-xchat_hook_command(ph, "ONOTICE", XCHAT_PRI_NORM, onotice_cb,
-                   "Usage: ONOTICE <message> Sends a notice to all ops", NULL);
-
-
-
- -

 xchat_hook_fd() 

-Prototype: xchat_hook *xchat_hook_fd(xchat_plugin *ph, int fd, int flags, xchat_fd_cb *callb, void *userdata); -
-
Description: Hooks a socket or file descriptor. WIN32: Passing a pipe from MSVCR71, MSVCR80 or other variations is not supported at this time. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
fd: The file descriptor or socket. -
flags: One or more of XCHAT_FD_READ, XCHAT_FD_WRITE, XCHAT_FD_EXCEPTION, XCHAT_FD_NOTSOCKET. Use bitwise OR to combine them. -XCHAT_FD_NOTSOCKET tells HexChat that the provided fd is not a socket, but a "MSVCRT.DLL" pipe. -
callb: Callback function. This will be called when the socket is available for reading/writing or exception (depending on your chosen flags) -
userdata: Pointer passed to the callback function.
-Returns: Pointer to the hook. Can be passed to xchat_unhook. -


- -

 xchat_hook_print() 

-Prototype: xchat_hook *xchat_hook_print(xchat_plugin *ph, const char *name, int pri, xchat_print_cb *callb, void *userdata); -
-
Description: Registers a function to trap any print events. -The event names may be any available in the "Advanced > Text Events" window. -There are also some extra "special" events you may hook using this function. -Currently they are:
-"Open Context" - Called when a new xchat_context is created. -
"Close Context" - Called when a xchat_context pointer is closed. -
"Focus Tab" - Called when a tab is brought to front. -
"Focus Window" - Called a toplevel window is focused, or the main -tab-window is focused by the window manager. -
"DCC Chat Text" - Called when some text from a DCC Chat arrives. It provides these elements in the word[] array:
word[1] Address -
word[2] Port -
word[3] Nick -
word[4] The Message -
-"Key Press" - Called when some keys are pressed in the input-box (since 2.4.2). It provides these elements in the word[] array:
word[1] Key Value -
word[2] State Bitfield (shift, capslock, alt) -
word[3] String version of the key -
word[4] Length of the string (may be 0 for unprintable keys) -
-
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
name: Name of the print event (as in Edit Event Texts Window). -
pri: Priority of this command. Use XCHAT_PRI_NORM. -
callb: Callback function. This will be called when this event name is printed. -
userdata: Pointer passed to the callback function.
-Returns: Pointer to the hook. Can be passed to xchat_unhook. -
-
Example: -
-
-static int youpart_cb(char *word[], void *userdata)
-{
-	xchat_printf(ph, "You have left channel %s\n", word[3]);
-	return XCHAT_EAT_XCHAT;	/* dont let HexChat do its normal printing */
-}
-
-xchat_hook_print(ph, "You Part", XCHAT_PRI_NORM, youpart_cb, NULL);
-
-
-
- -

 xchat_hook_server() 

-Prototype: xchat_hook *xchat_hook_server(xchat_plugin *ph, const char *name, int pri, xchat_serv_cb *callb, void *userdata); -
-
Description: Registers a function to be called when a certain server event occurs. You can -use this to trap PRIVMSG, NOTICE, PART, a server numeric etc... If you want to -hook every line that comes from the IRC server, you may use the special name of "RAW LINE". -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
name: Name of the server event. -
pri: Priority of this command. Use XCHAT_PRI_NORM. -
callb: Callback function. This will be called when this event is received from the server. -
userdata: Pointer passed to the callback function.
-Returns: Pointer to the hook. Can be passed to xchat_unhook. -
-
Example: -
-
-static int kick_cb(char *word[], char *word_eol[], void *userdata)
-{
-	xchat_printf(ph, "%s was kicked from %s (reason=%s)\n", word[4], word[3], word_eol[5]);
-	return XCHAT_EAT_NONE;	/* don't eat this event, let other plugins and HexChat see it too */
-}
-
-xchat_hook_server(ph, "KICK", XCHAT_PRI_NORM, kick_cb, NULL);
-
-
-
- -

 xchat_hook_timer() 

-Prototype: xchat_hook *xchat_hook_timer(xchat_plugin *ph, int timeout, xchat_timer_cb *callb, void *userdata); -
-
Description: Registers a function to be called every "timeout" milliseconds. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
timeout: Timeout in milliseconds (1000 is 1 second). -
callb: Callback function. This will be called every "timeout" milliseconds. -
userdata: Pointer passed to the callback function.
-Returns: Pointer to the hook. Can be passed to xchat_unhook. -
-
Example: -
-
-static xchat_hook *myhook;
-
-static int stop_cb(char *word[], char *word_eol[], void *userdata)
-{
-	if(myhook != NULL)
-	{
-		xchat_unhook(ph, myhook);
-		myhook = NULL;
-		xchat_print(ph, "Timeout removed!\n");
-	}
-
-	return XCHAT_EAT_ALL;
-}
-
-static int timeout_cb(void *userdata)
-{
-	xchat_print(ph, "Annoying message every 5 seconds! Type /STOP to stop it.\n");
-	return 1;	/* return 1 to keep the timeout going */
-}
-
-myhook = xchat_hook_timer(ph, 5000, timeout_cb, NULL);
-xchat_hook_command(ph, "STOP", XCHAT_PRI_NORM, stop_cb, NULL, NULL);
-

-
- -

 xchat_unhook() 

-Prototype: void *xchat_unhook(xchat_plugin *ph, xchat_hook *hook); -
-
Description: Unhooks any hook registered with xchat_hook_print/server/timer/command. When plugins are unloaded, all of its hooks are automatically -removed, so you don't need to call this within your xchat_plugin_deinit() function. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
hook: Pointer to the hook, as returned by xchat_hook_*. -
-Returns: The userdata you originally gave to xchat_hook_*. -

- -

 xchat_command() 

-Prototype: void xchat_command(xchat_plugin *ph, const char *command); -
-
Description: Executes a command as if it were typed in HexChat's input box. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
command: Command to execute, without the forward slash "/". -

-
- -

 xchat_commandf() 

-Prototype: void xchat_commandf(xchat_plugin *ph, const char *format, ...); -
-
Description: Executes a command as if it were typed in HexChat's input box and provides string formating like printf. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
format: The format string. -

-
- -

 xchat_print() 

-Prototype: void xchat_print(xchat_plugin *ph, const char *text); -
-
Description: Prints some text to the current tab/window. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
text: Text to print. May contain mIRC color codes. -

-
- -

 xchat_printf() 

-Prototype: void xchat_printf(xchat_plugin *ph, const char *format, ...); -
-
Description: Prints some text to the current tab/window and provides formating like printf. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
format: The format string. -

-
- -

 xchat_emit_print() 

-Prototype: int xchat_emit_print(xchat_plugin *ph, const char *event_name, ...); -
-
Description: Generates a print event. This can be any -event found in the Preferences > Advanced > Text Events window. The vararg parameter list -MUST always be NULL terminated. Special care should be taken when calling this function -inside a print callback (from xchat_hook_print), as not to cause endless recursion. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
event_name: Text event to print. -

-
-Returns: 1-Success 0-Failure. -

-Example: -
-xchat_emit_print(ph, "Channel Message", "John", "Hi there", "@", NULL);
-
-

- -

 xchat_send_modes() (new for 2.0.9)

-Prototype: void xchat_send_modes (xchat_plugin *ph, const char *targets[], int ntargets, int modes_per_line, char sign, char mode) -
-
Description: Sends a number of channel mode changes to the current channel. For example, you can Op a whole -group of people in one go. It may send multiple MODE lines if the request doesn't fit on one. Pass 0 for -modes_per_line to use the current server's maximum possible. This function should only be called while -in a channel context. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
targets: Array of targets (strings). The names of people whom the action will be performed on. -
ntargets: Number of elements in the array given. -
modes_per_line: Maximum modes to send per line. -
sign: Mode sign, '-' or '+'. -
mode: Mode char, e.g. 'o' for Ops.
-
-Example: (Ops the three names given) -
-const char *names_to_Op[] = {"John", "Jack", "Jill"};
-xchat_send_modes(ph, names_to_Op, 3, 0, '+', 'o');
-
-

- -

 xchat_find_context() 

-Prototype: xchat_context *xchat_find_context(xchat_plugin *ph, const char *servname, const char *channel); -
-
Description: Finds a context based on a channel and servername. If servname is NULL, it finds any channel (or query) by the given name. If channel is NULL, it finds the front-most tab/window of the given servname. If NULL is given for both arguments, the currently focused tab/window will be returned.
-Changed in 2.6.1. If servname is NULL, it finds the channel (or query) by the given name in the same server group as the current context. If that doesn't exists then find any by the given name. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
servname: Servername or NULL. -
channel: Channelname or NULL. -
-
-Returns: Context pointer (for use with xchat_set_context) or NULL. -


- -

 xchat_get_context() 

-Prototype: xchat_context *xchat_get_context(xchat_plugin *ph); -
-
Description: Returns the current context for your plugin. You can use this later with xchat_set_context. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
-
-Returns: Context pointer (for use with xchat_set_context). -


- -

 xchat_get_info() 

-Prototype: const char *xchat_get_info(xchat_plugin *ph, const char *id); -
-
Description: Returns information based on your current context. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
id: ID of the information you want. Currently supported IDs are (case sensitive): -
- - - - - - - - - - - - - - - - - - - - -
awayaway reason or NULL if you are not away.
channelcurrent channel name.
charsetcharacter-set used in the current context (since 2.4.2).
event_text <name>text event format string for name (since 2.8.2).
gtkwin_ptr(GtkWindow *) (since 2.8.9).
hostreal hostname of the server you connected to.
inputboxthe input-box contents, what the user has typed (since 2.4.1).
libdirfslibrary directory. e.g. /usr/lib/xchat. The same directory used for auto-loading plugins (since 2.4.0).This string isn't necessarily UTF-8, but local file system encoding.
modeschannel modes, if known, or NULL (since 2.8.1).
networkcurrent network name or NULL.
nickyour current nick name.
nickservnickserv password for this network or NULL (since 2.4.3).
servercurrent server name (what the server claims to be). NULL if you are not connected.
topiccurrent channel topic.
versionxchat version number.
win_ptrnative window pointer. Unix: (GtkWindow *) Win32: HWND (since 2.6.0).
win_statuswindow status: "active", "hidden" or "normal" (since 2.0.9).
xchatdirxchat config directory, e.g.: /home/user/.xchat2 This string is encoded in UTF-8, which means you _should_ convert it to "locale" encoding before using functions like open() or OpenFile(). For best Unicode support on Linux, convert this string using g_filename_from_utf8 and on Windows convert this string to UTF-16LE (wide) and use OpenFileW() etc.
xchatdirfsxchat config directory, e.g.: /home/user/.xchat2 (since 2.0.9).This string is encoded in local file system encoding, making it ideal for direct use with functions like open() or OpenFile(). For real Unicode support on Windows, it's best not to use HexChatdirfs, but HexChatdir instead.
-
-
-Returns: A string of the requested information, or NULL. This string must -not be freed and must be copied if needed after the call to xchat_get_info. -


- -

 xchat_get_prefs() 

-Prototype: int xchat_get_prefs(xchat_plugin *ph, const char *name, const char **string, int *integer); -
-
Description: Provides xchat's setting information (that which is available through the /set command). -A few extra bits of information are available that don't appear in the /set list, currently they are: -
-
- - - -
state_cursorCurrent input-box cursor position (characters, not bytes). Since 2.4.2.
idUnique server id. Since 2.6.1.
-
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
name: Setting name required. -
string: Pointer-pointer which to set. -
integer: Pointer to an integer to set, if setting is a Boolean or Integer type. -
-Returns: 0-Failed 1-Returned a string 2-Returned an Integer 3-Returned a Boolean. -

Example: -
-
-{
-	int i;
-	const char *str;
-
-	if (xchat_get_prefs (ph, "irc_nick1", &str, &i) == 1)
-	{
-		xchat_printf (ph, "Current nickname setting: %s\n", str);
-	}
-}
-
-

- - -

 xchat_set_context() 

-Prototype: int xchat_set_context(xchat_plugin *ph, xchat_context *ctx); -
-
Description: Changes your current context to the one given. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
ctx: Context to change to (obtained with xchat_get_context or xchat_find_context). -
-
-Returns: 1 for success, 0 for failure. -


- -

 xchat_nickcmp() 

-Prototype: int xchat_nickcmp(xchat_plugin *ph, const char *s1, const char *s2); -
-
Description: Performs a nick name comparision, based on the current server connection. This might be a RFC1459 compliant string compare, or -plain ascii (in the case of DALNet). Use this to compare channels and nicknames. The function works the same way as strcasecmp. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
s1: String to compare. -
s2: String to compare s1 to. -
-
-Quote from RFC1459: -
- Because of IRC's scandanavian origin, the characters {}| are - considered to be the lower case equivalents of the characters []\, - respectively. This is a critical issue when determining the - equivalence of two nicknames. -
-Returns: - An integer - less than, equal to, or greater than zero if s1 is found, - respectively, to be less than, to match, or be greater than s2. -


- -

 xchat_strip() (new for 2.4.2)

-Prototype: char *xchat_strip(xchat_plugin *ph, const char *str, int len, int flags); -
-
Description: Strips mIRC color codes and/or text attributes (bold, underlined etc) from the given string and returns a newly allocated string. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
str: String to strip. -
len: Length of the string (or -1 for NULL terminated). -
flags: Bit-field of flags: 0-Strip mIRC colors, 1-Strip text attributes. -
-
-Returns: -A newly allocated string or NULL for failure. You must free this string with xchat_free. -

Example: -
-
-{
-	char *new_text;
-
-	/* strip both colors and attributes by using the 0 and 1 bits (1 BITWISE-OR 2) */
-	new_text = xchat_strip(ph, "\00312Blue\003 \002Bold!\002", -1, 1 | 2);
-
-	if(new_text)
-	{
-		/* new_text should now contain only "Blue Bold!" */
-		xchat_printf(ph, "%s\n", new_text);
-		xchat_free(ph, new_text);
-	}
-}
-
- -

- -

 xchat_free() (new for 2.4.2)

-Prototype: void xchat_free(xchat_plugin *ph, void *ptr); -
-
Description: Frees a string returned by xchat_* functions. Currently only used to free strings from xchat_strip. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
ptr: Pointer to free. -
-
- -

- -

 xchat_pluginpref_set_str() (new for 2.9.0)

-Prototype: int xchat_pluginpref_set_str (xchat_plugin *ph, const char *var, const char *value); -
-
Description: Saves a plugin-specific setting with string value to a plugin-specific config file. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
var: Name of the setting to save. -
value: String value of the the setting. -
-
-Returns: 1 for success, 0 for failure. -

Example: -
-
int xchat_plugin_init (xchat_plugin *plugin_handle,
-			char **plugin_name,
-			char **plugin_desc,
-			char **plugin_version,
-			char *arg)
-{
-	ph = plugin_handle;
-	*plugin_name = "Tester Thingie";
-	*plugin_desc = "Testing stuff";
-	*plugin_version = "1.0";
-
-	xchat_pluginpref_set_str (ph, "myvar1", "I want to save this string!");
-	xchat_pluginpref_set_str (ph, "myvar2", "This is important, too.");
-
-	return 1;       /* return 1 for success */
-}
-
-In the example above, the settings will be saved to the plugin_tester_thingie.conf file, and its content will be: -
-
myvar1 = I want to save this string!
-myvar2 = This is important, too.
-
-You should never need to edit this file manually. -


- -

 xchat_pluginpref_get_str() (new for 2.9.0)

-Prototype: int xchat_pluginpref_get_str (xchat_plugin *ph, const char *var, char *dest); -
-
Description: Loads a plugin-specific setting with string value from a plugin-specific config file. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
var: Name of the setting to load. -
dest: Array to save the loaded setting's string value to. -
-
-Returns: 1 for success, 0 for failure. -


- -

 xchat_pluginpref_set_int() (new for 2.9.0)

-Prototype: int xchat_pluginpref_set_int (xchat_plugin *ph, const char *var, int value); -
-
Description: Saves a plugin-specific setting with decimal value to a plugin-specific config file. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
var: Name of the setting to save. -
value: Decimal value of the the setting. -
-
-Returns: 1 for success, 0 for failure. -

Example: -
-
static int saveint_cb (char *word[], char *word_eol[], void *user_data)
-{
-	int buffer = atoi (word[2]);
-
-	if (buffer > 0 && buffer < INT_MAX)
-	{
-		if (xchat_pluginpref_set_int (ph, "myint1", buffer))
-		{
-			xchat_printf (ph, "Setting successfully saved!\n");
-		}
-		else
-		{
-			xchat_printf (ph, "Error while saving!\n");
-		}
-	}
-	else
-	{
-		xchat_printf (ph, "Invalid input!\n");
-	}
-
-	return XCHAT_EAT_XCHAT;
-}
-
-You only need these kind of complex checks if you're saving user input, which can be non-numeric. -


- -

 xchat_pluginpref_get_int() (new for 2.9.0)

-Prototype: int xchat_pluginpref_get_int (xchat_plugin *ph, const char *var); -
-
Description: Loads a plugin-specific setting with decimal value from a plugin-specific config file. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
var: Name of the setting to load. -
-
-Returns: The decimal value of the requested setting upon success, -1 for failure. -


- -

 xchat_pluginpref_delete() (new for 2.9.0)

-Prototype: int xchat_pluginpref_delete (xchat_plugin *ph, const char *var); -
-
Description: Deletes a plugin-specific setting from a plugin-specific config file. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
var: Name of the setting to delete. -
-
-Returns: 1 for success, 0 for failure. If the given setting didn't exist, it also returns 1, so 1 only indicates that the setting won't exist after the call. -


- -

 xchat_pluginpref_list() (new for 2.9.0)

-Prototype: int xchat_pluginpref_list (xchat_plugin *ph, char *dest); -
-
Description: Builds a comma-separated list of the currently saved settings from a plugin-specific config file. -
-
Arguments: -
ph: Plugin handle (as given to xchat_plugin_init). -
dest: Array to save the list to. -
-
-Returns: 1 for success, 0 for failure (nonexistent, empty or inaccessible config file). -


- - -