/****************************************************************************** taskbarflash.ds 1.0, 22 Jan 2006 -- Flash in taskbar on messages in X-Chat. Copyright (C) 2006 Daniel Simmons. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ******************************************************************************/ /* Specify all channels here that you want to flash on message, or leave blank to flash on all. eg: var chanFlash = new Array("#foo", "#bar"); // Flash on #foo, and #bar var chanFlash = new Array(); // Flash on all */ var chanFlash = new Array(); // Set to 1 if you want X-Chat to flash when you receive a private message var pmFlash = 1; function xchat_plugin_init() { // Register function that will trap channel message events xchat_hook_print("Channel Message", XCHAT_PRI_NORM, "chanMsgCb"); if (pmFlash == 1) { // Register function that will trap private message events xchat_hook_print("Private Message", XCHAT_PRI_NORM, "pmMsgCb"); xchat_hook_print("Private Message to Dialog", XCHAT_PRI_NORM, "pmMsgCb"); } // Register commands xchat_hook_command("setpmflash", XCHAT_PRI_NORM, "parseCmd", "Usage: SETPMFLASH <0/1>, turns taskbar flashing ON or OFF when a private message is received."); xchat_hook_command("setchanflash", XCHAT_PRI_NORM, "parseCmd", "Usage: SETCHANFLASH <0/1>, turns taskbar flashing ON or OFF when a message is received on the specified channel."); // Print feedback messages xchat_print("Message flash script loaded.") if (chanFlash.length > 0) { xchat_print("Flashing on messages from: " + chanFlash.join(" ")); } else { xchat_print("Flashing on ALL channel messages"); } xchat_print("Flashing on private messages: " + (pmFlash == 1)); } function findIndex(array, value) { var i = 0; for (i in array) { if (array[i] == value) { return i; } } return -1; } function parseCmd(command, param1, param2) { if (command == "setpmflash") { // Set value specified by user parameter pmFlash = param1; if (pmFlash == 1) { xchat_print("Taskbar flash for private message is now on."); } else { xchat_print("Taskbar flash for private message is now off."); } } else if (command == "setchanflash") { if (param1 == "all") { chanFlash = new Array(); } else if (param2 == 1) { // Add chan name to array if its not already there if (findIndex(param1) == -1) { chanFlash.push(param1); } xchat_print("Taskbar flash for channel " + param1 + " is now on."); } else { // Find chan name and remove it from array var chanIndex = findIndex(param1); if (chanIndex != -1) { chanFlash.splice(chanIndex, 1); } xchat_print("Taskbar flash for channel " + param1 + " is now off."); } } return XCHAT_EAT_ALL; } function chanMsgCb() { var i = 0; var currentChannel = xchat_get_info("channel"); if (chanFlash.length > 0) { // Only flash if the message was received on a specified channel for (i in chanFlash) { if (currentChannel == chanFlash[i]) { // Tell xchat to flash xchat_command("GUI FLASH"); // Break out of loop break; } } } // Allow others commands to continue etc. return XCHAT_EAT_NONE; } function pmMsgCb() { // Tell xchat to flash xchat_command("GUI FLASH"); // Allow others commands to continue etc. return XCHAT_EAT_NONE; }