1<?php 2/* Based on parts of Example.php from SmartIRC 3 * Example.php Copyright (c) 2002-2003 Mirco "MEEBEY" Bauer <mail@meebey.net> <http://www.meebey.net> 4 * SRB2MS.php Copyright (c) 2004 by Logan Arias of Sonic Team JR. 5 * 6 * the Rest is Copyright (c) 2004 Logan Arias <Logan.GBA@gmail.net> 7 * This is LGPL! that means you can change and use as you like 8 * 9 * Full LGPL License: <http://www.meebey.net/lgpl.txt> 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 */ 25include_once('./SmartIRC.php'); 26define('MAGPIE_DIR', './magpierss/'); 27// define('MAGPIE_CACHE_AGE', 30); // half-min 28require_once(MAGPIE_DIR.'rss_fetch.inc'); 29require_once(MAGPIE_DIR.'rss_utils.inc'); 30$today = getdate(); 31$lastupdatetime = mktime($today['hours'],$today['minutes']-6,0,$today['mon'], $today['mday'], $today['year']); 32$lastlisttime = mktime($today['hours'],$today['minutes']-1,0,$today['mon'], $today['mday'], $today['year']); 33 34class SRB2MS_BOT 35{ 36 37 function ListUsersPM(&$irc, &$data) 38 { 39 global $rssdatabase; 40 if ($rssdatabase->users[0]) 41 { 42 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, 'List of RSS users'); 43 foreach ($rssdatabase->users as $users) 44 { 45 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "$users"); 46 } 47 } 48 else 49 { 50 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, 'there are no RSS users'); 51 } 52 } 53 54 function RSSupdateuser(&$irc, &$data) 55 { 56 global $rssdatabase; 57 if ($rssdatabase->OnList("$data->nick")) 58 { 59 $irc->message(SMARTIRC_TYPE_NOTICE, $data->message, "I am trying to update $data->nick to $data->message from the list"); 60 if ($rssdatabase->ReplaceUser("$data->nick","$data->message")) 61 { 62 $irc->message(SMARTIRC_TYPE_NOTICE, $data->message, "I have changed $data->nick to $data->message on the list"); 63 } 64 else 65 { 66 $irc->message(SMARTIRC_TYPE_NOTICE, $data->message, "$data->nick was not on the list"); 67 } 68 } 69 } 70 71 function RSScheckuser(&$irc, &$data) 72 { 73 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "I going to check if you are on the list"); 74 global $rssdatabase; 75 if ($rssdatabase->OnList("$data->nick")) 76 { 77 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "you are on the list"); 78 } 79 else 80 { 81 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "you are not on the list"); 82 } 83 } 84 85 function RSSremoveuser(&$irc, &$data) 86 { 87 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "I am trying to remove $data->nick from the list"); 88 global $rssdatabase; 89 if ($rssdatabase->DeleteUser("$data->nick")) 90 { 91 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "I have removed $data->nick from the list"); 92 } 93 else 94 { 95 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "$data->nick is not on the list"); 96 } 97 } 98 99 function RSSadduser(&$irc, &$data) 100 { 101 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "I am trying to add you $data->nick to the list"); 102 global $rssdatabase; 103 if ($rssdatabase->AddUser("$data->nick")) 104 { 105 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "I have added $data->nick to the list"); 106 } 107 else 108 { 109 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "$data->nick is already on the list"); 110 } 111 } 112/* 113 function RSSListGamesPM(&$irc, &$data) 114 { 115 $content = $this->GenFeed(); 116 $SRB2MSRSS10 = new MagpieRSS( $content ); 117 if ($SRB2MSRSS10) 118 { 119 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, 'Running SRB2 netgames '); 120 foreach ($SRB2MSRSS10->items as $item) 121 { 122 $description = $item['dc']['description']; 123 $title = $item['title']; 124 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "Name: $title $description"); 125 } 126 } 127 else 128 { 129 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, '.magpie_error()'); 130 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, 'The SRB2 MasterServer RSS feed is not up'); 131 } 132 } 133*/ 134 function RSSListUpdate(&$irc) 135 { 136 global $lastupdatetime; 137 global $SRB2MS_mute; 138 if ($SRB2MS_mute) 139 { 140 return; 141 } 142 $RSS10content = $this->GenFeed(); 143 $SRB2MSRSS10 = new MagpieRSS( $RSS10content ); 144 if ($SRB2MSRSS10) 145 { 146 //$irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun', 'Running SRB2 netgames '); 147 foreach ($SRB2MSRSS10->items as $item) 148 { 149 if ( $item['title'] == "No servers" ) 150 { 151 // NOP 152 } 153 elseif ( $item['title'] == "No master server" ) 154 { 155 // NOP 156 } 157 else 158 { 159 $published = parse_w3cdtf($item['dc']['date']); 160 if ( $published >= $lastupdatetime ) 161 { 162 $title = $item['title']; 163 $serveraddress = $item['srb2ms']['address']; 164 $serverport = $item['srb2ms']['port']; 165 $serverversion = $item['srb2ms']['version']; 166 //if ( $serverversion == "1.09.3" ) 167 //{ 168 // $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun' , "New Server, $serveraddress:$serverport Name: $title"); 169 //} 170 //else 171 { 172 $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun' , "New Server, $serveraddress:$serverport Name: $title Version: $serverversion"); 173 } 174 //$irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2general', "New Server, Name: $title $description"); 175 } 176 else 177 { 178 // NOP 179 } 180 } 181 182 } 183 $today = getdate(); 184 // update time 185 $lastupdatetime = mktime($today['hours'],$today['minutes'],0,$today['mon'], $today['mday'], $today['year']); 186 } 187 else 188 { 189 $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun', '.magpie_error()'); 190 $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun', 'The SRB2 MasterServer RSS feed is not up'); 191 } 192 } 193 194 function Mute(&$irc, &$data) 195 { 196 foreach ($irc->channel['#srb2fun']->ops as $nick => $key ) 197 { 198 if ($data->nick == $nick || $data->nick == 'Logan_GBA') 199 { 200 global $lastupdatetime; 201 $today = getdate(); 202 // update time 203 $lastupdatetime = mktime($today['hours'],$today['minutes'],0,$today['mon'], $today['mday'], $today['year']); 204 $GLOBALS['SRB2MS_mute'] = TRUE; 205 return; 206 } 207 } 208 } 209 210 function Unmute(&$irc, &$data) 211 { 212 foreach ($irc->channel['#srb2fun']->ops as $nick => $key ) 213 { 214 if ($data->nick == $nick || $data->nick == 'Logan_GBA') 215 { 216 $GLOBALS['SRB2MS_mute'] = FALSE; 217 return; 218 } 219 } 220 } 221 222 223 function Mute2(&$irc, &$data) 224 { 225 if ($data->nick == 'Logan_GBA') 226 { 227 global $lastupdatetime; 228 $today = getdate(); 229 // update time 230 $lastupdatetime = mktime($today['hours'],$today['minutes'],0,$today['mon'], $today['mday'], $today['year']); 231 $GLOBALS['SRB2MS_mute'] = TRUE; 232 } 233 } 234 235 function Unmute2(&$irc, &$data) 236 { 237 if ($data->nick == 'Logan_GBA') 238 { 239 $GLOBALS['SRB2MS_mute'] = FALSE; 240 } 241 } 242 243 function RSSListGames(&$irc, &$data) 244 { 245 global $lastlisttime; 246 $content = $this->GenFeed(); 247 $today = getdate(); 248 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'testing feed'); 249 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$content"); 250 //$content1 = $this->Gettextfromserver(); 251 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$content1"); 252 $SRB2MSRSS10 = new MagpieRSS( $content ); 253 if ($SRB2MSRSS10) 254 { 255 if ((mktime($today['hours'],$today['minutes']-2,0,$today['mon'], $today['mday'], $today['year'])) >= $lastlisttime) 256 { 257 //$irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun', 'Running SRB2 netgames '); 258 foreach ($SRB2MSRSS10->items as $item) 259 { 260 if ( $item['title'] == "No servers" ) 261 { 262 //0$description = $item['dc']['description']; 263 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "No SRB2 Games are running, so why don't you start one?"); 264 } 265 elseif ( $item['title'] == "No master server" ) 266 { 267 $description = $item['dc']['description']; 268 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$description"); 269 } 270 else 271 { 272 $title = $item['title']; 273 $serveraddress = $item['srb2ms']['address']; 274 $serverport = $item['srb2ms']['port']; 275 $serverversion = $item['srb2ms']['version']; 276 //if ( $serverport == " 5029" ) 277 //{ 278 // $serverport = "5029"; 279 //} 280 //if ( $serverversion == "1.09.3" ) 281 //{ 282 // $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun' , "$serveraddress:$serverport Name: $title"); 283 //} 284 //else 285 { 286 $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun' , "$serveraddress:$serverport Name: $title Version: $serverversion"); 287 } 288 289 } 290 291 } 292 $today = getdate(); 293 $lastlisttime = mktime($today['hours'],$today['minutes'],0,$today['mon'], $today['mday'], $today['year']); 294 } 295 296 } 297 else 298 { 299 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, ".magpie_error()"); 300 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'The SRB2 MasterServer RSS feed is not up'); 301 } 302 } 303 304 function RSSListGamesPM(&$irc, &$data) 305 { 306 global $lastlisttime; 307 $content = $this->GenFeed(); 308 $today = getdate(); 309 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'testing feed'); 310 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$content"); 311 //$content1 = $this->Gettextfromserver(); 312 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$content1"); 313 $SRB2MSRSS10 = new MagpieRSS( $content ); 314 if ($SRB2MSRSS10) 315 { 316 //if ((mktime($today['hours'],$today['minutes']-2,0,$today['mon'], $today['mday'], $today['year'])) >= $lastlisttime) 317 { 318 //$irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun', 'Running SRB2 netgames '); 319 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "Running SRB2 netgames from http://srb2.servegame.org/"); 320 foreach ($SRB2MSRSS10->items as $item) 321 { 322 if ( $item['title'] == "No servers" ) 323 { 324 //0$description = $item['dc']['description']; 325 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "No SRB2 Games are running, so why don't you start one?"); 326 } 327 elseif ( $item['title'] == "No master server" ) 328 { 329 $description = $item['dc']['description']; 330 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$description"); 331 } 332 else 333 { 334 $title = $item['title']; 335 $serveraddress = $item['srb2ms']['address']; 336 $serverport = $item['srb2ms']['port']; 337 $serverversion = $item['srb2ms']['version']; 338 //if ( $serverport == " 5029" ) 339 //{ 340 // $serverport = "5029"; 341 //} 342 //if ( $serverversion == "1.09.3" ) 343 //{ 344 // $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun' , "$serveraddress:$serverport Name: $title"); 345 //} 346 //else 347 { 348 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "$serveraddress:$serverport Name: $title Version: $serverversion"); 349 } 350 351 } 352 353 } 354 $today = getdate(); 355 $lastlisttime = mktime($today['hours'],$today['minutes'],0,$today['mon'], $today['mday'], $today['year']); 356 } 357 358 } 359 else 360 { 361 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, ".magpie_error()"); 362 //$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'The SRB2 MasterServer RSS feed is not up'); 363 } 364 } 365 366 function ListGamesPM(&$irc, &$data) 367 { 368 $fd = fsockopen("srb2.servegame.org", 28900, $errno, $errstr, 5); 369 if ($fd) 370 { 371 $buff = "000012360000"; 372 fwrite($fd, $buff); 373 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, 'Running SRB2 netgames '); 374 while (1) 375 { 376 $content=fgets($fd, 13); // skip 13 first bytes 377 $content=fgets($fd, 1024); 378 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, "$content"); 379 //echo "$content"; 380 if (feof($fd)) break; 381 } 382 } 383 else 384 { 385 $irc->message(SMARTIRC_TYPE_NOTICE, $data->nick, 'The SRB2 MasterServer is not up'); 386 } 387 } 388 389 function ListGamesChan(&$irc, &$data) 390 { 391 global $lastlisttime; 392 $today = getdate(); 393 $fd = fsockopen("srb2.servegame.org", 28900, $errno, $errstr, 5); 394 if ($fd) 395 { 396 stream_set_timeout ($fd, 5); 397 $buff = "000012360000"; 398 fwrite($fd, $buff); 399 if ( (mktime($today['hours'],$today['minutes']-5,0,$today['mon'], $today['mday'], $today['year'])) >= $lastlisttime ) 400 { 401 $content = ""; 402 while (1) 403 { 404 fgets($fd, 13); // skip 13 first bytes 405 $content = fgets($fd, 1024); 406 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "$content"); 407 $today = getdate(); 408 $lastlisttime = mktime($today['hours'],$today['minutes'],0,$today['mon'], $today['mday'], $today['year']); 409 if (feof($fd)) break; 410 } 411 } 412 } 413 else 414 { 415 $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'The SRB2 MasterServer is not up'); 416 } 417 } 418 419 function byebye(&$irc, &$data) 420 { 421 foreach ($irc->channel['#srb2fun']->ops as $quitnick => $key ) 422 { 423 if ($data->nick == $quitnick) 424 { 425 $irc->setAutoReconnect(FALSE); 426 $irc->setAutoRetry(FALSE); 427 $irc->quit('This quit was done by' + "$data->nick"); 428 return; 429 } 430 } 431 } 432 433 function BeenInvited(&$irc, &$data) 434 { 435 if ($data->message == '#srb2fun') 436 $irc->join($data->message); 437 438 foreach ($irc->channel['#srb2fun']->ops as $invitenick => $key ) 439 { 440 if ($data->nick == $invitenick) 441 { 442 $irc->join($data->message); 443 return; 444 } 445 } 446 foreach ($irc->channel['#srb2fun']->users as $nick => $key ) 447 { 448 if ($data->nick == $nick) 449 { 450 $irc->kick('#srb2fun', $data->nick, "Sorry, but I don't like you, or your channel, $data->message"); 451 return; 452 } 453 } 454 //$irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "Sorry, but I don't like you, or your channel, $data->message"); 455 } 456 457 function Talk(&$irc, &$data) 458 { 459 foreach ($irc->channel['#srb2fun']->ops as $nick => $key) 460 { 461 if ($data->nick == $nick) 462 { 463 $msg = str_replace("!talk ", '', "$data->message"); 464 $irc->message(SMARTIRC_TYPE_CHANNEL, '#srb2fun', $msg); 465 return; 466 } 467 } 468 foreach ($irc->channel['#srb2fun']->users as $nick => $key) 469 { 470 if ($data->nick == $nick) 471 { 472 $irc->kick('#srb2fun', $data->nick, 'Stop talking to me!'); 473 return; 474 } 475 } 476 } 477 478 function Action(&$irc, &$data) 479 { 480 foreach ($irc->channel['#srb2fun']->ops as $nick => $key) 481 { 482 if ($data->nick == $nick) 483 { 484 $msg = str_replace("!action ", '', "$data->message"); 485 $irc->message(SMARTIRC_TYPE_ACTION, '#srb2fun', $msg); 486 return; 487 } 488 } 489 foreach ($irc->channel['#srb2fun']->users as $nick => $key) 490 { 491 if ($data->nick == $nick) 492 { 493 $irc->kick('#srb2fun', $data->nick, 'Stop talking to me!'); 494 return; 495 } 496 } 497 } 498 499 function Kick(&$irc, &$data) 500 { 501 foreach ($irc->channel['#srb2fun']->ops as $nick => $key) 502 { 503 if ($data->nick == $nick) 504 { 505 $msg = str_replace("!kick ", '', "$data->message"); 506 $irc->kick('#srb2fun', $msg); 507 return; 508 } 509 } 510 foreach ($irc->channel['#srb2fun']->users as $nick => $key) 511 { 512 if ($data->nick == $nick) 513 { 514 $irc->kick('#srb2fun', $data->nick, 'Stop talking to me!'); 515 return; 516 } 517 } 518 } 519 520 function DebugPM(&$irc, &$data) 521 { 522// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "from:"); 523// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->from"); 524// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "nick:"); 525// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->nick"); 526// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "ident:"); 527// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->ident"); 528// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "host:"); 529// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->host"); 530// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "channel:"); 531// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->channel"); 532// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "message:"); 533// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->message"); 534// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "type:"); 535// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->type"); 536// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "rawmessage:"); 537// $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, "$data->rawmessage"); 538 539 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "from: $data->from"); 540 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "nick: $data->nick"); 541 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "ident: $data->ident"); 542 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "host: $data->host"); 543 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "channel: $data->channel"); 544 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "message: $data->message"); 545 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "type: $data->type"); 546 $irc->message(SMARTIRC_TYPE_QUERY, "Alam_GBC", "rawmessage: $data->rawmessage"); 547 } 548 549 function GetRSS10datafromserver() 550 { 551 $content = ""; 552 $fd = fsockopen("srb2.servegame.org", 28900, $errno, $errstr, 5); 553 if ($fd) 554 { 555 $buff = "000012400000"; 556 fwrite($fd, $buff); 557 while (1) 558 { 559 fgets($fd, 13); // skip 13 first bytes 560 $content .= fgets($fd, 1024); 561 if (feof($fd)) break; 562 } 563 fclose($fd); 564 } 565 else 566 { 567 $content = '<items>'; 568 $content .= '<rdf:Seq>'; 569 $content .= '<rdf:li rdf:resource="http://srb2.servegame.org/" />'; 570 $content .= '</rdf:Seq>'; 571 $content .= '</items>'; 572 $content .= '</channel>'; 573 $content .= "\n"; 574 $content .= '<item rdf:about="http://srb2.servegame.org/"> '; 575 $content .= '<title>No master server</title><dc:description>The master server is not running</dc:description></item>'; 576 } 577 return "$content"; 578 } 579 580 function GenFeed() 581 { 582 $content = '<?xml version="1.0" encoding="ISO-8859-1"?>'; 583 $content .= "\n"; 584 $content .= '<rdf:RDF'; 585 $content .= ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'; 586 $content .= "\n"; 587 $content .= ' xmlns="http://purl.org/rss/1.0/"'; 588 $content .= "\n"; 589 $content .= ' xmlns:dc="http://purl.org/dc/elements/1.1/"'; 590 $content .= "\n"; 591 $content .= ' xmlns:srb2ms="http://srb2.servegame.org/SRB2MS/elements/"'; 592 $content .= "\n"; 593 $content .= '>'; 594 $content .= "\n"; 595 $content .= "\n"; 596 $content .= ' <channel rdf:about="http://srb2.servegame.org/srb2ms_status.php">'; 597 $content .= "\n"; 598 $content .= ' <title>SRB2 Master Server RSS Feed</title>'; 599 $content .= "\n"; 600 $content .= ' <link>http://srb2.servegame.org/srb2ms_status.php</link>'; 601 $content .= "\n"; 602 $content .= ' <description>Playing around with RSS</description>'; 603 $content .= "\n"; 604 $content .= ' <language>en-us</language>'; 605 $content .= "\n"; 606 $feed = $this->GetRSS10datafromserver(); 607 $content .= "$feed"; 608 $content .= '</rdf:RDF>'; 609 return $content; 610 } 611} 612 613class RSSDataBase_Class 614{ 615 var $users = array(); 616 617 function OnList($User) 618 { 619 $userbeenfound = FALSE; 620 foreach ($this->users as $Userlist) 621 { 622 if ($Userlist == $User) { 623 $userbeenfound = TRUE; } 624 } 625 return $userbeenfound; 626 } 627 628 function AddUser($User) 629 { 630 $userbeenfound = FALSE; 631 foreach ($this->users as $Userlist) 632 { 633 if ($Userlist == $User) { 634 $userbeenfound = TRUE; } 635 } 636 if (!$userbeenfound) { 637 $this->users[] = $User; 638 } 639 return !$userbeenfound; 640 } 641 642 function DeleteUser($User) 643 { 644 $userbeenfound = FALSE; 645 foreach ($this->users as $index => $Userlist) 646 { 647 if ($Userlist == $User) 648 { 649 $userbeenfound = TRUE; 650 $id = $index; 651 } 652 } 653 if ($userbeenfound) 654 { 655 unset($this->users[$id]); 656 $this->users = array_values($this->users); 657 } 658 return $userbeenfound; 659 } 660 function ReplaceUser($oldUser,$newUser) 661 { 662 $userbeenfound = FALSE; 663 foreach ($this->users as $index => $Userlist) 664 { 665 if ($Userlist == $oldUser) 666 { 667 $userbeenfound = TRUE; 668 $id = $index; 669 } 670 } 671 if ($userbeenfound) 672 { 673 $this->users[$id] = $newUser; 674 } 675 return $userbeenfound; 676 } 677} 678// gobal var for muting the Bot 679$SRB2MS_mute = FALSE; 680//$SRB2MSRSS10 = fetch_rss( 'http://srb2.servegame.org/RSS1.0.php' ); 681// thing to hold RSS stuff 682$rssdatabase = &new RSSDataBase_Class(); 683// PHP error reporting 684//error_reporting(E_ERROR); 685// the Bot is the Class SRB2MS_BOT 686$bot = &new SRB2MS_BOT(); 687// Create SmartIRC, and name it as <network>irc for use to, well, do irc stuff ^_^ 688$esperirc = &new Net_SmartIRC(); 689// To Debug or Not 690//$esperirc->setDebug(SMARTIRC_DEBUG_ALL); 691// Do connect to the Internet 692$esperirc->setUseSockets(TRUE); 693// kep a list of all the users in the channel 694$esperirc->setChannelSyncing(TRUE); 695// Register the triggers with the class of SRB2MS_BOT 696//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!gamelist$', $bot, 'ListGamesChan'); 697//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!gamelist$', $bot, 'ListGamesPM'); 698//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!RSSgamelist$', $bot, 'RSSListGamesPM'); 699//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!gamelist0$', $bot, 'RSSListGames'); 700$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!gamelist$', $bot, 'RSSListGamesPM'); 701//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!gamelist$', $bot, 'RSSListGamesPM'); 702//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!addme$', $bot, 'RSSadduser'); 703//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!removeme$', $bot, 'RSSremoveuser'); 704//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!listusers$', $bot, 'ListUsersPM'); 705//$esperirc->registerActionhandler(SMARTIRC_TYPE_NICKCHANGE, '', $bot, 'RSSupdateuser'); 706//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!checkme$', $bot, 'RSScheckuser'); 707//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!shutdown$', $bot, 'byebye'); 708$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!mute$', $bot, 'Mute'); 709$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!unmute$', $bot, 'Unmute'); 710$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!shutup$', $bot, 'Mute2'); 711$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!talktome$', $bot, 'Unmute2'); 712$esperirc->registerTimehandler(120000, $bot, 'RSSListUpdate'); 713//$esperirc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!gamelist$', $bot, 'ListGamesChan'); 714$esperirc->registerActionhandler(SMARTIRC_TYPE_INVITE, '', $bot, 'BeenInvited'); 715//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!talk', $bot, 'Talk'); 716//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!action', $bot, 'Action'); 717//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!kick', $bot, 'Kick'); 718//$esperirc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!ban', $bot, 'Ban'); 719//$esperirc->registerActionhandler(SMARTIRC_TYPE_ALL, '', $bot, 'DebugPM'); 720//$esperirc->registerActionhandler(SMARTIRC_TYPE_KICK | SMARTIRC_TYPE_QUIT | SMARTIRC_TYPE_PART, '', $bot, 'DebugPM'); 721// If you fail once, try agian 722$esperirc->setAutoRetry(TRUE); 723// Connect to EsperNet 724//$esperirc->connect('irc.esper.net', 6667); 725$esperirc->connect('excalibur.esper.net', 6667); 726// Reconnect as needed 727$esperirc->setAutoReconnect(TRUE); 728// Use the name SRB2MS, and set other stuff 729$esperirc->login('SRB2MS', 'Net_SmartIRC Client '.SMARTIRC_VERSION.' (SRB2MS_Bot.php)', 0, 'Net_SmartIRC'); 730// Join #srb2fun 731$esperirc->join(array('#srb2fun')); 732// SRB2MS_Pass.php have "$esperirc->message(SMARTIRC_TYPE_QUERY, 'nickserv', 'identify <password>');" 733include('./SRB2MS_Pass.php'); 734// Idle 735$esperirc->listen(); 736// Rejoin? 737$esperirc->reconnect(); 738 739?> 740