plugin.id = "zc-autoperform"; // This script auto connect this.autoConnections specified networks, a one-minute delays;
// Check the connection every this.checkTime minutes and auto reconnect 'offline-mode'.
plugin.init = // This script can also hide your virtual IP for all connected networks, (true) if you want it.
function _init( glob ) {
this.major = 1; // Major version number.
this.minor = 0; // Minor version number.
this.version = this.major + '.' + this.minor + ' (06 Mar 2010)';
this.description = 'Auto Connect and Reconnect some Networks. '+
'By MakOke <gboxlan@gmail.com>';
// ============================================= Settings ====================================
this.autoConnections = [ 'arrakis', 'moznet', 'mindforge' ]; // Networks.
this.checkTime = 10; // Minutes.
this.prefary.push( ['hidehost', false, ''] ); // Virtual IP.
// ========================================================================================
this.cmds = [ ['hidehost', cmdHideHost, CMD_CONSOLE | CMD_NO_HELP | CMD_NEED_NET] ];
this.privacity = isPluginInstalled( 'ctcp-privacity' );
if( !client.getConnectionCount() )
attachNetworks( this.autoConnections, this.privacity );
return "OK";
}
plugin.enable =
function _enable() {
this.commands = client.commandManager.defineCommands( this.cmds );
this.checkPoint = checkInterval( this.autoConnections, this.privacity,
this.prefs['hidehost'], this.checkTime );
return true;
}
plugin.disable =
function _disable() {
clearInterval( this.checkPoint );
delete this.checkPoint;
client.commandManager.removeCommands( this.commands );
return true;
}
function cmdHideHost( e ) {
for( var i = 0; i < client.viewsArray.length; i++ )
if( client.viewsArray[i].source.TYPE == 'IRCNetwork' )
client.viewsArray[i].source.lastServer.me.host = typeof( undefined );
}
function isPluginInstalled( pluginId ) {
for( var i = 0; i < client.plugins.length; i++ )
if( client.plugins[i].id == pluginId )
return i;
return false;
}
function attachNetworks( autoConnections, privacity ) {
var privacityEnabled = privacity? client.plugins[privacity].enabled: false;
if( privacityEnabled )
dispatchTimeout( 'disable-plugin ctcp-privacity', 10 );
for( var i = 0; i < autoConnections.length; i++ )
dispatchTimeout( 'attach irc://' + autoConnections[i] + '/', ( i+1 ) * 60 );
if( privacityEnabled )
dispatchTimeout( 'enable-plugin ctcp-privacity', ( autoConnections.length+2 ) * 60 );
}
function dispatchTimeout( cmd, secs ) {
this.cmd = function() { dispatch( cmd ); };
return setTimeout( this.cmd, secs * 1000 );
}
function checkInterval( autoConnections, privacity, hidehost, mins ) {
this.func = function() {
if( !client.getConnectionCount() )
attachNetworks( autoConnections, privacity );
if( hidehost )
cmdHideHost();
};
return setInterval( this.func, mins * 60000 );
}
Download File zc-autoperform.js 3.0 KB