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.

Making a script work in 2 channels

Help for those learning Tcl or writing their own scripts.
Post Reply
S
Sbarkeri
Voice
Posts: 15
Joined: Tue Aug 11, 2009 12:01 am

Making a script work in 2 channels

Post by Sbarkeri »

Hi, I have the following script and it works fine however I would like to edit it so that it works in another channel

Code: Select all

bind pub -|- !uac pub:uac
proc pub:uac {nick host hand chan text} {
  if {![string match [string tolower $chan] "#clanbase.crew.mw2"]} {
   return 0
  }
  if {[llength $text] == 0} {
   putserv "MODE #clanbase.mw2 -c"
   putserv "PRIVMSG #clanbase.mw2 :** NOTICE ** The gamecrew can provide limited support for UAC2, if you are having problems please visit: http://uac2.com/forums/ and wait for a UAC2 admin to respond to your issue."
   putserv "MODE #clanbase.mw2 +c"
  } else {
   set target [lindex [split $text] 0]
   putserv "MODE #clanbase.mw2 -c"
   putserv "PRIVMSG #clanbase.mw2 :** NOTICE FOR $target ** The gamecrew can only provide limited support for UAC2, if you are having problems please visit: http://uac2.com/forums/ and wait for a UAC2 admin to respond to your issue."
   putserv "MODE #clanbase.mw2 +c"
  }
}
You will notice that this script sends a message to the client channel (#clanbase.mw2) then someone in the admin channel (#clanbase.crew.m2) says !uac UserName. However I would like to extend this script so that it also works in #clanbase.cod4 and #clanbase.crew.cod4, I want it to have the same message etc. however just to extend it to work in both channels.

Cheers.
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Code: Select all

 set uac_chans "#clanbase.mw2 #clanbase.cod4 #clanbase.crew.cod4"

 bind pub -|- !uac pub:uac

 proc pub:uac {nick host hand chan text} {
  global uac_chans
  if {[lsearch "$uac_chans" "$chan"] == -1} {
   return 0
  }
  if {[llength $text] == 0} {
   pushmode $chan -c
   puthelp "PRIVMSG $chan :** NOTICE ** The gamecrew can provide limited support for UAC2, if you are having problems please visit: http://uac2.com/forums/ and wait for a UAC2 admin to respond to your issue."
   pushmode $chan +c
  } else {
   set target [lindex [split $text] 0]
   pushmode $chan -c
   puthelp "PRIVMSG $chan :** NOTICE FOR $target ** The gamecrew can only provide limited support for UAC2, if you are having problems please visit: http://uac2.com/forums/ and wait for a UAC2 admin to respond to your issue."
   pushmode $chan +c
  }
 }
S
Sbarkeri
Voice
Posts: 15
Joined: Tue Aug 11, 2009 12:01 am

Post by Sbarkeri »

Thanks but I kind of think you misunderstood my problem a little. What your script will do is respond to the !uac command when it is said in any of the 4 channels however what I want it to do is for an admin to say "!uac" or "!uac nick" in of the #xxx.crew channels and for the message to display in the standard channel. For example I will say "!uac Test" in #clanbase.crew.cod4 and in #clanbase.cod4 the message "**Notice for Test** Blah Blah" will appear. My script that I posted in the first post already does this for one pair of channels however I would like to work for the other pair too. So that the messages will appear in like so

!uac Sent Here ---> Notice Displayed Here
#Clanbase.crew.mw2 ---> #clanbase.mw2
#Clanbase.crew.cod4 ---> #clanbase.cod4


Cheers[/b]
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Understood :D *after next post* probably :/

Code: Select all

 bind pub -|- !uac pub:uac

 proc pub:uac {nick host hand chan text} {
  set c [lindex [split [string tolower $chan] #] 1]
  if {([regexp -- {^(clanbase.crew.mw2|clanbase.crew.cod4|clanbase.mw2|clanbase.cod4)$} "$c"])&&([llength $text] == 0)} {
   if {[string match "*.cod4" "$c"]} {
    set dest "#clanbase.cod4"
   } else {
    set dest "#clanbase.mw2"
   }
   putserv "MODE $dest -c"
   putserv "PRIVMSG $dest :** NOTICE ** The gamecrew can only provide limited support for UAC2, if you are having problems please visit: http://uac2.com/forums/ and wait for a UAC2 admin to respond to your issue."
   putserv "MODE $dest +c" 
  } elseif {([regexp -- {^(clanbase.crew.mw2|clanbase.crew.cod4)$} "$c"])&&([llength $text] > 0)} {
    set targets [lrange [split $text] 0 end]
    if {[string match "*.crew.cod4" "$c"]} {
     set dest "#clanbase.cod4"
    } else {
     set dest "#clanbase.mw2"
    }
     putserv "MODE $dest -c"
     putserv "PRIVMSG $dest :** NOTICE FOR $targets ** The gamecrew can only provide limited support for UAC2, if you are having problems please visit: http://uac2.com/forums/ and wait for a UAC2 admin to respond to your issue."
     putserv "MODE $dest +c" 
  }
 }
Last edited by TCL_no_TK on Sun Jan 17, 2010 2:51 pm, edited 3 times in total.
S
Sbarkeri
Voice
Posts: 15
Joined: Tue Aug 11, 2009 12:01 am

Post by Sbarkeri »

Sorry to sound so fussy however this is still going to send the message to the channel the user types the bind in as the pushmode and pushhelp and being sent to the $chan which as we all know is set to whatever channel the bind was originally posted in. Here is what I wanted to happen:

Code: Select all

User Types "!uac" or "!uac NICK" in #clanbase.crew.cod4 or #clanbase.crew.mw2

If channel = #clanbase.crew.cod4 Then
Send PRIVMSG (*NOTICE* BLAH BLAH) to #clanbase.cod4
If bind "!uac" has a NICK Then Send PRIVMSG (*NOTICE FOR NICK* BLAH BLAH)

If channel = #clanbase.crew.mw2 Then
Send PRIVMSG to #clanbase.mw2
If bind "!uac" has a NICK Then Send PRIVMSG (*NOTICE FOR NICK* BLAH BLAH)
Hope that kind of made it a little clearer, sorry for any inconveinience!
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Not at all, dont think my brain works as well with old age now :P i've edited my last post anyway, hopefully this should do the trick :wink: if not you can always post again :arrow:
S
Sbarkeri
Voice
Posts: 15
Joined: Tue Aug 11, 2009 12:01 am

Post by Sbarkeri »

Aha :D Thanks As Always, glad we got there eventually :P
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

lol me too :P
Post Reply