All pastes #578947 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-20 13:04 UTC
rendered paste body
<?php
	class Net_SmartIRC_module_main {
		var $name = "main";
		var $version = "1.0";
		var $description = "Module: main";
		var $author = "Brian Johnson <brian@dogtoe.com";
		var $license = "GPL";
		
		var $actions = array();
		
		function module_init(&$irc) {
			$this->actions[] = $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL|SMARTIRC_TYPE_QUERY, '^!quit$', $this, 'quit');
			$this->actions[] = $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL|SMARTIRC_TYPE_QUERY, '^!reconnect$', $this, 'reconnect');
			$this->actions[] = $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!time$', $this, 'time');
			$this->actions[] = $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!date$', $this, 'time');
		}
		
		function module_exit(&$irc) {
        		foreach ($this->actions as $value) {
            		$irc->unregisterActionid($value);
        		}
    		}
		
		function quit(&$irc, &$data) {
			global $bot;
			if ($bot->master == $data->nick) {
            		$irc->disconnect();
            		exit;
        		}
		}
		
		function reconnect(&$irc, &$data) {
			global $bot;
        		if ($bot->master == $data->nick) {
				$irc->reconnect();
			}
    		}
    		
		function time(&$irc, &$data) {
			$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Date & Time: " . date("r"));
    		}
	}
?>