This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Help with modification of a script

Support & discussion of released scripts, and announcements of new releases.
Post Reply
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Help with modification of a script

Post by ViciousPiranha »

Hi,

I'm using the following 'relay' script:

Code: Select all

	# 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:
<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:

<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?
s
silentziler
Voice
Posts: 11
Joined: Wed Sep 09, 2015 10:57 am

Re: Help with modification of a script

Post by silentziler »

Add

Code: Select all

regsub {https.*} $text {} text
before your putserv!
s
silentziler
Voice
Posts: 11
Joined: Wed Sep 09, 2015 10:57 am

If you want text after the URL

Post by silentziler »

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: Select all

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.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

That didn't work for me. Do you mind writing the whole script with the change, may I missed out something?
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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: Select all

set text [lrange $text 0 end-1]
that simply eliminates the last element, turning:
<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:
<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.
V
ViciousPiranha
Voice
Posts: 36
Joined: Mon Dec 17, 2012 5:21 am

Post by ViciousPiranha »

Works great caesar, thank you
Post Reply