Advertising
Paste Description for Norbot 1
88.249.36.188
- Norbot 1
- Thursday, April 17th, 2008 at 8:30:39am MDT
- //===================================================================
- //========================CLASS.PHP==================================
- //===================================================================
- <?php
- class ZeroBot {
- // Class variables
- var $perform = true;
- function ZeroBot () {
- // Define some default values.
- $this->CONFIG['nick'] = "Norbot36";
- $this->CONFIG['ident'] = "Norek Bot ". VERSION;
- $this->buffer['old_buffer'] = "";
- $this->buffer['new'] = false;
- $this->CONFIG['admin'] = "";
- }
- function connect () {
- // if configured, connect.
- if (!$this->con['socket']) {
- $this->error("Could not connect to: ". $this->CONFIG['server'] ." on port ". $this->CONFIG['port']);
- } else {
- $this->send("USER ". $this->CONFIG['nick'] ." ". $this->CONFIG['server'] ." ". $this->CONFIG['server'] ." :". $this->CONFIG['ident']);
- $this->send("NICK ". $this->CONFIG['nick'] ." ". $this->CONFIG['server']);
- }
- } else {
- $this->error("Not configured correctly!");
- }
- }
- function newData () {
- // check if there's new data to be read, and handle if ping.
- $this->buffer['new'] = false;
- $this->buffer['all'] = $data;
- if ($this->perform) {
- $this->perform();
- }
- return false;
- }
- $this->parse_buffer();
- $this->buffer['new'] = true;
- return true;
- }
- return false;
- }
- function perform () {
- // actions to be done on connect.
- $this->join($this->CONFIG['chan'], $this->CONFIG['key']);
- $this->perform = false;
- }
- function printData () {
- // output the data
- }
- }
- function writeToLog () {
- // Functie waarmee je logs kan maken.
- $file = "C:\web\www\bot2\Logs\\" . $this->buffer['parsed']['channel'] . ".txt";
- }
- function events () {
- // check which event needs to be triggered, and trigger it.
- } elseif (!empty($this->CONFIG['admin']) && strtolower($this->buffer['parsed']['username']) == strtolower($this->CONFIG['admin'])) {
- }
- }
- $this->onNumeric($this->buffer['parsed']['text'], $this->buffer['parsed']['channel'], $this->buffer['parsed']['target']);
- }
- $this->onNick($this->buffer['parsed']['old'], $this->buffer['parsed']['new']);
- }
- $this->onJoin($this->buffer['parsed']['username'], $this->buffer['parsed']['channel']);
- }
- $this->onPart($this->buffer['parsed']['username'], $this->buffer['parsed']['channel']);
- }
- if (strtoupper($this->buffer['parsed']['command']) == "MODE" && strtoupper($this->buffer['parsed']['channel']) != strtoupper($this->CONFIG['nick'])) {
- $this->onMode($this->buffer['parsed']['username'], $this->buffer['parsed']['channel'], $this->buffer['parsed']['text']);
- }
- elseif (strtoupper($this->buffer['parsed']['command']) == "MODE" && strtoupper($this->buffer['parsed']['channel']) == strtoupper($this->CONFIG['nick'])) {
- $this->onUserMode($this->buffer['parsed']['username'], $this->buffer['parsed']['text']);
- }
- }
- }
- function setServer ($server, $port = 6667) {
- $this->CONFIG['server'] = $server;
- $this->CONFIG['port'] = $port;
- } else {
- $this->error("Need valid server adres");
- }
- }
- function setName ($name = "ZeroBot", $ident = false) {
- $this->CONFIG['nick'] = $name;
- if ($ident) {
- $this->CONFIG['ident'] = $ident . " [Zero bot v". VERSION . " by DaeDaluz]";
- }
- }
- function setChannel ($chan, $key = "") {
- $this->CONFIG['chan'] = $chan;
- } else {
- $this->CONFIG['chan'] = "#" . $chan;
- }
- $this->CONFIG['key'] = $key;
- }
- function setAdmin ($nick) {
- $this->CONFIG['admin'] = $nick;
- }
- function error ($error) {
- }
- function send ($data, $output = true) {
- if ($output) {
- }
- }
- function connected () {
- return true;
- } else {
- return false;
- }
- }
- // Make sense of the input data.
- function parse_buffer() {
- $buffer = NUll;
- $buffer = $this->buffer['all'];
- } else {
- }
- case "JOIN":
- $buffer['text'] = $buffer['username']." ( ".$buffer['user_host']." )";
- $buffer['command'] = "JOIN";
- $buffer['channel'] = $buffer[2];
- }
- break;
- case "QUIT":
- $buffer['text'] = $buffer['username']." ( ".$buffer['user_host']." )";
- $buffer['command'] = "QUIT";
- $buffer['channel'] = "";
- break;
- case "NOTICE":
- $buffer['command'] = "NOTICE";
- $buffer['channel'] = $buffer[2];
- break;
- case "PART":
- $buffer['text'] = $buffer['username']." ( ".$buffer['user_host']." )";
- $buffer['command'] = "PART";
- $buffer['channel'] = $buffer[2];
- break;
- case "MODE":
- } else {
- $buffer['text'] = $buffer[3];
- }
- $buffer['command'] = "MODE";
- $buffer['channel'] = $buffer[2];
- break;
- case "NICK":
- $buffer['text'] = $buffer['username']." => ". $buffer[2]." ( ".$buffer['user_host']." )";
- $buffer['old'] = $buffer['username'];
- $buffer['new'] = $buffer[2];
- $buffer['command'] = "NICK";
- $buffer['channel'] = "";
- break;
- $buffer['text'] = $buffer[3];
- $buffer['command'] = "NUMERIC";
- $buffer['channel'] = $buffer[1];
- $buffer['target'] = $buffer[2];
- break;
- default:
- $buffer['command'] = $buffer[1];
- $buffer['channel'] = $buffer['username'];
- } else {
- $buffer['channel'] = $buffer[2];
- }
- break;
- }
- $this->buffer['parsed'] = $buffer;
- }
- }
- function meIson ($chan) {
- return true;
- } else {
- return false;
- }
- }
- $this->send("JOIN " . $chan . " " . $key);
- }
- function msg ($chan, $msg) {
- $this->send('PRIVMSG '. $chan .' :'.$msg);
- }
- function ctcp ($to, $msg) {
- }
- function part ($chan) {
- $this->send("PART " . $chan);
- }
- function quit ($msg = "Zerobot singing off..") {
- $this->send("QUIT :" . $msg);
- }
- function mode ($chan, $modes) {
- $this->send("MODE ". $chan . " " . $modes);
- }
- function Op ($chan, $nick) {
- $this->mode ($chan, "+o " . $nick);
- }
- function deOp ($chan, $nick) {
- $this->mode ($chan, "-o " . $nick);
- }
- function changeName ($name) {
- $this->send("NICK :" . $name);
- }
- function randomName () {
- $this->changeName($newName);
- }
- function storeUsers () {
- $text = $this->buffer['parsed']['text'];
- } else {
- $getal = 0;
- }
- $this->usersOnChannel[$exp[0]][$getal]['nick'] = $exp[4];
- $this->usersOnChannel[$exp[0]][$getal]['ident'] = $exp[1];
- $this->usersOnChannel[$exp[0]][$getal]['host'] = $exp[2];
- $this->usersOnChannel[$exp[0]][$getal]['info'] = $exp[7];
- }
- function ison ($chan, $nick) {
- foreach ($this->usersOnChannel[$chan] as $value) {
- return true;
- }
- }
- return false;
- }
- function onMode ($nick, $chan, $modes) {
- $extrac = 1;
- if ($value == "+") {
- $temp = true;
- } elseif ($value == "-") {
- $temp = false;
- } else {
- if ($temp) {
- $tmp['mode'] = $value;
- $tmp['ex'] = $split[$extrac];
- if ($value == "o") {
- $this->onOp($nick, $chan, $split[$extrac]);
- }
- $extrac++;
- }
- $plus[] = $tmp;
- } else {
- $tmp['mode'] = $value;
- $tmp['ex'] = $split[$extrac];
- if ($value == "o") {
- $this->onDeop($nick, $chan, $split[$extrac]);
- }
- $extrac++;
- }
- $min[] = $tmp;
- }
- }
- }
- }
- function onUserMode ($nick, $modes) {
- $extrac = 1;
- if ($value == "+") {
- $temp = true;
- } elseif ($value == "-") {
- $temp = false;
- } else {
- if ($temp) {
- foreach ($this->onUserMode as $key => $val) {
- if ("+" . $value . "" == $val['mode']) {
- break;
- }
- }
- } else {
- foreach ($this->onUserMode as $key => $val) {
- if ("-" . $value . "" == $val['mode']) {
- break;
- }
- }
- }
- }
- }
- }
- function onNumeric ($text, $numeric) {
- if ($this->buffer['parsed']['target'] != $this->CONFIG['nick'] && $this->buffer['parsed']['target'] != "*") {
- $this->CONFIG['nick'] = $this->buffer['parsed']['target'];
- }
- if ($numeric == '433') {
- if ($exp[0] == $this->CONFIG['nick']) {
- $this->randomName();
- }
- }
- foreach ($this->onNumeric as $key => $val) {
- if ($numeric == $val['numeric']) {
- break;
- }
- }
- }
- function onNick ($old, $new) {
- if ($this->buffer['parsed']['old'] == $this->CONFIG['nick']) {
- $this->CONFIG['nick'] = $this->buffer['parsed']['new'];
- }
- }
- function onOp ($by, $chan, $on) {
- if (strtolower($on) == strtolower($this->CONFIG['nick']) && strtolower($chan) == strtolower($this->CONFIG['chan'])) {
- $this->CONFIG['secured'] = true;
- $this->mode($chan, '+ims');
- }
- }
- function onDeop ($by, $chan, $on) {
- $this->deop($chan, $by);
- $this->op($chan, $on);
- }
- }
- function onPart($nick, $chan) {
- }
- } else {
- foreach ($this->onPart as $key => $val) {
- $this->JPProcess($val, $key);
- }
- }
- }
- }
- }
- function onJoin($nick, $chan) {
- }
- }
- foreach ($this->onJoin as $key => $val) {
- $this->JPProcess($val, $key);
- }
- }
- }
- }
- function JPProcess ($val, $key) {
- if (in_array_i($key, $val['chan'])) {
- $chan_s = true;
- } else {
- $chan_s = false;
- }
- $chan_s = true;
- } else {
- $chan_s = false;
- }
- } else {
- $chan_s = true;
- }
- if (in_array_i($this->buffer['parsed']['username'], $val['nick'])) {
- $nick_s = true;
- } else {
- $nick_s = false;
- }
- $nick_s = true;
- } else {
- $nick_s = false;
- }
- } else {
- $nick_s = true;
- }
- if ($nick_s && $chan_s) {
- foreach ($val['para'] as $waarde) {
- }
- } else {
- }
- }
- }
- function onCtcp ($text) {
- $trig = $trig[0];
- $text = $trig[1];
- foreach ($this->onCtcp as $key => $val) {
- foreach ($val['para'] as $sleutell => $par) {
- $para[] = $par;
- }
- } else {
- }
- break;
- }
- }
- }
- }
- function tokenRep ($string, $zin) {
- foreach ($output as $value) {
- }
- }
- foreach ($output as $value) {
- }
- }
- return $string;
- }
- function onText ($text) {
- foreach ($this->onText as $key => $val) {
- foreach ($val['para'] as $sleutel => $waarde) {
- break;
- } else {
- $val['para'][$sleutel] = $this->tokenRep($waarde, $trig[1]);
- }
- }
- foreach ($val['para'] as $sleutell => $par) {
- }
- } else {
- }
- break;
- }
- }
- }
- }
- function newOnText ($trigger, $cmd, $reqPar = 0, $para = "") {
- $this->onText[$getal]['trigger'] = $trigger;
- $this->onText[$getal]['cmd'] = $cmd;
- $this->onText[$getal]['req'] = $reqPar;
- $this->onText[$getal]['para'] = $para;
- } else {
- $this->error("The number of required parameters must be an INT");
- }
- } else {
- $this->error("Trigger required");
- }
- } else {
- $this->error("Not callable function! :" . $cmd);
- }
- }
- function newOnCtcp ($trigger, $cmd, $reqPar = 0, $para = "") {
- $this->onCtcp[$getal]['trigger'] = $trigger;
- $this->onCtcp[$getal]['cmd'] = $cmd;
- $this->onCtcp[$getal]['req'] = $reqPar;
- $this->onCtcp[$getal]['para'] = $para;
- } else {
- $this->error("The number of required parameters must be an INT");
- }
- } else {
- $this->error("Trigger required");
- }
- } else {
- $this->error("Not callable function! :" . $cmd);
- }
- }
- function newOnJoin ($cmd, $para = "", $nick = "", $chan = "") {
- $this->onJoin[$getal]['cmd'] = $cmd;
- $this->onJoin[$getal]['para'] = $para;
- $this->onJoin[$getal]['nick'] = $nick;
- $this->onJoin[$getal]['chan'] = $chan;
- } else {
- $this->error("Parameters must be in array format!");
- }
- } else {
- $this->error("Not callable function! :" . $cmd);
- }
- }
- function newOnPart ($cmd, $para = "", $nick = "", $chan = "") {
- $this->onPart[$getal]['cmd'] = $cmd;
- $this->onPart[$getal]['para'] = $para;
- $this->onPart[$getal]['nick'] = $nick;
- $this->onPart[$getal]['chan'] = $chan;
- } else {
- $this->error("Parameters must be in array format!");
- }
- } else {
- $this->error("Not callable function! :" . $cmd);
- }
- }
- function newOnUserMode ($mode, $cmd) {
- $this->onUserMode[$getal]['mode'] = $mode;
- $this->onUserMode[$getal]['cmd'] = $cmd;
- } else {
- $this->error("Not callable function! :" . $cmd);
- }
- }
- function newOnNumeric ($numeric, $cmd) {
- $this->onNumeric[$getal]['numeric'] = $numeric;
- $this->onNumeric[$getal]['cmd'] = $cmd;
- } else {
- $this->error("Not callable function! :" . $cmd);
- }
- }
- }
- function in_array_i($search, &$array) {
- foreach ($array as $item)
- return TRUE;
- return FALSE;
- }
- ?>
- //===================================================================
- //========================INDEX.PHP==================================
- //===================================================================
- <?php
- include("class.php");
- $bot = new ZeroBot;
- $bot->setServer("irc.gtanet.com");
- $bot->setName("Norbot36", "AKAZAR");
- $bot->setChannel("#norek.test");
- $bot->setAdmin("[TNC]Norek");
- // newOnText( String trigger, String Functie, Int required parameters [, Array parameter]);
- // newOnText( String trigger, String functie, int required parameters [, Array parameters]);
- $bot->newOnCtcp('version', 'ctcp', 0, Array("*nick", "( :: ZeroBot :: ) [v*version] ( :: by DaeDaluz :: )"));
- // newOnUserMode(string usermode, string functie);
- $bot->newOnUserMode('+xviw', 'perform');
- // newOnNumerc(string numeric, string functie);
- $bot->newOnNumeric('352', 'storeUsers');
- // newOnJoin('String functie, Array parameters [, String on who ] [, String channel]);
- // newOnPart('String functie, Array parameters [, String on who ] [, String channel]);
- $bot->connect();
- while ($bot->connected()) {
- if ($bot->newData()) {
- $bot->printData();
- $bot->events();
- }
- }
- ?>
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.