|
-
Mar 20th, 2006, 08:09 PM
#1
Thread Starter
Hyperactive Member
Mid left right
I used to use
Nick = Left$(IrcRead(0), InStrRev(IrcRead(0), "!") - 1)
Nick = Mid$(Nick, InStrRev(Nick, ":") + 1)
to get the Nick of someone in IRC but now in .net it says left is an unknown function cause someone help me witht his IrcRead(0) would be something like this :[email protected]
-
Mar 20th, 2006, 08:12 PM
#2
Re: Mid left right
If you know how to use Mid, check out Substring..If you dont, well check out substring
Nick = Nick.Substring(0,5)
-
Mar 20th, 2006, 08:13 PM
#3
Thread Starter
Hyperactive Member
Re: Mid left right
Yea but the only constant thing to go off of is ! and @ the others will vary in letters and number of letters.
-
Mar 20th, 2006, 08:31 PM
#4
Re: Mid left right
The equivalent of InStr and InStrRev are String.IndexOf and String.LastIndexOf. That will allow you to do basically what you are now without Runtime functions.
-
Mar 20th, 2006, 08:43 PM
#5
Thread Starter
Hyperactive Member
Re: Mid left right
Aren't those just to see if that field is inside of the string? I need to make the string Nick = Rub3X in that case.
-
Mar 20th, 2006, 08:58 PM
#6
Re: Mid left right
Test this, okay?
VB Code:
Name = Name.Substring(0, Name.IndexOf("!"c))
-
Mar 20th, 2006, 09:01 PM
#7
Re: Mid left right
IndexOf will give you the index of the first occurence of a character or substring, while LastIndexOf will give you the index of the last occurrence. You can use the results of those methods to calculate the parameters to pass to Substring, which is exactly how InStrRev is being used in the code you originally posted.
-
Mar 20th, 2006, 09:19 PM
#8
Thread Starter
Hyperactive Member
-
Mar 20th, 2006, 09:30 PM
#9
Re: Mid left right
Cool. Don't forget to resolve your thread from the Thread Tools menu.
-
Mar 20th, 2006, 09:36 PM
#10
Re: Mid left right
And the old vb6 string functions are in the Strings module... (although it is best to use the above mentioned methods, this is just to give me something to post about )
Strings.Left
Strings.Right
... etc
-
Mar 20th, 2006, 10:14 PM
#11
Thread Starter
Hyperactive Member
Re: Mid left right
erm I am actually having troubles now with that code. I am making an IRC bot and when I try and connect it says
Attempting connection to irc.cyber-knowledge.net....
Connected to server.
Error: Length cannot be less than zero.
Parameter name: length
Error: Length cannot be less than zero.
Parameter name: length
[email protected] MODE #main +v DotNetBotPort
In the textbox. It still connects but certain commands don't work...:S Everytime I send the variable Nick to the server it says that.
-
Mar 20th, 2006, 10:20 PM
#12
-
Mar 20th, 2006, 10:39 PM
#13
Thread Starter
Hyperactive Member
Re: Mid left right
Ok here is the code. I commented out the Nick parse stuff for now and replaced it with just Rub3X for now since that is my IRC nick. I am trying to make the login for it but as you can see I am having trouble. I don't know exactly how to use the IP and check if the person who is typing .login has the same IP as the one logged in. And tbh I doubt you will understand it since it mostly deals with raw IRC commands. Is there a way to pause just what happens in ONE sub while the program continues? Cause...
VB Code:
ElseIf C(3) = ":" & Prefix & "remove" & Chr(13) Then
wsClient.SendData(wsClient.StringToBytes("USERIP Rub3X" & vbCrLf))
If TyperIP = UserIP Then
wsClient.SendData(wsClient.StringToBytes("PRIVMSG " & IrcChan & " :Removing bot please wait..." & vbCrLf))
wsClient.SendData(wsClient.StringToBytes("QUIT" & " :Leaving" & vbCrLf))
End
That trys to compare the person's IP who is typing vs the UserIP which is the IP of the user logged in. But in order to do this you need to send the USERIP raw command and by the time i can do that it's too late and it's already went into a false value of that makes any sense. So I think if I can pause just what is happening in one sub it will work.
Last edited by OMITT3D; Mar 20th, 2006 at 10:45 PM.
-
Mar 20th, 2006, 11:20 PM
#14
Thread Starter
Hyperactive Member
Re: Mid left right
Nvm that won't even work cause i did something just to test it
ElseIf C(3) = ":" & Prefix & "remove" & Chr(13) Then
wsClient.SendData(wsClient.StringToBytes("USERIP Rub3X" & vbCrLf))
Dim z As Long
z = "0"
Do Until z > 699999999
z = z + 1
Loop
If TyperIP = UserIP Then
wsClient.SendData(wsClient.StringToBytes("PRIVMSG " & IrcChan & " :Removing bot please wait..." & vbCrLf))
wsClient.SendData(wsClient.StringToBytes("QUIT" & " :Leaving" & vbCrLf))
End
End If
and all it did was execute the loop first then it did Case "340" after that so idk how to do it =s
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|