 |
|
 |
|
|
|
 |
|
 |
|
| Tip: Yoshi wings take you to level C8 or 1C8. Which one you get depends on the overworld level you're in. |
|
|
|
 |
|
 |
|
 |
|
 |
|
| [VB.NET] IRC and Sockets {and more or less .Substring()} |
|
Forum Index - Hobbies - Computers & Technology - [VB.NET] IRC and Sockets {and more or less .Substring()} |
|
Pages: 1  |
|
|
|
| Posted on 2012-02-10 05:53:03 PM |
Link | Quote |
|
Hey guys! I have a small problem with an IRC client I'm trying to make.
Code Function recv() As String
Dim data(4096) As Byte
s.Receive(data, 4096, SocketFlags.None)
Dim mail As String = System.Text.ASCIIEncoding.UTF8.GetString(data)
If mail.Contains(" ") Then
If mail.Substring(0, 4) = "PING" Then
Dim pserv As String = mail.Substring(mail.IndexOf(":"), mail.Length - mail.IndexOf(":"))
pserv = pserv.TrimEnd(Chr(0))
cmd_send("PONG " & pserv)
mail = "*** [" & server & "] Ping!" & vbCr & vbLf
ElseIf mail.Substring(mail.IndexOf(" ") + 1, 7) = "PRIVMSG" Then
Dim text As String = mail.Substring(mail.IndexOf("PRIVMSG") + 10 + channel.Count())
Dim user As String = "<" & mail.Split(":")(1).Split("!")(0) & "> "
mail = user & text
ElseIf mail.StartsWith(":" & server & " 001 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("001") + 6 + nickname.Length)
ElseIf mail.StartsWith(":" & server & " 002 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("002") + 6 + nickname.Length)
ElseIf mail.StartsWith(":" & server & " 003 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("003") + 6 + nickname.Length)
ElseIf mail.StartsWith(":" & server & " 004 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("004") + 5 + nickname.Length)
ElseIf mail.StartsWith(":" & server & " 005 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("005") + 5 + nickname.Length)
ElseIf mail.StartsWith(":" & server & " 251 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("251") + 5 + nickname.Length)
ElseIf mail.StartsWith(":" & server & " 252 " & nickname) Then
mail = "*** [" & server & "] " & mail.Substring(mail.IndexOf("252") + 5 + nickname.Length)
End If
End If
Return mail
End Function
This function is supposed to format the text received from the server, but this is what I get:
Code*** [irc.caffie.net] Ping!
*** [irc.caffie.net] Welcome to the CaffieNET IRC Network xtreme!xtreme@**.**.**.**.customer.cdi.no
:irc.caffie.net 002 xtreme :Your host is irc.caffie.net, running version Unreal3.2.8.1
:irc.caffie.net 003 xtreme :This server was created tor jul 30 2009 at 18:10:17 CEST
:irc.caffie.net 004 xtreme irc.caffie.net Unreal3.2.8.1 iowghraAsORTVSxNCWqBzvdHtGp lvhopsmntikrRcaqOALQbSeIKVfMCuzNTGj
:irc.caffie.net 005 xtreme UHNAMES NAMESX SAFELIST HCN MAXCHANNELS=20 CHANLIMIT=#:20 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307
KICKLEN=307 AWAYLEN=307 MAXTARGETS=20 :are supported by this server
:irc.caffie.net 005 xtreme WALLCHOPS WATCH=128 WATCHOPTS=A SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(qaohv)~&@%+ CHANMODES=beI,kfL,lj,
psmntirRcOAQKVCuzNSMTG NETWORK=CaffieNET CASEMAPPING=ascii EXTBAN=~,cqnr ELIST=MNUCT STATUSMSG=~&@%+ :are supported by this server
:irc.caffie.net 005 xtreme EXCEPTS INVEX CMDS=KNOCK,MAP,DCCALLOW,USERIP :are supported by this server
:irc.caffie.net 251 xtreme :There are 110 users and 32 invisible on 2 servers
*** [irc.caffie.net] 9 :operator(s) online
Any idea to as why most of it isn't working?
|
| Last edited on 2012-02-10 06:03:25 PM by x-treme. |
|
| Posted on 2012-02-11 06:41:10 AM |
Link | Quote |
|
I've took a look into what my bot does...
Quote[CaffieNET] <<< NICK YIBotDev
[CaffieNET] <<< USER yibot place holder :Awesome stuff
[OtherServ] <<< NICK EpicBot
[OtherServ] <<< USER yibot place holder :Epic stuff
[OtherServ] >>> PING :675CE965
[OtherServ] <<< PONG :675CE965
[OtherServ] >>> :irc.caffie.net 001 EpicBot :Welcome to the CaffieNET IRC Network EpicBot!yibot@178-36-161-22.adsl.inetia.pl
[OtherServ] <<< JOIN #lern4bot
[OtherServ] >>> :irc.caffie.net 002 EpicBot :Your host is irc.caffie.net, running version Unreal3.2.8.1
[OtherServ] >>> :irc.caffie.net 003 EpicBot :This server was created tor jul 30 2009 at 18:10:17 CEST
As I can see, 001 and 002 barely have any difference, but your script doesn't recognize 002 correctly. My guess would be that none of else if applies to this situation. First, it passes because it contains space obviously . I wonder what is different about 001 and 002...
But... I remember that I had once similar issue... let's check in telnet (line breaks added for clarity)...
Quote:irc.caffie.net 001 telnet :Welcome to the CaffieNET IRC Network telnet!telnet@178-36-161-22.adsl.inetia.pl\n\r
:irc.caffie.net 002 telnet :Your host is irc.caffie.net, running version Unreal3.2.8.1\n\r
\n\r? In most programming languages I've seen, receiving data expects \n or \r\n, but definitely not invalid \n\r (I wonder why some servers send those, it's not something that any OS does...). In this case, it has seen \n, and considered \r to be part of next line... That's probably the issue.
|
|
|
Pages: 1  |
|
|
|
|
Forum Index - Hobbies - Computers & Technology - [VB.NET] IRC and Sockets {and more or less .Substring()} |
|
|
 |
|
 |
The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.
Copyright © 2005 - 2013 - SMW Central Legal Information - Link To UsTotal queries: 29
|
|
|
|