egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with modification of a script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 34

PostPosted: Tue Jul 04, 2017 2:08 am    Post subject: Help with modification of a script Reply with quote

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
View user's profile Send private message
silentziler
Voice


Joined: 09 Sep 2015
Posts: 10

PostPosted: Wed Jul 05, 2017 2:07 pm    Post subject: Re: Help with modification of a script Reply with quote

Add
Code:

regsub {https.*} $text {} text

before your putserv!
Back to top
View user's profile Send private message
silentziler
Voice


Joined: 09 Sep 2015
Posts: 10

PostPosted: Wed Jul 05, 2017 7:07 pm    Post subject: If you want text after the URL Reply with quote

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
View user's profile Send private message
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 34

PostPosted: Sat Jul 08, 2017 5:58 am    Post subject: Reply with quote

That didn't work for me. Do you mind writing the whole script with the change, may I missed out something?
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3401
Location: Area 51

PostPosted: Sun Jul 09, 2017 4:47 am    Post subject: Reply with quote

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)

_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
ViciousPiranha
Voice


Joined: 17 Dec 2012
Posts: 34

PostPosted: Tue Jul 11, 2017 12:42 pm    Post subject: Reply with quote

Works great caesar, thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber