Location: PHPKode > projects > VampMan: V:tR Character Manager > vampman-1.0.2/php-irc/modules/monmod/monmod.php
<?php
/*
+---------------------------------------------------------------------------
|   PHP-IRC v2.2.1
|   ========================================================
|   by Manick
|   (c) 2001-2006 by http://phpbots.sf.net/
|   Contact: hide@address.com
|   irc: #hide@address.com
|   ========================================
+---------------------------------------------------------------------------
|   > mon_mod module
|   > Module written by proof_of_death
|   > Contact: hide@address.com
|   > Module Version Number: 1.0
+---------------------------------------------------------------------------
|   > 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+---------------------------------------------------------------------------
|   Changes
|   =======-------
|   > If you wish to suggest or submit an update/change to the source
|   > code, email me at hide@address.com with the change, and I
|   > will look to adding it in as soon as I can.
+---------------------------------------------------------------------------
*/

class monmod extends module {


	public $title = "monmod";
	public $author = "proof_of_death";
	public $version = "1.0";
	public $dontShow = true;





	public function init()
	{
	}

	public function destroy()
	{

	}

	public function on_join($line,$args)
	{
		$channum = 0;
		if($line['fromNick'] == $this->ircClass->getNick())
			return;
		$user = $line['fromNick'];
		$channelsarr = $this->ircClass->getMaintainedChannels();
		foreach($channelsarr as $key=>$channel)
		{
			if($channel['CHANNEL'] == "#help" || $channel['CHANNEL'] == "#ooc" || $channel['CHANNEL'] == "#ooc-immature")
				continue;
			if($this->ircClass->isOnline($user, $channel['CHANNEL']))
				$channum++;
			if($channum > 1)
			{
				if(!$this->getModule("char_mod")->IsAdmin($user,$line['text']))
					$this->ircClass->sendRaw("KICK ".$line['text']." $user :you are only allowed in one character channel at a time");
				break;
			}
		}



	}


	public function op($line,$args)
	{
		if(substr($line['to'],0,1) == "#")
		{
			if(substr($args['cmd'],0,1) != "!")
				return;
			else
			{
				$channel = $line['to'];
				$user = $line['fromNick'];
			}
		}
		else
		{
			if($args['nargs'] < 2 || substr($args['arg1'],0,1) != "#")
			{
				$this->ircClass->notice($line['fromNick'], "format is : ".$line['cmd']." #channel nick", 1);
				return;
			}

			$channel = $args['arg1'];
			$user = $args['arg2'];

		}

		if(!$this->getModule("char_mod")->IsAdmin($user,$channel))
		{
			$this->ircClass->notice($line['fromNick'], "only admins can op or deop", 1);
			return;
		}
		$this->ircClass->changeMode($channel, "+", "o", $user);
		return;



	}


	public function deop($line,$args)
	{
		if(substr($line['to'],0,1) == "#")
		{
			if(substr($args['cmd'],0,1) != "!")
				return;
			else
			{
				$channel = $line['to'];
				$user = $line['fromNick'];
			}
		}
		else
		{
			if($args['nargs'] < 2 || substr($args['arg1'],0,1) != "#")
			{
				$this->ircClass->notice($line['fromNick'], "format is : ".$line['cmd']." #channel nick", 1);
				return;
			}

			$channel = $args['arg1'];
			$user = $args['arg2'];

		}

		if(!$this->getModule("char_mod")->IsAdmin($user,$channel))
		{
			$this->ircClass->notice($line['fromNick'], "only admins can op or deop", 1);
			return;
		}
		$this->ircClass->changeMode($channel, "-", "o", $user);
		return;



	}

	public function on_connect()
	{

		$this->ircClass->sendRaw("OPER php-irc ".$this->ircClass->getClientConf("password"));
//		$this->ircClass->sendRaw("OPER ".$this->ircClass->getClientConf("password"));

		$channelsarr = $this->ircClass->getMaintainedChannels();
                foreach($channelsarr as $key=>$channel)
                {
                        $this->ircClass->privMsg("ChanServ","identify ".$channel['CHANNEL']." ".$this->ircClass->getClientConf("password"), $queue = 1);
                }	
	}

	public function topic_reset($line,$args)
	{
		if($this->getModule("char_mod")->IsAdmin($line['fromNick']))
			$this->reset_topics();

	}
	private function reset_topics()
	{
		$this->ircClass->sendRaw("TOPIC #help :Discuss with the STs");
                $this->ircClass->sendRaw("TOPIC #ooc :Take a break from pretending you're a blood-sucking monster");
		
		
	}

}


?>
Return current item: VampMan: V:tR Character Manager