| View previous topic :: View next topic |
| Author |
Message |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Tue Jul 04, 2017 2:08 am Post subject: Help with modification of a script |
|
|
Hi,
I'm using the following 'relay' script:
| Code: |
# Channel flag.
setudef flag monitorText2
# Subchannel.
set subchannel2 #football2
# Bind all text in all channels.
bind pubm - * monitorProc2
proc monitorProc2 {nick uhost hand chan text} {
global subchannel2
# Check channel flag.
if {![channel get $chan monitorText2]} {
return 0
}
# Check text for matching values.
if {[string match "*DEAL DONE:*" $text] } {
# Send matching text to subchannel.
putserv "PRIVMSG #football :$text"
}
|
And I'm looking for a modification to the script - that it will not relay a URL when it's in the end of the message
For example, it currently relays this message:
| Quote: |
<DiMarzio> Transfer News Live: DEAL DONE: Napoli have signed Adam Ounas from Bordeaux for €10m, rising to €12m on a 5-year contract. (Source: BWFC) https://t.co/SekHZY3hIs |
and I want it to relay it without the url.
Expected result:
| Quote: |
<DiMarzio> Transfer News Live: DEAL DONE: Napoli have signed Adam Ounas from Bordeaux for €10m, rising to €12m on a 5-year contract. (Source: BWFC) |
Help please? |
|
| Back to top |
|
 |
silentziler Voice
Joined: 09 Sep 2015 Posts: 11
|
Posted: Wed Jul 05, 2017 2:07 pm Post subject: Re: Help with modification of a script |
|
|
Add
| Code: |
regsub {https.*} $text {} text
|
before your putserv! |
|
| Back to top |
|
 |
silentziler Voice
Joined: 09 Sep 2015 Posts: 11
|
Posted: Wed Jul 05, 2017 7:07 pm Post subject: If you want text after the URL |
|
|
If the URL is the last thing in the sentence, it will be removed.
If there is text remaining after the URL, the URL will remain.
Replace your putserv with the code below:
Updated:
| Code: |
regexp {https://.* (..*)} $text - 2
if {[info exists 2] eq "0" } {
regsub {https.*} $text {} text
putserv "PRIVMSG #football :$text"
} else {
putserv "PRIVMSG #football :$text"
}
|
Last edited by silentziler on Tue Jul 11, 2017 2:16 pm; edited 1 time in total |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Sat Jul 08, 2017 5:58 am Post subject: |
|
|
| That didn't work for me. Do you mind writing the whole script with the change, may I missed out something? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun Jul 09, 2017 4:47 am Post subject: |
|
|
You aren't missing anything cos that regexp doesn't seem to be working, at least I tried with the text you said in first post.
Anyway, if the text you want to rely has that url at the end and all you want is to relay the same text but without the url at the end then woudln't it be simplier to go with something like:
| Code: |
set text [lrange $text 0 end-1]
|
that simply eliminates the last element, turning:
| Quote: |
<DiMarzio> Transfer News Live: DEAL DONE: Napoli have signed Adam Ounas from Bordeaux for €10m, rising to €12m on a 5-year contract. (Source: BWFC) https://t.co/SekHZY3hIs
|
into:
| Quote: |
<DiMarzio> Transfer News Live: DEAL DONE: Napoli have signed Adam Ounas from Bordeaux for €10m, rising to €12m on a 5-year contract. (Source: BWFC)
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
ViciousPiranha Voice
Joined: 17 Dec 2012 Posts: 36
|
Posted: Tue Jul 11, 2017 12:42 pm Post subject: |
|
|
| Works great caesar, thank you |
|
| Back to top |
|
 |
|