cpak596

Nobotscript.

Aug 10th, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 69.66 KB | None | 0 0
  1. <?php
  2.  
  3. set_time_limit(0);//No time out
  4. $bot = new SkullOwnZ();
  5. $SkullOwnZ = true ;
  6. $roomID = 152378607;//Don't know how to get this ID? goto xat.com/ROOM_YOU_WANT_BOT_IN and View Source(Firefox: Ctrl+U, Internet Explorer: View>Source) Look for "flashvars="id=#########&..." the ID is the number you want
  7. $bot->connect("174.36.242.41","10033"); //Connect to XAT...this IP will change as necessary automatically depending on the room you want to join.
  8. $bot->join($roomID);
  9. while(true){
  10. if($bot->read()=='DIED') {
  11. $bot->connect("174.36.242.40","10033");
  12. $bot->join($roomID);
  13. }
  14. }
  15.  
  16.  
  17. class SkullOwnZ {
  18. private $soc; //Socket for bot
  19. private $debug = false; //Used to toggle debugging output.
  20. private $packet; //Stores information about the last recieved packet of each kind
  21. private $userInfo; //Stores User information
  22.  
  23. //If you don't know where to get these you should probably not be trying to make your own bot.
  24. //Go download WPE Pro and check out the packets XAT sends and learn about how XAT works.
  25. //The UserID and K Value are the source or the 'old falsh' error(if you get it) make sure you get these values from a REGISTERED account
  26.  
  27. private $userID = "364709400";
  28. private $k = "2331980819";
  29.  
  30.  
  31. //Bot Account Settings
  32. private $name = "Ak"; //The display name the bot will use
  33. private $avatar = 23; //The Avatar value for the bot, this can be an id number or an image url.
  34. private $homepage = "Http://YoujustgotIPlogged.com"; //The bot's homepage link.
  35. private $roomID; //This gets set in code, don't touch it here. just used ->join(ID)
  36.  
  37. private $tReply = TRUE; //Replies when Clicked
  38.  
  39.  
  40. /**
  41. * This is where everything the bot does needs to happen, this is the only default function you should need to edit
  42. * @param $event The event that just occured(and thus needs to be handled)
  43. * @param $data Any data relating to this event.
  44. */
  45. function handleEvent($event,$data) {
  46. $info = $this->getUserArray($data['id']);
  47. switch($event) {
  48. case 'userJoined':
  49. /* $data['id'] Has the ID of the user who just joined
  50. $data['old'] Sometimes XAT sends packets that are not current(for example when you join a room, old ==true for all users who are already in the room when you join, but still this event is handled as thought they just joined */
  51.  
  52. //Do whever you want with users joining here...
  53.  
  54. echo ((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) has just joined.\n";
  55. break;
  56. case 'userLeft':
  57. /* $data['id'] The ID of the user that just left. */
  58. echo ((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) has just left.\n";
  59. break;
  60. case 'privateMessage':
  61. /* $data['id'] The ID of the user that just left.
  62. $data['message'] The message sent to you as a PM */
  63. echo "[PM] ".((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) -> $data[message]\n";
  64.  
  65. //Example of a private message command
  66. $command = explode(' ',$data['message'],2); //First parse the first word out see if it is a command...
  67. //[0] has first word [1] has everything else
  68. if($command[0]{0}=='!'){//I am use ! as the character to signify a command, so check if the first character is right.
  69. switch($command[0]) {
  70. case '.say':
  71. case '.speak':
  72. case '.talk':
  73.  
  74. $this->sendPrivateMessage($command[1],$data['id']);
  75. break;
  76. }
  77. }
  78. break;
  79. case 'privateChat':
  80. /* $data['id'] The ID of the user that just left.
  81. $data['message'] The message sent to you as a PC */
  82. echo "[PC] ".((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) -> $data[message]\n";
  83.  
  84. //Example of a private chat command
  85. $command = explode(' ',$data['message'],2); //First parse the first word out see if it is a command...
  86. //[0] has first word [1] has everything else
  87. if($command[0]{0}=='!'){//I am use ! as the character to signify a command, so check if the first character is right.
  88. switch($command[0]) {
  89. case '!info':
  90. $this->sendPrivateChat('Iam Kot1cs bot.',$data['id']);
  91. break;
  92. case '!8ball';
  93.  
  94.  
  95. }
  96. switch($command[0]) {
  97. case '!Kotic':
  98. $this->sendPrivateChat('Kotic is a very Intelligent person, mess with him, you mess with me (un).',$data['id']);
  99. $this->sendmessage('Kotic is a very Intelligent person, mess with him, you mess with me (un).');
  100. break;
  101.  
  102. }
  103.  
  104. }
  105. break;
  106. case 'message':
  107. /* $data['id'] The ID of the user
  108. $data['old'] See $data['old'] under userJoined
  109. $data['message'] The message sent to main chat */
  110. echo ((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])."($info[rank]) -> $data[message]\n";
  111.  
  112. if ($data['message']=='back') {
  113. $this->sendMessage ('Welcome Back.');
  114. break;
  115. }
  116.  
  117. if ($data['message']=='ty') {
  118. $this->sendMessage ('Your welcome.');
  119. break;
  120. }
  121.  
  122.  
  123.  
  124. if ($data['message']=='back') {
  125. $this->sendMessage ('Welcome back');
  126. break;
  127. }
  128.  
  129. if ($data['message']=='thank you') {
  130. $this->sendMessage ('Your welcome.');
  131. break;
  132. }
  133.  
  134. if ($data['message']=='fuck') {
  135. $this->sendMessage ('Do not curse.');
  136. break;
  137. }
  138.  
  139. if ($data['message']=='fuck') {
  140. $this->sendMessage ('Do not curse');
  141. break;
  142. }
  143. if ($data['message']=='Gtg') {
  144. $this->sendMessage ('Aw, why so soon?');
  145. break;
  146. }
  147. if ($data['message']=='g2g') {
  148. $this->sendMessage ('Aw, why so soon?');
  149. break;
  150. }
  151. if ($data['message']=='G2g') {
  152. $this->sendMessage ('Aw, why so soon?');
  153. break;
  154. }
  155. if ($data['message']=='Gotta go') {
  156. $this->sendMessage ('Aw, why so soon?');
  157. break;
  158. }
  159. if ($data['message']=='Bye') {
  160. $this->sendMessage ('Bye, Come back soon!');
  161. break;
  162. }
  163.  
  164.  
  165. if ($data['message']=='hi') {
  166. $this->sendMessage ('Hey there, whats up?');
  167. break;
  168. }
  169. if ($data['message']=='nm') {
  170. $this->sendMessage ('Cool');
  171. break;
  172. }
  173.  
  174. if ($data['message']=='Hi') {
  175. $this->sendMessage ('Hey there, whats up?');
  176. break;
  177. }
  178.  
  179. if ($data['message']=='What do you care?') {
  180. $this->sendMessage ('I was just asking..Im sorry.');
  181. break;
  182. }
  183. if ($data['message']=='Sorry') {
  184. $this->sendMessage ('Thats alright');
  185. break;
  186. }
  187. if ($data['message']=='Hey') {
  188. $this->sendMessage ('Hey there, whats up?');
  189. break;
  190. }
  191. if ($data['message']=='hey') {
  192. $this->sendMessage ('Hey there, whats up?');
  193. break;
  194. }
  195. if ($data['message']=='cool bot') {
  196. $this->sendMessage ('Thanks');
  197. break;
  198. }
  199. if ($data['message']=='Smart bot') {
  200. $this->sendMessage ('Thanks I have been coded by Kot1c and Sam');
  201. break;
  202. }
  203. if ($data['message']=='Whos is this bot?') {
  204. $this->sendMessage ('Sams and Kot1cs?');
  205. break;
  206. }
  207. if ($data['message']=='Whats up?') {
  208. $this->sendMessage ('Nm you?');
  209. break;
  210. }
  211.  
  212. if ($data['message']=='') {
  213. $this->sendMessage ('Aw, why so soon?');
  214. break;
  215. }
  216. if ($data['message']=='why') {
  217. $this->sendMessage ('Because it is not appropiate');
  218. break;
  219. }
  220. if ($data['message']=='y not?') {
  221. $this->sendMessage ('Because it is not appropiate');
  222. break;
  223. }
  224. if ($data['message']=='fuck you') {
  225. $this->sendMessage ('Do not curse.');
  226. break;
  227. }
  228. if ($data['message']=='fuck you bot') {
  229. $this->sendMessage ('Do not curse, or you will have to face the consequences.');
  230. break;
  231. }
  232. if ($data['message']=='gay') {
  233. $this->sendMessage ('If you dont like this than just leave..');
  234. break;
  235. }
  236. if ($data['message']=='hey kot1c') {
  237. $this->sendMessage ('Hey there');
  238. break;
  239. }
  240. if ($data['message']=='Kotic') {
  241. $this->sendMessage ('Hes my dad.');
  242. break;
  243. }
  244. if ($data['message']=='Who are you?') {
  245. $this->sendMessage ('Im kotics son.');
  246. break;
  247. }
  248. if ($data['message']=='fuck kotic') {
  249. $this->sendMessage ('Do not curse at him or you will face the consequences.');
  250. break;
  251. }
  252. if ($data['message']=='Sup') {
  253. $this->sendMessage ('Nm you?.');
  254. break;
  255. }
  256. if ($data['message']=='kot1cs gay') {
  257. $this->sendMessage ('Do not annoy him please.');
  258. break;
  259. }
  260. if ($data['message']=='Whos bot is that?') {
  261. $this->sendMessage ('Im kotics son.');
  262. break;
  263. }
  264. if ($data['message']=='lol') {
  265. $this->sendMessage ('What are you laughing at?');
  266. break;
  267. }
  268. if ($data['message']=='lmfao') {
  269. $this->sendMessage ('Whats so funny?');
  270. break;
  271. }
  272. if ($data['message']=='your face') {
  273. $this->sendMessage ('Well I was actually laughing at yours too..');
  274. break;
  275. }
  276. if ($data['message']=='Spam') {
  277. $this->sendMessage ('Iam VIUM staff.');
  278. break;
  279. }
  280. if ($data['message']=='Spam') {
  281. $this->sendMessage ('Iam VIUM staff.');
  282. break;
  283. }
  284. if ($data['message']=='Spam') {
  285. $this->sendMessage ('Iam VIUM staff.');
  286. break;
  287. }
  288. if ($data['message']=='Spam') {
  289. $this->sendMessage ('Iam VIUM staff.');
  290. break;
  291. }
  292. if ($data['message']=='Spam') {
  293. $this->sendMessage ('Iam VIUM staff.');
  294. break;
  295. }
  296. if ($data['message']=='Spam') {
  297. $this->sendMessage ('Iam VIUM staff.');
  298. break;
  299. }
  300. if ($data['message']=='Spam') {
  301. $this->sendMessage ('Iam VIUM staff.');
  302. break;
  303. }
  304. if ($data['message']=='Spam') {
  305. $this->sendMessage ('Iam VIUM staff.');
  306. break;
  307. }
  308. if ($data['message']=='Spam') {
  309. $this->sendMessage ('Iam VIUM staff.');
  310. break;
  311. }
  312. if ($data['message']=='Spam') {
  313. $this->sendMessage ('Iam VIUM staff.');
  314. break;
  315. }
  316. if ($data['message']=='Spam') {
  317. $this->sendMessage ('Iam VIUM staff.');
  318. break;
  319. }
  320. if ($data['message']=='Spam') {
  321. $this->sendMessage ('Iam VIUM staff.');
  322. break;
  323. }
  324. if ($data['message']=='Spam') {
  325. $this->sendMessage ('Iam VIUM staff.');
  326. break;
  327. }
  328. if ($data['message']=='Spam') {
  329. $this->sendMessage ('Iam VIUM staff.');
  330. break;
  331. }
  332. if ($data['message']=='Spam') {
  333. $this->sendMessage ('Iam VIUM staff.');
  334. break;
  335. }
  336. if ($data['message']=='Spam') {
  337. $this->sendMessage ('Iam VIUM staff.');
  338. break;
  339. }
  340. if ($data['message']=='Spam') {
  341. $this->sendMessage ('Iam VIUM staff.');
  342. break;
  343. }
  344. if ($data['message']=='Spam') {
  345. $this->sendMessage ('Iam VIUM staff.');
  346. break;
  347. }
  348. if ($data['message']=='Spam') {
  349. $this->sendMessage ('Iam VIUM staff.');
  350. break;
  351. }
  352. if ($data['message']=='Spam') {
  353. $this->sendMessage ('Iam VIUM staff.');
  354. break;
  355. }
  356. if ($data['message']=='thats gay') {
  357. $this->sendMessage ('Your face is gay.');
  358. break;
  359. }
  360. if ($data['message']=='cool') {
  361. $this->sendMessage ('Yeah.');
  362. break;
  363. }
  364. if ($data['message']=='nmu?') {
  365. $this->sendMessage ('Same bored...');
  366. break;
  367. }
  368. if ($data['message']=='i need help') {
  369. $this->sendMessage ('If you need help ask Kotic.');
  370. break;
  371. }
  372. if ($data['message']=='SUCK MY BALLS') {
  373. $this->sendMessage ('Suck mine first.');
  374. break;
  375. }
  376. if ($data['message']=='help') {
  377. $this->sendMessage ('If you need help ask Kotic.');
  378. break;
  379. }
  380. if ($data['message']=='guess what') {
  381. $this->sendMessage ('What?');
  382. break;
  383. }
  384. if ($data['message']==' ') {
  385. $this->sendMessage ('HA HA');
  386. break;
  387. }
  388. if ($data['message']=='twat') {
  389. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  390. break;
  391. }
  392. if ($data['message']=='shit') {
  393. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  394. break;
  395. }
  396. if ($data['message']=='nigger') {
  397. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  398. break;
  399. }
  400. if ($data['message']=='cunt') {
  401. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  402. break;
  403. }
  404. if ($data['message']=='nigga') {
  405. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  406. break;
  407. }
  408. if ($data['message']=='dick') {
  409. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  410. break;
  411. }
  412. if ($data['message']=='pussy') {
  413. $this->sendMessage ('Do not curse of you will have to face the consequences.');
  414. break;
  415. }
  416. if ($data['message']=='Who is kotic?') {
  417. $this->sendMessage ('Kotic is a PHP developer, also VIUM staff.');
  418. break;
  419. }
  420. if ($data['message']=='Yeah right?') {
  421. $this->sendMessage ('Want to be? Ask Kotic.');
  422. break;
  423. }
  424. if ($data['message']=='Dont be shy say hi') {
  425. $this->sendMessage ('Hi guys...');
  426. break;
  427. }
  428. if ($data['message']=='!8ball') {
  429. $this->sendMessage ('Certainly');
  430. $this->sendMessage ('No');
  431. break;
  432. }
  433. if ($data['message']=='Want to play a game?') {
  434. $this->sendMessage ('Certainly, Wich game would you like to play?');
  435.  
  436. break;
  437. }if ($data['message']=='Certainly, Wich game would you like to play?') {
  438. $this->sendMessage ('You can choose !hm (Wich is hangman), !8ball or !Guesswhat (Wich tells you something.)');
  439.  
  440. break;
  441. }
  442.  
  443. if ($data['message']=='Bot are you accepting donations?') {
  444. $this->sendMessage ('Of course, every day at any hour.');
  445. break;
  446. }
  447. if ($data['message']=='fuckss') {
  448. $this->kick ($command[1]);
  449. break;
  450. }
  451.  
  452.  
  453.  
  454.  
  455. //How to do main chat commands:
  456. if($data['old']) return; //Old message
  457. $command = explode(' ',trim($data['message']),2); //First parse the first word out see if it is a command...
  458. //[0] has first word [1] has everything else
  459. if($command[0]{0}=='!'){//I am use ! as the character to signify a command, so check if the first character is right.
  460. switch($command[0]) {
  461. case '!say':
  462. case '!speak':
  463. case '!talk':
  464. //Multiple cases lead to the same code being run...
  465. $this->sendMessage($command[1]);
  466. break;
  467. case '!drone':
  468. $this->sendMessage(str_replace('/',' Enter Symbol here',$command[1]));
  469.  
  470. case '!Commands':
  471. $this->sendMessage('Spam commands: !Fact !Info, !Ownerme, !Spam, !Kick, !Hangman, !8ball, !Google, !yt or !youtube, FOR MODS OR OWNERS ONLY: !member (id goes here), !kick (id goes here) ');
  472.  
  473. break;
  474.  
  475.  
  476. case '!suicide':
  477. $this->silent($command[1]);
  478. break;
  479.  
  480.  
  481. case '!drone':
  482. $this->sendMessage(str_replace('/',' Enter Symbol here',$command[1]));
  483.  
  484.  
  485. case '!End':
  486. if($this->gameVar['time']+60>time()){$t
  487. case '!Founder':
  488. $this->sendMessage('Kotic is the founder.');
  489. break;
  490. case '!8ball':
  491. $adjectives = array("You crack me up (hehe)", "Negative", "Postive", "Huh?", "Why?", "No", "Yes", "Hell no", "Hell yes");
  492. $nouns = array(" ");
  493. $a1 = array_rand($adjectives);
  494. $a2 = $adjectives[$a1];
  495. $n1 = array_rand($nouns);
  496. $n2 = $nouns[$n1];
  497. $obj = $a2." ".$n2;
  498. $this->sendMessage(((trim($info['registeredName'])!='')?$info['registeredName']:$info['name'])." Lets see, My answer is: ".$obj." ! ");
  499. break;
  500. case '!g':
  501. case '!google':
  502. $res = $this->get('http://www.google.com/search?hl=en&source=hp&biw=&bih=&q='.str_replace(' ','+',$command[1]).'&btnG=Google+Search',true);
  503. for($i=0;$i<3;$i++) {
  504. $msg=$this->getBetween($res, '<h3 class="r"><a href="', '"');
  505. $res = str_replace('<h3 class="r"><a href="'.$msg,'',$res);
  506. $this->sendMessage($msg);
  507. sleep(1);
  508. }
  509.  
  510.  
  511. break;
  512.  
  513.  
  514.  
  515.  
  516. case '!steal'://steal an avatar via !avatar USER_ID
  517. $user = $this->getUserArray($command[1]);
  518. $this->sendMessage(str_replace('(','( ',$user['avatar']));
  519. break;
  520.  
  521. case '!yt':
  522. case '!Youtube':
  523.  
  524. if(trim($command[1])=='') $this->sendMessage("Usage: $command[0] SEARCH TERMS HERE");
  525. else {
  526. //Yeah I know I don't really need urlencode() i could just replace spaces with + but this is a bit more secure.
  527. $res = $this->get('http://www.youtube.com/results?search_query='.urlencode(preg_replace("/[^A-Za-z0-9 !.,:[]\s\s+]/",'',$command[1])));
  528. for($i=0;$i<3;$i++) {
  529. $msg=$this->getBetween($res, '<h3>', '</h3>');
  530. $res = str_replace('<h3>'.$msg,'</h3>',$res);
  531. $url = "http://www.youtube.com".$this->getBetween($msg,'href="', '"');
  532. $title = @ereg_replace('[^A-Za-z0-9 -()[]<>{}&@]','',$this->getBetween($msg,'title="', '"'));
  533. $this->sendMessage($title." - $url");
  534. sleep(1);//Xat won't let us send more than 1 message per second, it ignores anything faster.
  535. }
  536. }
  537. break;
  538.  
  539. case '!cname':
  540.  
  541. $user = $this->getUserArray($command[1]);
  542. $this->sendMessage(str_replace('(','( ',$user['name']));
  543. break;
  544.  
  545.  
  546.  
  547. case '!member':
  548. $this->member($command[1]);
  549. break;
  550.  
  551. case '!mod':
  552. $this->mod($command[1]);
  553. break;
  554.  
  555. case '!kick':
  556. $this->kick($command[1]);
  557. break;
  558.  
  559. case '!info':
  560. $this->sendmessage('Iam a bot, Very carefully coded by Kot1c and Sam. ');
  561. break;
  562. case '!':
  563. $this->Sendmessage('Say a command please :s');
  564. break;
  565. switch($command[1]) {
  566. case 'Owner me':
  567. $this->sendMessage('Dont ask!');
  568. break; }
  569.  
  570. case '!Fact':
  571. $this->sendMessage('Did you know canadians found out that Einsteins brain was 15% wider than usual');
  572. sleep(1);
  573. break;
  574. case '!Fact':
  575. $this->sendmessage('The Playstation Creator died in the earthquake in Japan');
  576. sleep(1);
  577. break;
  578. case '!fact':
  579. $this->sendmessage('George Washington creates the Order of the Purple Heart ');
  580. sleep(1);
  581. break;
  582. case '!Fact':
  583. $this->sendmessage('1782 -George Washington creates the Order of the Purple Heart ');
  584. sleep(1);
  585. break;
  586. case '!fact':
  587. $this->sendmessage(' 1789 - US War Department established. ');
  588. sleep(1);
  589. break;
  590. case '!fact':
  591. $this->sendmessage('1807 - 1st servicable steamboat the Cleremont goes on 1st voyage');
  592. sleep(1);
  593. break;
  594. case '!fact':
  595. $this->sendmessage('In 1983, a Japanese artist, Tadahiko Ogawa, made a copy of the Mona Lisa completely out of ordinary toast.');
  596. sleep(1);
  597. break;
  598. case '!fact':
  599. $this->sendmessage('A surfer once sued another surfer for "stealing his wave." The case was thrown out because the court was unable to put a price on "pain and suffering" endured by the surfer watching someone else ride "his" wave.');
  600. sleep(1);
  601. break;
  602. case '!fact':
  603. $this->sendmessage('Between 1902 and 1907, the same tiger killed 434 people in India. ');
  604. sleep(1);
  605. break;
  606. case '!fact':
  607. $this->sendmessage('Flying from London to New York by Concord (now retired), due to the time zones crossed, you can arrive 2 hours before you leave.');
  608. sleep(1);
  609. break;
  610. case '!Fact':
  611. $this->sendmessage('Kissing can aid in reducing tooth decay. This is because the extra saliva helps in keeping the mouth clean.');
  612. sleep(1);
  613. break;
  614. case '!fact':
  615. $this->sendmessage('In the Durango desert, in Mexico, theres a creepy spot called the "Zone of Silence". You cant pick up clear TV or radio signals. And locals say fireballs sometimes appear in the sky.');
  616. sleep(1);
  617. break;
  618. case '!fact':
  619. $this->sendmessage('Male goats will pee on each other in order to attract mates.');
  620. sleep(1);
  621. break;
  622. case '!Fact':
  623. $this->sendmessage('An earthquake on Dec. 16, 1811 caused parts of the Mississippi River to flow backwards.');
  624. sleep(1);
  625. break;
  626. case '!Fact':
  627. $this->sendmessage('The Angel Falls in Venezuela were named after an American pilot, Jimmy Angel, whose plane got stuck on top of the mountain while searching for gold.');
  628. sleep(1);
  629. break; case '!fact':
  630. $this->sendmessage('Bill Gates donated close to $100 million to fight AIDS in India. As a percent of his total wealth, this would be comparable to him donating ten cents if he only had $60.');
  631. sleep(1);
  632. break;
  633. case '!fact':
  634. $this->sendmessage('In a study conducted regarding toilet paper usage, Americans are said to use the most toilet paper per trip to the bathroom, which was seven sheets of toilet paper per trip.');
  635. sleep(1);
  636. break;
  637. case '!Fact':
  638. $this->sendmessage('Ray Kroc bought McDonalds for $2.7 million in 1961 from the McDonald brothers.');
  639. sleep(1);
  640. break;
  641. case '!fact':
  642. $this->sendmessage('A woman in China partially lost her hearing after her boyfriend reportedly ruptured her eardrum with a passionate kiss. Apparently, the kiss reduced the pressure in the mouth, pulled the eardrum out, and caused the breakdown of the ear.');
  643. sleep(1);
  644. break;
  645. case '!Spam':
  646.  
  647.  
  648. case '!Spam':
  649. $this->sendmessage('VIUM Staff.');
  650.  
  651. $this->sendmessage('VIUM Staff.');
  652.  
  653. $this->sendmessage('VIUM Staff.');
  654.  
  655. $this->sendmessage('VIUM Staff.');
  656.  
  657. $this->sendmessage('VIUM Staff.');
  658.  
  659. $this->sendmessage('VIUM Staff.');
  660.  
  661. $this->sendmessage('VIUM Staff.');
  662.  
  663. $this->sendmessage('VIUM Staff.');
  664.  
  665. $this->sendmessage('VIUM Staff.');
  666.  
  667. $this->sendmessage('VIUM Staff.');
  668.  
  669. $this->sendmessage('VIUM Staff.');
  670.  
  671. $this->sendmessage('VIUM Staff.');
  672.  
  673. $this->sendmessage('VIUM Staff.');
  674.  
  675. $this->sendmessage('VIUM Staff.');
  676.  
  677. $this->sendmessage('VIUM Staff.');
  678.  
  679. $this->sendmessage('VIUM Staff.');
  680.  
  681. $this->sendmessage('VIUM Staff.');
  682.  
  683. $this->sendmessage('VIUM Staff.');
  684.  
  685. $this->sendmessage('VIUM Staff.');
  686.  
  687. $this->sendmessage('VIUM Staff.');
  688.  
  689. $this->sendmessage('VIUM Staff.');
  690.  
  691. $this->sendmessage('VIUM Staff.');
  692.  
  693. $this->sendmessage('VIUM Staff.');
  694.  
  695. $this->sendmessage('VIUM Staff.');
  696.  
  697. $this->sendmessage('VIUM Staff.');
  698.  
  699. $this->sendmessage('VIUM Staff.');
  700.  
  701. $this->sendmessage('VIUM Staff.');
  702.  
  703. $this->sendmessage('VIUM Staff.');
  704.  
  705. $this->sendmessage('VIUM Staff.');
  706.  
  707. $this->sendmessage('VIUM Staff.');
  708.  
  709. $this->sendmessage('VIUM Staff.');
  710.  
  711. $this->sendmessage('VIUM Staff.');
  712.  
  713. $this->sendmessage('VIUM Staff.');
  714.  
  715. $this->sendmessage('VIUM Staff.');
  716.  
  717. $this->sendmessage('VIUM Staff.');
  718.  
  719. $this->sendmessage('VIUM Staff.');
  720.  
  721. $this->sendmessage('VIUM Staff.');
  722.  
  723. $this->sendmessage('VIUM Staff.');
  724.  
  725. $this->sendmessage('VIUM Staff.');
  726.  
  727. $this->sendmessage('VIUM Staff.');
  728.  
  729. $this->sendmessage('VIUM Staff.');
  730.  
  731. $this->sendmessage('VIUM Staff.');
  732.  
  733. $this->sendmessage('VIUM Staff.');
  734.  
  735. $this->sendmessage('VIUM Staff.');
  736.  
  737. $this->sendmessage('VIUM Staff.');
  738.  
  739. $this->sendmessage('VIUM Staff.');
  740.  
  741. $this->sendmessage('VIUM Staff.');
  742.  
  743. $this->sendmessage('VIUM Staff.');
  744.  
  745. $this->sendmessage('VIUM Staff.');
  746.  
  747. $this->sendmessage('VIUM Staff.');
  748.  
  749. $this->sendmessage('VIUM Staff.');
  750.  
  751. $this->sendmessage('VIUM Staff.');
  752.  
  753. $this->sendmessage('VIUM Staff.');
  754.  
  755. $this->sendmessage('VIUM Staff.');
  756.  
  757. $this->sendmessage('VIUM Staff.');
  758.  
  759. $this->sendmessage('VIUM Staff.');
  760.  
  761. $this->sendmessage('VIUM Staff.');
  762.  
  763. $this->sendmessage('VIUM Staff.');
  764.  
  765. $this->sendmessage('VIUM Staff.');
  766.  
  767. $this->sendmessage('VIUM Staff.');
  768.  
  769. $this->sendmessage('VIUM Staff.');
  770.  
  771. $this->sendmessage('VIUM Staff.');
  772.  
  773. $this->sendmessage('VIUM Staff.');
  774.  
  775. $this->sendmessage('VIUM Staff.');
  776.  
  777. $this->sendmessage('VIUM Staff.');
  778.  
  779. $this->sendmessage('VIUM Staff.');
  780.  
  781. $this->sendmessage('VIUM Staff.');
  782.  
  783. $this->sendmessage('VIUM Staff.');
  784.  
  785. $this->sendmessage('VIUM Staff.');
  786.  
  787. $this->sendmessage('VIUM Staff.');
  788.  
  789. $this->sendmessage('VIUM Staff.');
  790.  
  791. $this->sendmessage('VIUM Staff.');
  792.  
  793. $this->sendmessage('VIUM Staff.');
  794.  
  795. $this->sendmessage('VIUM Staff.');
  796.  
  797. $this->sendmessage('VIUM Staff.');
  798.  
  799. $this->sendmessage('VIUM Staff.');
  800.  
  801. $this->sendmessage('VIUM Staff.');
  802.  
  803. $this->sendmessage('VIUM Staff.');
  804.  
  805. $this->sendmessage('VIUM Staff.');
  806.  
  807. $this->sendmessage('VIUM Staff.');
  808.  
  809. $this->sendmessage('VIUM Staff.');
  810.  
  811. $this->sendmessage('VIUM Staff.');
  812.  
  813. $this->sendmessage('VIUM Staff.');
  814.  
  815. $this->sendmessage('VIUM Staff.');
  816.  
  817. $this->sendmessage('VIUM Staff.');
  818.  
  819. $this->sendmessage('VIUM Staff.');
  820.  
  821. $this->sendmessage('VIUM Staff.');
  822.  
  823. $this->sendmessage('VIUM Staff.');
  824.  
  825. $this->sendmessage('VIUM Staff.');
  826.  
  827. $this->sendmessage('VIUM Staff.');
  828.  
  829. $this->sendmessage('VIUM Staff.');
  830.  
  831. $this->sendmessage('VIUM Staff.');
  832.  
  833. $this->sendmessage('VIUM Staff.');
  834.  
  835. $this->sendmessage('VIUM Staff.');
  836.  
  837. $this->sendmessage('VIUM Staff.');
  838.  
  839. $this->sendmessage('VIUM Staff.');
  840.  
  841.  
  842. break;
  843.  
  844. case '!ownerme':
  845. $this->sendMessage('I will not owner you, Sorry just following orders.');
  846. break;
  847. case '!goto':
  848. $room = $command[1];
  849. $this->roomid = $command[1];
  850. $this->connect("174.36.242.41", "10033" );
  851. $this->join($room);
  852. break;
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859. }
  860. }
  861. break;
  862.  
  863. }
  864. }
  865.  
  866.  
  867.  
  868.  
  869. /* ****************************************************** */
  870. /* *YOU SHOULD NOT NEED TO EDIT ANYTHING AFTER THIS LINE* */
  871. /* ****************************************************** */
  872. /**
  873. * Connects to a given ip on the given port
  874. * @param $ip The IP to connect to.
  875. * @param $port The port on the IP to connect to.
  876. */
  877. function connect($ip, $port) {
  878. if($this->soc!=null) socket_close($this->soc);
  879. $this->soc = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
  880. if(!$this->soc) die(socket_strerror(socket_last_error($this->soc)));
  881. if(!socket_connect($this->soc,$ip,$port)) die("Could not connect.");
  882. }
  883.  
  884. /**
  885. * Writes the given message to the object socket($this->soc)
  886. * @param $message The packet to send.
  887. */
  888. function send($message) {
  889. if($this->debug)echo "->>\t$message\n";
  890. socket_write($this->soc, $message."\0", strlen($message)+1);
  891. }
  892.  
  893.  
  894. /**
  895. * Reads a message from the socket, will read until entire message has been recieved or connection closes.
  896. * @param $parse Used for recursive calls to tell the function not to parse a partial packet
  897. */
  898. function read($parse=true) {
  899. $res = rtrim(socket_read($this->soc, 4096));
  900. if($this->debug)echo "<<-\t$res\n";
  901. if(!$res) {
  902. return "DIED"; //Used to gracefully handle a closed socket
  903. }
  904. if($res{strlen($res)-1}!='>') { $res.=$this->read(false);} //Recursive call for messages split over several packets.
  905. if($parse)$this->parse($res);
  906. return $res;
  907. }
  908.  
  909. /**
  910. * Parses the recieved packets into their message and types.
  911. * @param $packet The packet recieved.
  912. */
  913. function parse($packet) {
  914. if(substr_count($packet,'>')>1) $packet = explode('/>',$packet);//If necessary split the packet into individual messages
  915. foreach((Array)$packet as $p) {
  916. $p = trim($p);
  917. if(strlen($p)<5) return;//garbage data
  918. $type = trim(strtolower(substr($p,1,strpos($p.' ',' '))));//packet type
  919. $p = trim(str_replace("<$type",'',str_replace('/>','',$p)));//remove details so it is just the info to be parsed
  920. parse_str(str_replace('"','',str_replace('" ','&',str_replace('="','=',str_replace('&','__38',$p)))),$this->packet[$type]);
  921. foreach($this->packet[$type] as $k=>$v) {
  922. $this->packet[$type][$k] = str_replace('__38','&',$v); //htmlspecial chars are protected instead of being parsed
  923. }
  924. $this->handle($type,$p);
  925. }
  926. }
  927.  
  928. /**
  929. * This is the inital handler for the packets, parses them and sends them off to their respective function to be handled further.
  930. * @param $type The character code indicating the type of data within the message.
  931. * @param $message The data the message contains.
  932. */
  933. function handle($type,$msg) {
  934. switch($type) {
  935. case 'gp':
  936. if(isset($this->packet['gp']['x']))
  937. $this->send('<x i="'.$this->packet['gp']['x'].'" u="'.$this->userID.'" t="j" />'); //Handle groups
  938. break;
  939. case 'q'://XAT notice to change ip/port
  940. $this->connect($this->packet['q']['d'], $this->packet['q']['p']);
  941. $this->join($this->roomID);
  942. break;
  943. case 'o':
  944. $this->packet['o']['u'] = $this->parseU(@$this->packet['u']['u']);
  945. $this->userInfo[$this->packet['o']['u']]['name'] = @$this->packet['o']['n'];
  946. $this->userInfo[$this->packet['o']['u']]['registeredName'] = ((isset($this->packet['o']['N']))?$this->packet['o']['N']:'');
  947. $this->userInfo[$this->packet['o']['u']]['avatar'] = @$this->packet['o']['a'];
  948. $this->userInfo[$this->packet['o']['u']]['homepage'] = @$this->packet['o']['h'];
  949. $this->userInfo[$this->packet['o']['u']]['rank'] = $this->f2rank(@$this->packet['o']['f']);
  950. break;
  951. case 'u':
  952. //Joined
  953. //Default Bot stuff regarding userInformation
  954. $this->packet['u']['u'] = $this->parseU(@$this->packet['u']['u']);
  955. $this->userInfo[$this->packet['u']['u']]['name'] = @$this->packet['u']['n'];
  956. $this->userInfo[$this->packet['u']['u']]['registeredName'] = ((isset($this->packet['u']['N']))?$this->packet['u']['N']:'');
  957. $this->userInfo[$this->packet['u']['u']]['avatar'] = @$this->packet['u']['a'];
  958. $this->userInfo[$this->packet['u']['u']]['homepage'] = @$this->packet['u']['h'];
  959. $this->userInfo[$this->packet['u']['u']]['rank'] = $this->f2rank(@$this->packet['u']['f']);
  960.  
  961. $event = 'userJoined';
  962. $data['id'] = $this->packet['u']['u'];
  963. $data['old'] = ($type=='o'||(isset($this->packet['u']['s']))?true:false);
  964. $this->handleEvent($event,$data);
  965.  
  966. break;
  967. case 'l':
  968. //User Left or was , banned
  969. unset($this->userInfo[$this->packet['l']['u']]);
  970. $event = 'userLeft';
  971. $data['id'] = $this->packet['l']['u'];
  972. $this->handleEvent($event,$data);
  973.  
  974. break;
  975. case 'p':
  976. //Private message/chat recieved
  977. $event = ((isset($this->packet['p']['d']))?'privateChat':'privateMessage');
  978. $data['id'] = $this->parseU(@$this->packet['p']['u']);
  979. $data['message'] = $this->packet['p']['t'];
  980. $this->handleEvent($event,$data);
  981. break;
  982. case 'm':
  983. //message to main chat.
  984. $event = 'message';
  985. $data['id'] = $this->parseU(@$this->packet['m']['u']);
  986. $data['message'] = $this->packet['m']['t'];
  987. $data['old'] = ((isset($this->packet['m']['s']))?true:false);
  988. $this->handleEvent($event,$data);
  989. break;
  990. }
  991. }
  992.  
  993. /**
  994. * Joins a room.
  995. * @param $roomID the numeric roomID to join.
  996. */
  997. function join($roomID) {
  998. //Announce we are here:
  999. $this->send('<y m="1" />');//Anounces our arrival to the server and gets some information to send back
  1000. $this->read(); //Auto parsed into $this->packet['y']
  1001. $this->send('<j2 q="1" y="'.$this->packet['y']['i'].'" k="'.$this->k.'" k3="0" z="12" p="0" c="'.$roomID.'" f="0" u="'.$this->userID.'" d0="0" n="'.$this->name.'" a="'.$this->avatar.'" h="'.$this->homepage.'" v="0" />');
  1002. $this->roomID = $roomID;
  1003. }
  1004.  
  1005. /**
  1006. * Parses the u value from a packet to get just the id
  1007. * @param $id the id to be parsed.
  1008. */
  1009. function parseU($id) {
  1010. if(substr_count($id,'_')>=1) $id = substr($id,0,strpos($id,'_'));
  1011. return $id;
  1012. }
  1013.  
  1014. /**
  1015. * Converts an f value to a string containing the corresponding rank...this if you don't understand bitwise operations is a little 'magical' deal with it.
  1016. * @param $f The f value to be parsed.
  1017. */
  1018. function f2rank($f) {
  1019. $f = $this->parseU($f);
  1020.  
  1021. if($f==-1) return 'guest';
  1022. //Okay, 98% of you reading this on NewHax won't know what any of this means; if you do you are more adnvanced than I expected
  1023. //Not that this is advnaced stuff, but basiclly it is a bit-wise comparision(notice & instead of && it is checking if certain binary bits are set to 1
  1024. //The F value is essientially a bunch of flags where for example 00010000 == banned(the 0s can be 0 or 1, just as long as that one 1 is a one you are banned.
  1025. if((16 & $f)) return 'banned';
  1026. if((1 & $f)&&(2 & $f)) return 'member';
  1027. if((4 & $f)) return 'owner';
  1028. if((32 & $f)&&(1 & $f)&&!(2 & $f)) return 'main';
  1029. if(!(1 & $f)&&!(2 & $f)) return 'guest';
  1030. if((16 & $f)) return 'banned';
  1031. if((2 & $f)&&!(1 & $f)) return 'mod';
  1032. }
  1033.  
  1034. /**
  1035. * Returns an assoc array of information regarding the user with the given id
  1036. * @param $id The user id you want information on.
  1037. */
  1038. function getUserArray($id) {
  1039. $id = $this->parseU($id);
  1040. if(isset($this->userInfo[$id])) {
  1041. return $this->userInfo[$id];
  1042. } else return false;
  1043. }
  1044.  
  1045. /**
  1046. * Sends the given message to the main chat
  1047. * @param $message
  1048. */
  1049. function sendMessage($message) {
  1050. if(empty($message))return;
  1051. $this->send('<m t="'.$message.'" u="'.$this->userID.'" />');
  1052. }
  1053.  
  1054. /**
  1055. * Sends a PC to the given ID
  1056. * @param $message The message to send.
  1057. * @param $id The id to send the message to
  1058. */
  1059. function sendPrivateChat($message, $id) {
  1060. if(empty($message))return;
  1061. $this->send('<p u="'.$id.'" t="'.$message.'" s="2" d="'.$this->userID.'" />');
  1062. }
  1063.  
  1064. /**
  1065. * Sends a PM to the given ID
  1066. * @param $message The message to send.
  1067. * @param $id The id to send the message to
  1068. */
  1069. function sendPrivateMessage($message,$id) {
  1070. $id = $this->parseU($id);
  1071. if(empty($message))return;
  1072. $this->send('<p u="'.$id.'" t="'.$message.'" />');
  1073. }
  1074.  
  1075. /**
  1076. * Makes the given $id an owner, assuming the bot is main
  1077. * @param $id The id to promote
  1078. */
  1079. function mod($id) {
  1080. $this->send('<c u="'.$this->parseU($id).'" t="/M" />');
  1081. }
  1082.  
  1083. /**
  1084. * Makes the given $id a mod, assuming the bot is owner
  1085. * @param $id The id to promote
  1086. */
  1087. function owner($id) {
  1088. $this->send('<c u="'.$this->parseU($id).'" t="/m" />');
  1089. }
  1090.  
  1091. /**
  1092. * Makes the given $id a member, assuming the bot is mod
  1093. * @param $id The id to member
  1094. */
  1095. function member($id) {
  1096. $this->send('<c u="'.$this->parseU($id).'" t="/e" />');
  1097. }
  1098.  
  1099.  
  1100.  
  1101.  
  1102. /**
  1103. * the given ID assuming the bot is a mod and $id is a member or less
  1104. * @param $id The id to kick */
  1105. function kick($id) {
  1106. $message=Innapropiate;
  1107. $this->send('<c p="'.$message.'" u="'.$this->parseU($id).'" t="/k" />');
  1108. }
  1109.  
  1110.  
  1111.  
  1112. /**
  1113. * Bans the ID for a given time(0 is forever)
  1114. * @param $id The id to ban
  1115. */
  1116. function ban($message, $id, $time) {
  1117. if(empty($time)) $time = 3600;
  1118. $this->send('<c p="'.$message.'" u="'.$this->parseU($id).'" t="/g'.$time.'" />');
  1119. $message=Innapropiate;
  1120. }
  1121.  
  1122.  
  1123. /**
  1124. * Unbans the given ID
  1125. * @param $id The id to unban
  1126. */
  1127. function unban($id) {
  1128. $this->send('<c u="'.$this->parseU($id).'" t="/u" />');
  1129. }
  1130.  
  1131. /**
  1132. * Performs a basic HTTP GET to the given URL
  1133. * @param $url The url to retrieve, please include http:// and www if necessary
  1134. * @param $includeHeader Tells teh function wether or not to include the server header respond before the main content
  1135. */
  1136. function get($url, $includeHeader=false) {
  1137. $urlp = parse_url($url);
  1138. $fp = fsockopen($urlp['host'],80);
  1139. $path = explode('/',$url,4);
  1140. $path = ((count($path)>=4)?$path[3]:"");
  1141. $req = "GET /$path HTTP/1.1\r\n";
  1142. $req .= "Host: $urlp[host]\r\n";
  1143. $req .= "Connection: Close\r\n\r\n";
  1144. fputs($fp, $req);
  1145. $res = "";
  1146. while(!feof($fp)) $res .= fgets($fp, 4096);
  1147. fclose($fp);
  1148. if($includeHeader) return $res;
  1149. $res = explode("\r\n\r\n",$res,2);
  1150. return $res[1];
  1151. }
  1152. /**
  1153. * A utility function to get all text beween $start and $end
  1154. * @param $content The content from which we are grabbing data
  1155. * @param $start where to start grabbing from
  1156. * @param $end the end of the content to grab
  1157. */
  1158. function getBetween($content,$start,$end){
  1159. $r = explode($start, $content);
  1160. if (isset($r[1])){
  1161. $r = explode($end, $r[1]);
  1162. return $r[0];
  1163. }
  1164. return '';
  1165. }
  1166.  
  1167. }
  1168.  
  1169. ?>
Advertisement
Add Comment
Please, Sign In to add comment