|
Iljan
|
Iljan
|
I have some problems, i have made a scripts that posts in to a db by a php page but the variable of the channel (#dutch in this case) wont be posted in to the db.  The problem is the # in the channelname.  How do i strip $chan from #dutch to just "dutch" and set it as %temp.channel ?
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
$remove(#channelname,$chr(35))
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
Hi. //set %temp.channel $gettok($chan,1,35) //set %temp.channel $remove($chan,$chr(35)) //set %temp.channel $mid($chan,2-,$len($chan)) //tokenize 35 $chan | set %temp.channel $1 There's four examples of how you can do this.  Edit: Changed #dutch to $chan. -Andy
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
set %temp.channel $remove($chan,$chr(35)) or set %temp.channel $right($chan,-1) EDIT: Sheesh. Can't even reply within 15 minutes without being beat to it by not one, but TWO people. 
Last edited by Riamus2; 12/09/05 08:41 PM.
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Channel names can have multiple #'s in it, so using $remove would remove them all.
$mid($chan,2) is all one really needs, which does the same as your solution with $right.
Then again, maybe he didn't know that channel names can contain multiple #'s, and wants them all removed, which would mean the only good solution is, as you first suggested, $remove.
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Yeah, I thought about channels having multiple #'s.  I didn't realize the length parameter was optional on $mid. Good to know. 
|
|
|
|
Joined: Sep 2005
Posts: 2,630
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,630 |
Or simply replace it with a character that's illegal in a channel name, for example: $replace($chan,$(#,),$chr(44))
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
Well $chr(44) would not be a very good example to use but as you'd get: ,mIRC but..
$replace($chan,$(#,),$+($chr(32))) would be fine. $replace($chan,$(#,),$+($chr(3))) would also be fine if characters after the '#' are not numeric.
-Andy
|
|
|
|
Iljan
|
Iljan
|
Thankyou all for helping me out here, i used set %temp.channel $gettok($chan,1,35) And it works fine. Keep up the good work!!! 
|
|
|
|
Joined: Sep 2005
Posts: 2,630
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,630 |
So you can retrieve the correct channel name back later, for example:
My method:
Post: (mIRC) #w#e#i#r#d#c#h#a#n#n#e#l# -> (DB) ,w,e,i,r,d,c,h,a,n,n,e,l, Retrieve: (DB) ,w,e,i,r,d,c,h,a,n,n,e,l, -> (mIRC) #w#e#i#r#d#c#h#a#n#n#e#l#
Your method:
Post: (mIRC) #w#e#i#r#d#c#h#a#n#n#e#l# -> (DB) weirdchannel Retrieve: (DB) weirdchannel -> (mIRC) weirdchannel
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
That was why there was the second method posted. 
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Replacing the #'s with a space will not be fine, since I've specifically stated that channel names can have multiple #'s in them.
It would turn the channel #andy#is#crazy to andy is crazy , which is no longer distinguishable as a channel from regular other text.
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Hey, you might want to edit that to:
set %temp.channel $gettok($chan,1-,35)
Otherwise, you won't get the entire channel name if it has other #'s in it.
EDIT: Actually, that won't help either as it will remove the #'s.
You should use either of these instead:
set %temp.channel $mid($chan,2) set %temp.channel $right($chan,-1)
Last edited by Riamus2; 12/09/05 10:19 PM.
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
Well I guess so but I'd never attempt to join a channel with consecutive #'s in it, but if others actually do do it well then it was indeed wrong of me.  -Andy
|
|
|
|
Iljan
|
Iljan
|
i used it in the following script:
on 1:join:#:{ if ($nick == $me) { set %temp.channel $gettok($chan,1,35) .sockopen devesteservjoin some.server.url 80 .timer12 1 2 .sockwrite -n devesteservjoin GET /beheer/update.php?action=join $+ &nick= $+ $me $+ &channel= $+ %temp.channel HTTP/1.0 $+ $crlf .timer13 1 2 .sockwrite -n devesteservjoin Accept: */* $+ $crlf .timer14 1 2 .sockwrite -n devesteservjoin User-Agent: mIRC $+ $crlf .timer15 1 2 .sockwrite -n devesteservjoin Host: some.server.url $+ $crlf .timer16 1 2 .sockwrite -n devesteservjoin $crlf echo 4 -s Updating to server | set %chan.join $chan } } on *:SOCKCLOSE:devesteservjoin:{ /echo 4 -s Http server updated, thank you - Join at %chan.join }
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Hmm, why are you using timers to sockwrite to the connection? They serve no purpose as far as I can tell. Btw you don't need to put a $crlf after each header entry, since you are using the 'n' switch from sockwrite, which will append a $crlf already. Anyway, you've been helped accordingly, so I suppose this thread is finished.
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Iljan, read me last post (and the edit).
If you try using a channel like #test#1, it won't work correctly as you have it right now. Granted, those types of channel names are few and far between, but better to be safe than sorry.
|
|
|
|
Joined: Sep 2005
Posts: 2,630
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,630 |
All he said was that the # in the channel name was the problem, he didn't say it was only a problem if it was at the start of the text so using $right(#channel,-1) could still mess up for things like #channel#.
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
You might want to add those sockwrite commands inside an IF statement to check if the socket is opened otherwise you'll get an error.
On me:*:Join:#: {
set %temp.channel $gettok($chan,1-,35)
.sockopen devesteservjoin some.server.url 80
}
on 1:Sockopen:devesteservjoin:{
if ($sock(devesteservjoin)) {
.sockwrite -n $v1 GET /beheer/update.php?action=join $+ &nick= $+ $me $+ &channel= $+ %temp.channel HTTP/1.0 $+ $crlf
.sockwrite -n $v1 Accept: */* $+ $crlf
.sockwrite -n $v1 User-Agent: mIRC $+ $crlf
.sockwrite -n $v1 Host: some.server.url $+ $crlf
.sockwrite -n $v1 $crlf
echo 4 -s Updating to server | set %chan.join $chan
}
}
-Andy
|
|
|
|
|