Viewing topic:How to make the IRC Bot reply to VERSION
Page:
1
14-11-2007 - 8:05
I have looked, I have tried, I can't seem to get it. It is very annoying.
>.<
| code | |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
<font face="verdana" size="2" color="red"><b>
<?php
set_time_limit(0);
$socket = fsockopen("irc.gamesurge.net", 6667);
fputs($socket,"USER XDXPHP mmoalert.com XDX :XDX BOT n");
fputs($socket,"NICK xDx-phpn");
function doexit() {
sleep(3);
die("Session Ended");
sleep(0.1);
}
while(1) {
while($data = fgets($socket, 512)) {
echo nl2br($data);
flush();
$ex = explode(' ', $data);
if($ex[0] == "PING"){
fputs($socket, "PONG ".$ex[1]."n");
require_once('info.php');
}
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
$hostmask_old = explode("@", $ex[0]);
$hostmask = $hostmask_old[1];
$cmd = explode(" ",$data);
$nick = explode("!",$cmd[0]);
$nick = substr($nick[0],1);
$bind = explode(" ", $data, 3);
$bind2 = explode(" ", $bind[2], 3);
if ($command == ":!my") {
fputs($socket, "PRIVMSG ".$ex[2]." :Hello ".$nick."!n");
}
elseif ($command == ":!o") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick.": What is Ex[1]? Is it ".$ex[1]."n");
}
elseif ($command == ":!die") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." has requested a shut down. Closing.n");
fputs($socket, "QUIT :".$bind2[2]."");
doexit();
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!join") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." has requested to join ".$bind2[2]."n");
fputs($socket, "JOIN ".$bind2[2]."n");
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!part") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." has requested to part ".$bind2[2]."n");
fputs($socket, "PART ".$bind2[2]."n");
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!exec") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." Has Requested ".$bind2[2]."n");
fputs($socket, $bind2[2]);
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!say") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG #-Staff :".$nick." Has Requested ".$bind2[2]."n");
fputs($socket, "PRIVMSG ".$ex[2]." : ".$bind2[2]."n");
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($ex[1] == "VERSION") {
fputs($socket, "PRIVMSG #-Staff :[CTCP] ".$ex[1]." ".$nick." ".$ex[0]."n");
fputs($socket, "PRIVMSG ".$nick." :VERSION xDx-PHP Bot Programmed by xDx");
}
}
}
?></b></font>
|
>.<
14-11-2007 - 09:41
Hmm kind of annoying the code bb block is broken since the PHP update of the host :S
About the problem, i can't see whats wrong that fast, i never used CTCP on my bot. I recommend letting your bot asking for your version, and see how he is doing that.
What you can also do is use a TCP Sniffer to see the protocol, just google for TCP Sniffer and you will see quite some applications comming up. Just start the sniffer and IRC, and use version and you will see the exact protocol code.
About the problem, i can't see whats wrong that fast, i never used CTCP on my bot. I recommend letting your bot asking for your version, and see how he is doing that.
What you can also do is use a TCP Sniffer to see the protocol, just google for TCP Sniffer and you will see quite some applications comming up. Just start the sniffer and IRC, and use version and you will see the exact protocol code.
14-11-2007 - 10:32
00000000 50 52 49 56 4D 53 47 20 78 44 78 2D 70 68 70 20 PRIVMSG xDx-php
00000010 3A 01 56 45 52 53 49 4F 4E 01 0A :.VERSIO N..
and
00000000 3A 78 44 78 21 7E 78 64 78 40 63 72 69 6D 70 2E
Dx!~xd x@crimp.
00000010 73 74 61 66 66 2E 73 74 65 61 6D 69 64 62 6F 74 staff.st eamidbot
00000020 73 20 50 52 49 56 4D 53 47 20 78 44 78 2D 70 68 s PRIVMS G xDx-ph
00000030 70 20 3A 01 56 45 52 53 49 4F 4E 01 0D 0A 50 49 p :.VERS ION...PI
00000040 4E 47 20 3A 52 6F 6B 73 63 6F 6D 2E 4E 4C 2E 45 NG :Roks com.NL.E
00000050 55 2E 47 61 6D 65 53 75 72 67 65 2E 6E 65 74 0D U.GameSu rge.net.
00000060 0A .
PONG :Rokscom.NL.EU.GameSurge.net
Still confused on what I am looking for. Maybe explain some please?
00000010 3A 01 56 45 52 53 49 4F 4E 01 0A :.VERSIO N..
and
00000000 3A 78 44 78 21 7E 78 64 78 40 63 72 69 6D 70 2E
Dx!~xd x@crimp. 00000010 73 74 61 66 66 2E 73 74 65 61 6D 69 64 62 6F 74 staff.st eamidbot
00000020 73 20 50 52 49 56 4D 53 47 20 78 44 78 2D 70 68 s PRIVMS G xDx-ph
00000030 70 20 3A 01 56 45 52 53 49 4F 4E 01 0D 0A 50 49 p :.VERS ION...PI
00000040 4E 47 20 3A 52 6F 6B 73 63 6F 6D 2E 4E 4C 2E 45 NG :Roks com.NL.E
00000050 55 2E 47 61 6D 65 53 75 72 67 65 2E 6E 65 74 0D U.GameSu rge.net.
00000060 0A .
PONG :Rokscom.NL.EU.GameSurge.net
Still confused on what I am looking for. Maybe explain some please?
14-11-2007 - 11:48
Ok...
fputs($socket, "PRIVMSG ".$nick." :VERSION PHP 5n"
;
I found to send a CTCP VERSION. But i can't get it to reply..
fputs($socket, "PRIVMSG ".$nick." :VERSION PHP 5n"
;I found to send a CTCP VERSION. But i can't get it to reply..
14-11-2007 - 12:02
I got it.
Ok so instead of sniffing the TCP packets what I did was open /debug @raw and had a friend version me (He recommended me to do this)
Basicly, I got the CTCP Sending version correct but usually when people version something it says [NICK VERSION reply] THE VERSION HERE
But mine didn't say reply so I looked closely and noticed that when it replied it was using NOTICE instead of PRIVMSG and to recieve a VERSION it uses PRIVMSG. Confusing but here is what I got.
And of course my code is abit sloppy but I'm just in the stages of developing the basics and expanding my socket knowledge.
Great base script, I do love it. Though a nice thing is to do a require_one when ping and pong take place to require the JOINS and maybe the auth's depending on if you have AS or NickServ.
Ok so instead of sniffing the TCP packets what I did was open /debug @raw and had a friend version me (He recommended me to do this)
Basicly, I got the CTCP Sending version correct but usually when people version something it says [NICK VERSION reply] THE VERSION HERE
But mine didn't say reply so I looked closely and noticed that when it replied it was using NOTICE instead of PRIVMSG and to recieve a VERSION it uses PRIVMSG. Confusing but here is what I got.
| code | |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
<font face="verdana" size="2" color="red"><b>
<?php
set_time_limit(0);
$socket = fsockopen("irc.gamesurge.net", 6667);
fputs($socket,"USER XDXPHP mmoalert.com XDX :XDX BOT n");
fputs($socket,"NICK xDx-phpn");
function doexit() {
sleep(3);
die("Session Ended");
sleep(0.1);
}
while(1) {
while($data = fgets($socket, 512)) {
echo nl2br($data);
flush();
$ex = explode(' ', $data);
if($ex[0] == "PING"){
fputs($socket, "PONG ".$ex[1]."n");
require_once('info.php');
}
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
$hostmask_old = explode("@", $ex[0]);
$hostmask = $hostmask_old[1];
$cmd = explode(" ",$data);
$nick = explode("!",$cmd[0]);
$nick = substr($nick[0],1);
$bind = explode(" ", $data, 3);
$bind2 = explode(" ", $bind[2], 3);
if ($command == ":!my") {
fputs($socket, "PRIVMSG ".$ex[2]." :Hello ".$nick."!n");
}
elseif ($command == ":!o") {
# fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." Var[1] == ".$ex[1]."n");
}
elseif ($command == ":!die") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." has requested a shut down. Closing.n");
fputs($socket, "QUIT :".$bind2[2]."");
doexit();
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!join") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." has requested to join ".$bind2[2]."n");
fputs($socket, "JOIN ".$bind2[2]."n");
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!part") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." has requested to part ".$bind2[2]."n");
fputs($socket, "PART ".$bind2[2]."n");
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!exec") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG ".$ex[2]." :".$nick." Has Requested ".$bind2[2]."n");
fputs($socket, $bind2[2]);
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":!say") {
if ($hostmask == "crimp.staff.steamidbots") {
fputs($socket, "PRIVMSG #-Staff :".$nick." Has Requested ".$bind2[2]."n");
fputs($socket, "PRIVMSG ".$ex[2]." : ".$bind2[2]."n");
} else {
fputs($socket, "PRIVMSG ".$ex[2]." :Sorry ".$nick." But your hostmask is not correct.n");
}
}
elseif ($command == ":VERSION") {
fputs($socket, "PRIVMSG #-Staff :[CTCP] ".$ex[1]." ".$nick." ".$ex[0]."n");
fputs($socket, "NOTICE ".$nick." :VERSION Using Php5.2n");
}
}
}
?></b></font>
|
And of course my code is abit sloppy but I'm just in the stages of developing the basics and expanding my socket knowledge.
Great base script, I do love it. Though a nice thing is to do a require_one when ping and pong take place to require the JOINS and maybe the auth's depending on if you have AS or NickServ.
14-11-2007 - 15:19
Hmm i would use notice too in stead of privmsg at first. These are a few annoying little things.
About the bot, i recommend you to create the bot in OOP. You can also find a OOP tutorial here on CM.
About the bot, i recommend you to create the bot in OOP. You can also find a OOP tutorial here on CM.
Page:
1
Reply to topic
Reply to topic

