|
Joined: Aug 2004
Posts: 26
Ameglian cow
|
OP
Ameglian cow
Joined: Aug 2004
Posts: 26 |
I'm using this script to echo from one chan to another.
on *:text:*:#OCForum:{
if ($network $nick $strip($1) = OverNet Klarg [NEW]) {
var %x
.echo -q $regsub($1-,/.*\((.*?)\).*\((.*?)\).*/S,[12\2] 04\1,%x)
scid -at1 if ($network = Efnet) && ($me ison #OCforum.dk) msg #ocforum.dk $($v2 %x,)
}
}
The source which I echo looks like this: 4[7NEW4] - 7Topic:4(Need help on OC4) - 7Section:4(HARDWARE4) And then the output looks like this: [12HARDWARE] 4Need help on OC So question: How can I add that it will ONLY echo those section that are named e.g. HARDWARE, OC, GAMING, NETWORK, tec?
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
on *:text:*:#OCForum:{
if ($network $nick $strip($1) == OverNet Klarg [NEW]) {
var %a = hardware|oc|gaming|network
!.echo -q $regsub($1-,/.*\((.*?)\).*\(( %a )\).*/Six,[12\2] 04\1,%a)
scon -at1 if ($network == Efnet) && ($me ison #OCforum.dk) msg #OCforum.dk % $+ a
}
}
Add the words that you want to match to variable %a, seperated by pipes. Greets
Last edited by FiberOPtics; 17/01/05 03:09 PM.
Gone.
|
|
|
|
Joined: Aug 2004
Posts: 26
Ameglian cow
|
OP
Ameglian cow
Joined: Aug 2004
Posts: 26 |
Hm.. any chance doing it by adding some sort of "if hardware|oc|gaming isin" thingie tomy previous code?
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
You mean you only want it to work if it has one of those categories between the brackets ( ) ? on *:text:*:#OCForum:{
if ($network $nick $strip($1) == OverNet Klarg [NEW]) {
var %a = hardware|oc|gaming|network
var %b = $regsub($1-,/.*\((.*?)\).*\(( %a )\).*/Six,[12\2] 04\1,%a)
if %b { scon -at1 if ($network == Efnet) && ($me ison #OCforum.dk) msg #OCforum.dk % $+ a }
}
}
Greets
Gone.
|
|
|
|
Joined: Aug 2004
Posts: 26
Ameglian cow
|
OP
Ameglian cow
Joined: Aug 2004
Posts: 26 |
Yes, thats what i mean. Hm, the code doesnt seems to work..
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Did the first code I pasted you work? Because nothing has changed really, all that is different is that the result from the $regsub is stored in a var, rather than silenced.
Then the most basic if check to see if it has a value other than 0.
Did it work before, the first code?
Greets
EDIT: I tested the regex with the input that you gave in the first thread, and it works fine. So it isn't the regex part, it is something in the messaging part.
I went on efnet (the network you want to msg) in the channel #ocforum.dk and it was empty. Are you positive that is the network/channel you want to msg to???
Last edited by FiberOPtics; 17/01/05 10:12 PM.
Gone.
|
|
|
|
Joined: Aug 2004
Posts: 26
Ameglian cow
|
OP
Ameglian cow
Joined: Aug 2004
Posts: 26 |
The first code did kind of work, but it echoed everything, no matter which hardware|oc|etc it was.. The second code worked actually better. It echoed only what it was supposed to echo, BUT I'd like to change the output.. source looks like: 4[7NEW4] - 7Topic:4(Need help on OC4) - 7Section:4(HARDWARE4) And i want it to look like: [12HARDWARE] 4Need help on OC See?
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
It does that lol.
That's what I just tested:
I made a quick alias like this:
alias ocforum { var %a = hardware|oc|gaming|offtopic var %b = $regsub($1-,/.*\((.*?)\).*\(( %a )\).*/Six,[12\2] 04\1,%a) echo -a result: %a ** %b }
And then did:
/ocforum 4[7NEW4] - 7Topic:4(Need help on OC4) - 7Section:4(HARDWARE4)
Which echoed to me: result: [12HARDWARE] 04Need help on OC ** 1
lol
EDIT: Are you copying my code exactly as you see it on this board? Btw there is a space around %a on both sides in that regsub, just to be sure that you didn't strip out those spaces.
Last edited by FiberOPtics; 17/01/05 10:26 PM.
Gone.
|
|
|
|
Joined: Aug 2004
Posts: 26
Ameglian cow
|
OP
Ameglian cow
Joined: Aug 2004
Posts: 26 |
lol, sorry got it now! /me n00b Btw, what if the source changed? To: 4[7NEW4] - 7Section:4(HARDWARE4) - 7Topic:4(Need help on OC4) What do i have to change to get the same output as earlier? [12HARDWARE] 04Need help on OC
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Try this one, it won't matter what position. I'm not that much of a regex freak, but it's a working solution: on *:text:*:#OCForum:{
if ($network $nick $strip($1) == OverNet Klarg [NEW]) {
var %a = hardware|oc|gaming|offtopic, %b
if $regsub($1-,/.*section:\(( %a )\).*/Six,[12\1],%a) && $&
$regsub($1-,/.*topic:\((.*?)\).*/Si,04\1,%b) {
scon -at1 if ($network == Efnet) && ($me ison #OCforum.dk) msg #OCforum.dk $+(%,a %,b)
}
}
}
Last edited by FiberOPtics; 17/01/05 11:20 PM.
Gone.
|
|
|
|
Joined: Aug 2004
Posts: 26
Ameglian cow
|
OP
Ameglian cow
Joined: Aug 2004
Posts: 26 |
thanx a lot, worked perfect!!
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Glad to hear it's all working out. Cya Edit: 2 things crossed my mind 1. Right now your match words can only be single words, seperated by pipes. 2. There may come a time where you enter a word as category, that has a character in it, with a special meaning inside a regex. So I altered the script, looks a bit longer too: You can now specify multiple words as category, as long as you seperate each category by a pipe. Example: hardware|over clocking|setting up a pc|oc on *:text:*:#OCForum:{
if ($network $nick $strip($1) == OverNet Klarg [NEW]) {
var %a = hardware|oc|gaming|offtopic, %b
if $regsub($1-,/.*section:\((\Q $+ $replace(%a,\E,\\E,\Q,\\Q,|,\E|\Q) $+ \E)\).*/Si,[12\1],%a) && $&
$regsub($1-,/.*topic:\((.*?)\).*/Si,04\1,%b) {
scon -at1 if ($network == Efnet) && ($me ison #OCforum.dk) msg #OCforum.dk $+(%,a %,b)
}
}
}
Last edited by FiberOPtics; 18/01/05 12:43 AM.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
I made an error in the above code, more specifically in the $replace as part of the regsub.
The replace should look like: $replacecs(%a,\E,\E\\E\Q,|,\E|\Q)
Gone.
|
|
|
|
|