Exemple #1
0
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 = name;
	*plugin_desc = desc;
	*plugin_version = version;

	xchat_hook_command (ph, "SASL", XCHAT_PRI_NORM, sasl_cmd_cb, sasl_help, 0);
	xchat_hook_print (ph, "Connected", XCHAT_PRI_NORM, connect_cb, NULL);
	/* xchat_hook_print (ph, "Disconnected", XCHAT_PRI_NORM, disconnect_cb, NULL); */
	xchat_hook_server (ph, "CAP", XCHAT_PRI_NORM, cap_cb, NULL);
	xchat_hook_server (ph, "RAW LINE", XCHAT_PRI_NORM, server_cb, NULL);
	xchat_hook_server (ph, "903", XCHAT_PRI_NORM, authend_cb, NULL);
	xchat_hook_server (ph, "904", XCHAT_PRI_NORM, authend_cb, NULL);
	xchat_hook_server (ph, "905", XCHAT_PRI_NORM, authend_cb, NULL);
	xchat_hook_server (ph, "906", XCHAT_PRI_NORM, authend_cb, NULL);
	xchat_hook_server (ph, "907", XCHAT_PRI_NORM, authend_cb, NULL);

	xchat_printf (ph, "%s plugin loaded\n", name);

	return 1;
}
static VALUE static_ruby_xchat_hook_command( VALUE klass,
                                             VALUE name,
                                             VALUE priority,
                                             VALUE help )
{
  char *s_name;
  char *s_help;
  int   i_priority;

  xchat_hook *hook;
  VALUE       v_hook;

  Check_Type( name, T_STRING );
  Check_Type( priority, T_FIXNUM );
  Check_Type( help, T_STRING );

  s_name = StringValueCStr( name );
  i_priority = FIX2INT( priority );
  s_help = StringValueCStr( help );

  hook = xchat_hook_command( static_plugin_handle,
                             s_name,
                             i_priority,
                             static_ruby_custom_command_hook,
                             s_help,
                             NULL );
  v_hook = Data_Wrap_Struct( static_xchat_hook_klass,
                             NULL, NULL,
                             hook );

  return v_hook;
}
Exemple #3
0
int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg){
	ph = plugin_handle;
	*plugin_name = "mpcInfo";
	*plugin_desc = "Information-Script for Media Player Classic"; 
	*plugin_version=VERSION;

	xchat_hook_command(ph, "mpc", XCHAT_PRI_NORM, mpc_tell,"no help text", 0);
	xchat_hook_command(ph, "mpc_themes", XCHAT_PRI_NORM, print_themes,"no help text", 0);
	xchat_hook_command(ph, "mpc_reloadthemes", XCHAT_PRI_NORM, mpc_themeReload,"no help text", 0);
	xchat_command (ph, "MENU -ietc\\music.png ADD \"Window/Display Current Song (MPC)\" \"MPC\"");

	themeInit();
	loadThemes();
	xchat_printf(ph, "%s %s plugin loaded\n",*plugin_name, VERSION);

	return 1;
}
Exemple #4
0
int
xchat_plugin_init (xchat_plugin * plugin_handle, char **plugin_name,
						 char **plugin_desc, char **plugin_version, char *arg)
{
	if (initialized != 0) {
		xchat_print (plugin_handle, "Perl interface already loaded\n");
		return 0;
	}

	ph = plugin_handle;
	initialized = 1;

	*plugin_name = "Perl";
	*plugin_desc = "Perl scripting interface";
	*plugin_version = PACKAGE_VERSION;

	xchat_hook_command (ph, "load", XCHAT_PRI_NORM, perl_command_load, 0, 0);
	xchat_hook_command (ph, "unload", XCHAT_PRI_NORM, perl_command_unload, 0,
							  0);
	xchat_hook_command (ph, "reload", XCHAT_PRI_NORM, perl_command_reload, 0,
							  0);
	xchat_hook_command (ph, "pl_reload", XCHAT_PRI_NORM, perl_command_reload, 0,
							  0);
	xchat_hook_command (ph, "unloadall", XCHAT_PRI_NORM,
							  perl_command_unloadall, 0, 0);
	xchat_hook_command (ph, "reloadall", XCHAT_PRI_NORM,
							  perl_command_reloadall, 0, 0);

	/*perl_init (); */
	xchat_hook_timer (ph, 0, perl_auto_load, NULL );

	xchat_print (ph, "Perl interface loaded\n");

	return 1;
}
Exemple #5
0
int
xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;

	*plugin_name = name;
	*plugin_desc = desc;
	*plugin_version = version;

	xchat_hook_command (ph, "EXEC", XCHAT_PRI_NORM, run_command, "Usage: /EXEC [-O] - execute commands inside XChat", 0);
	xchat_printf (ph, "%s plugin loaded\n", name);

	return 1;       /* return 1 for success */
}
Exemple #6
0
/* Xchat::Internal::hook_command(name, priority, callback, help_text, userdata) */
static
XS (XS_Xchat_hook_command)
{
	char *name;
	int pri;
	SV *callback;
	char *help_text = NULL;
	SV *userdata;
	xchat_hook *hook;
	HookData *data;

	dXSARGS;

	if (items != 5) {
		xchat_print (ph,
						 "Usage: Xchat::Internal::hook_command(name, priority, callback, help_text, userdata)");
	} else {
		name = SvPV_nolen (ST (0));
		pri = (int) SvIV (ST (1));
		callback = ST (2);

		/* leave the help text has NULL if the help text is undefined to avoid
		 * overriding the default help message for builtin commands */
		if (SvOK(ST (3))) {
			help_text = SvPV_nolen (ST (3));
		}

		userdata = ST (4);
		data = NULL;

		data = malloc (sizeof (HookData));
		if (data == NULL) {
			XSRETURN_UNDEF;
		}

		data->callback = sv_mortalcopy (callback);
		SvREFCNT_inc (data->callback);
		data->userdata = sv_mortalcopy (userdata);
		SvREFCNT_inc (data->userdata);
		data->depth = 0;
		data->package = NULL;
		hook = xchat_hook_command (ph, name, pri, command_cb, help_text, data);

		XSRETURN_IV (PTR2IV (hook));
	}

}
Exemple #7
0
int
xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;

	*plugin_name = name;
	*plugin_desc = desc;
	*plugin_version = version;

	firstRun = 1;

	xchat_hook_command (ph, "WINSYS", XCHAT_PRI_NORM, printInfo, NULL, NULL);
	xchat_command (ph, "MENU -ietc\\system.png ADD \"Window/Display System Info\" \"WINSYS\"");

	xchat_printf (ph, "%s plugin loaded\n", name);

	return 1;       /* return 1 for success */
}
int
#ifdef STATIC
timer_plugin_init
#else
xchat_plugin_init
#endif
				(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;

        *plugin_name = "Timer";
        *plugin_desc = "IrcII style /TIMER command";
        *plugin_version = "";

        xchat_hook_command(ph, "TIMER", XCHAT_PRI_NORM, timer_cb, HELP, 0);

        return 1; /* return 1 for success */
}
Exemple #9
0
int
xchat_plugin_init (xchat_plugin * plugin_handle,
                   char **plugin_name, char **plugin_desc,
                   char **plugin_version, char *arg)
{
    ph = plugin_handle;

    *plugin_name = "XDCC";
    *plugin_desc = "Very simple XDCC server";
    *plugin_version = "0.1";

    xchat_hook_command (ph, "XDCC", XCHAT_PRI_NORM, xdcc_command, 0, 0);
    xchat_hook_print (ph, "CTCP Generic", XCHAT_PRI_NORM, ctcp_cb, 0);
    xchat_hook_print (ph, "CTCP Generic to Channel", XCHAT_PRI_NORM, ctcp_cb,
                      0);

    xdcc_load ();
    xchat_print (ph, "XDCC loaded. Type /XDCC for help.\n");

    return 1;
}
Exemple #10
0
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;

	*plugin_name = "Winamp";
	*plugin_desc = "Winamp plugin for HexChat";
	*plugin_version = "0.5";

	xchat_hook_command (ph, "WINAMP", XCHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
   	xchat_command (ph, "MENU -ietc\\music.png ADD \"Window/Display Current Song (Winamp)\" \"WINAMP\"");

	xchat_print (ph, "Winamp plugin loaded\n");

	return 1;       /* return 1 for success */
}
Exemple #11
0
int
xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;

	*plugin_name = name;
	*plugin_desc = desc;
	*plugin_version = version;

	/* this is required for the very first run */
	if (xchat_pluginpref_get_int (ph, "limit") == -1)
	{
		xchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT);
	}

	xchat_hook_command (ph, "CHECKSUM", XCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", 0);
	xchat_hook_print (ph, "DCC RECV Complete", XCHAT_PRI_NORM, dccrecv_cb, NULL);
	xchat_hook_print (ph, "DCC Offer", XCHAT_PRI_NORM, dccoffer_cb, NULL);

	xchat_printf (ph, "%s plugin loaded\n", name);
	return 1;
}
Exemple #12
0
/* 
 * lua:  xchat.hook_command(name, func_name, prio, help_str, data)
 * desc: 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( "", ...)
 * 		Starting from version 2.6.8, commands hooked that begin with a 
 * 		period ('.') will be hidden in /HELP and /HELP -l. 
 * ret:  true... or false if something went wrong while registering hook
 * args: 
 *       * name (string): the name of the new command
 *       * func_name (string): the lua function to be called when command is
 *          entered
 *       * prio (number): use one of the xchat.PRIO_*
 *       * help_str (string): help for the new command... use nil for no help
 *       * data (table): table with strings, numbers and booleans, which will
 *         be passed to func_name as last argument.
 */
static int lxc_hook_command(lua_State *L)
{
	xchat_hook *hook;
	const char *help, *command, *func;
	double prio;
	struct lxc_hooks *hooks, *h;
	struct lxc_States *st;
	struct lxc_cbdata *cb;


	if (lua_gettop(L) < 5) /* expand to five args if necessary */
		lua_settop(L, 5);

	cb = malloc(sizeof(struct lxc_cbdata));
	if (!cb) {
		xchat_printf(ph, "lxc_hook_command(): failed to malloc: %s", 
																	strerror(errno));
		lua_pushboolean(L, 0);
		return 1;
	}

	cb->state = L;
	cb->data = NULL;

	command 	= luaL_checkstring(L, 1);
	func     = luaL_checkstring(L, 2);
	cb->func = func;
	cb->hook = NULL;

	if (lua_type(L, 3) == LUA_TNIL)
		prio = XCHAT_PRI_NORM;
	else
		prio = luaL_checknumber(L, 3);

	if (lua_type(L, 4) == LUA_TSTRING) {
		help = luaL_checkstring(L, 4);
		if (strlen(help) == 0)
			help = NULL;
	}
	else
		help = NULL;
	
	if (lxc_get_userdata(5, cb) == 0) 
		lua_pushboolean(L, 0);
	else {
		h = malloc(sizeof(struct lxc_hooks));
		if (!h) {
			xchat_printf(ph, "lxc_hook_command(): failed to malloc: %s", 
																	strerror(errno));
			lua_pushboolean(L, 0);
			return 1;
		}
		hook    = xchat_hook_command(ph, command, prio, lxc_run_hook, help, cb);
		h->hook = hook;
		h->name = command;
		h->next = NULL;
		st      = lxc_states;
		while (st) {
			if (st->state == L) {
				if (!st->hooks) 
					st->hooks = h;
				else {
					hooks     = st->hooks;
					while (hooks->next) 
						hooks = hooks->next;
					hooks->next = h;
				}
				break;
			}
			st = st->next;
		}
		lua_pushboolean(L, 1);
	}
	return 1;
}
Exemple #13
0
int xchat_plugin_init(xchat_plugin *plugin_handle,
                      char **plugin_name,
                      char **plugin_desc,
                      char **plugin_version,
                      char *arg)
{
	struct lxc_States	*state;	
	lua_State *L;
	const char *xdir;
	const char *name, *desc, *vers;
	char *xsubdir;
   /* we need to save this for use with any xchat_* functions */
   ph = plugin_handle;

   /* tell xchat our info */
   *plugin_name = LXC_NAME;
   *plugin_desc = LXC_DESC;
   *plugin_version = LXC_VERSION;

	xchat_hook_command(ph, "LOAD", XCHAT_PRI_NORM, lxc_cb_load, NULL, NULL);
	xchat_hook_command(ph, "UNLOAD", XCHAT_PRI_NORM, lxc_cb_unload, NULL, NULL);
	xchat_hook_command(ph, "LUA", XCHAT_PRI_NORM, lxc_cb_lua, "Usage: LUA <code>, executes <code> in a new lua state", NULL);

	xdir = xchat_get_info (ph, "xchatdirfs");
	xsubdir = g_build_filename (xdir, "addons", NULL);
	lxc_autoload_from_path (xsubdir);
	g_free (xsubdir);

	/* put this here, otherwise it's only displayed when a script is autoloaded upon start */
	xchat_printf(ph, "Lua interface loaded");

	if (!lxc_states) /* no scripts loaded */
		return 1;
	
	state = lxc_states;
	while (state) {
		L = state->state;
		lua_pushstring(L, "xchat_register");
		lua_gettable(L, LUA_GLOBALSINDEX);
		if (lua_pcall(L, 0, 3, 0)) {
			xchat_printf(ph, "Lua plugin: error registering script %s", 	
								lua_tostring(L, -1));
			lua_pop(L, 1);
			state = state->next;
			continue;
		}

		name = lua_tostring(L, -3);
		desc = lua_tostring(L, -2);
		vers = lua_tostring(L, -1);
		lua_pop(L, 4); /* func + 3 ret value */
		state->gui = xchat_plugingui_add(ph, state->file, name, desc, vers, NULL);

		lua_pushstring(L, "xchat_init");
		lua_gettable(L, LUA_GLOBALSINDEX);
		if (lua_type(L, -1) != LUA_TFUNCTION) 
			lua_pop(L, 1);
		else {
			if (lua_pcall(L, 0, 0, 0)) {
				xchat_printf(ph, "Lua plugin: error calling xchat_init() %s", 	
								lua_tostring(L, -1));
				lua_pop(L, 1);
			}
		}
		state = state->next;
	}
	return 1; 
}