Advertisement
outsider

relay.tcl

Nov 15th, 2020
1,452
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # ------------------------------------------------------
  2. #    OUTsider's Complex & Advanced RelayScript v1.0
  3. # ------------------------------------------------------
  4. # - Make sure you set the same relayid for all
  5. #   channels on all networks you want to link together
  6. # - Enable the relay by setting the channel +relay
  7. # - You can link chans on the same net or crossnet
  8. #   or whatever combination you want
  9.  
  10. setudef flag relay
  11. setudef flag relay_mode
  12. setudef int relayid
  13.  
  14. bind bot - RELAY relay:bot
  15. proc relay:bot {from trigger args} {
  16.     global server network
  17.     set args [lindex $args 0]
  18.     set cmd [lindex $args 0]
  19.     set rid [lindex $args 1]
  20.     set rnetwork [lindex $args 2]
  21.     set rnick [lindex $args 3]
  22.     set rargs [lrange $args 4 e]
  23.     switch -- $cmd {
  24.         "PUB" { set msg "\[$rnick@$rnetwork\] $rargs" }
  25.         "ACT" { set msg "* \[$rnick@$rnetwork\] $rargs" }
  26.         "JOIN" { set msg "*** \[$rnetwork\] $rnick ($rargs) has joined" }
  27.         "QUIT" { set msg "*** \[$rnetwork\] $rnick has signed off ($rargs)" }
  28.         "PART" { set msg "*** \[$rnetwork\] $rnick has left the channel ($rargs)" }
  29.         "KICK" { set msg "*** \[$rnetwork\] $rnick has been kicked by [lindex $rargs 0] ([lrange $rargs 1 e])" }
  30.         "MODE" { set msg "*** \[$rnetwork\] $rnick sets mode $rargs" }
  31.         "NICK" { set msg "*** \[$rnetwork\] $rnick changed nick to $rargs" }
  32.         "LIST" {
  33.             set repl ""
  34.             foreach lchan [channels] {
  35.                 if {[channel get $lchan relayid] == $rid} {
  36.                     set modes ""
  37.                     if {[botisop $lchan]} { lappend modes "@" }
  38.                     if {[botishalfop $lchan]} { lappend modes "%" }
  39.                     if {[botisvoice $lchan]} { lappend modes "+" }
  40.                     lappend repl "[join $modes]$lchan ([llength [chanlist $lchan]])"
  41.                 }
  42.             }
  43.             if {$repl != ""} {
  44.                 putbot $from "RELAY REPL $rid $network $rnick $network ($server): $repl"
  45.             }
  46.             return
  47.         }
  48.         "REPL" {
  49.             putnotc $rnick [join $rargs]
  50.             return
  51.         }
  52.         "RMODE" {
  53.             if {[string tolower [lindex $rargs 0]] != [string tolower $network]} { return }
  54.             foreach lchan [channels] {
  55.                 if {[channel get $lchan relayid] == $rid} {
  56.                     putserv "MODE $lchan [lrange $rargs 1 e]"
  57.                 }
  58.             }
  59.             return
  60.         }
  61.         "RKICK" {
  62.             set target [lindex [split [lindex $rargs 0] @] 0]
  63.             set rnet [lindex [split [lindex $rargs 0] @] 1]
  64.             set reason "LinkKick by $rnick@$rnetwork: [lrange $rargs 1 e]"
  65.             if {[string tolower $rnet] != [string tolower $network]} { return }
  66.             set found 0
  67.             foreach lchan [channels] {
  68.                 if {[channel get $lchan relayid] == $rid && [onchan $target $lchan]} {
  69.                     putkick $lchan $target $reason
  70.                     incr found
  71.                 }
  72.             }
  73.             if {$found==0} {
  74.                 putbot $from "RELAY REPL $rid $network $rnick User $target not found in any of the relaychannels on $network"
  75.             }
  76.             return
  77.         }
  78.         "RWHOM" {
  79.             if {[string tolower $rargs] != [string tolower $network]} { return }
  80.             foreach lchan [channels] {
  81.                 if {[channel get $lchan relayid] == $rid} {
  82.                     putbot $from "RELAY REPL $rid $network $rnick User on $lchan@$network:"
  83.                     foreach user [chanlist $lchan] {
  84.                         set modes ""
  85.                         if {[isop $user $lchan]} { lappend modes "@" }
  86.                         if {[ishalfop $user $lchan]} { lappend modes "%" }
  87.                         if {[isvoice $user $lchan]} { lappend modes "+" }
  88.                         putbot $from "RELAY REPL $rid $network $rnick [join $modes]$user ([getchanhost $user]) Idle: [duration [getchanidle $user $lchan]]"
  89.                     }
  90.                 }
  91.             }
  92.             putbot $from "RELAY REPL $rid $network $rnick End of LinkWhom"
  93.             return
  94.         }
  95.         "RMSG" {
  96.             set target [lindex [split [lindex $rargs 0] @] 0]
  97.             set rnet [lindex [split [lindex $rargs 0] @] 1]
  98.             if {[string tolower $rnet] != [string tolower $network]} { return }
  99.             foreach chan [channels] {
  100.                 if {[channel get $chan relayid] == $rid} { break }
  101.             }
  102.             putmsg $target "\[$rnick@$rnetwork\] [lrange $rargs 1 e]"
  103.             putmsg $target "To reply to this remote message please join $chan"
  104.             return
  105.         }
  106.     }
  107.     if {[info exists msg]} {
  108.         foreach lchan [channels] {
  109.             if {[channel get $lchan relayid] == $rid} {
  110.                 putmsg $lchan $msg
  111.             }
  112.         }
  113.     }
  114. }
  115.  
  116. proc relay:dopost {rid exceptchan msg} {
  117.     foreach lchan [channels] {
  118.         if {[channel get $lchan relay] && [channel get $lchan relayid] == $rid && $lchan != $exceptchan} {
  119.             putmsg $lchan $msg
  120.         }
  121.     }
  122. }
  123.  
  124. bind pubm - * relay:pubm
  125. proc relay:pubm {nick host hand chan args} {
  126.     global network
  127.     if {![channel get $chan relay] || [channel get $chan relayid] == 0} { return }
  128.     set args [lindex $args 0]
  129.     if {[binds [lindex $args 0]] != ""} { return }
  130.     putallbots "RELAY PUB [channel get $chan relayid] $network $nick $args"
  131.     relay:dopost [channel get $chan relayid] $chan "\[$nick@$network\] $args"
  132. }
  133.  
  134. bind ctcp - * relay:ctcp
  135. proc relay:ctcp {nick host hand chan keyword args} {
  136.     global network
  137.     set args [lindex $args 0]
  138.     if {![validchan $chan] || ![channel get $chan relay] || [channel get $chan relayid] == 0} { return }
  139.     if {$keyword == "ACTION"} {
  140.         putallbots "RELAY ACT [channel get $chan relayid] $network $nick $args"
  141.         relay:dopost [channel get $chan relayid] $chan "* \[$nick@$network\] $args"
  142.     }
  143. }
  144.  
  145. bind join - * relay:join
  146. proc relay:join {nick host hand chan} {
  147.     global network
  148.     if {![channel get $chan relay] || [isbotnick $nick] || [channel get $chan relayid] == 0} { return }
  149.     putallbots "RELAY JOIN [channel get $chan relayid] $network $nick $host"
  150.     relay:dopost [channel get $chan relayid] $chan "*** \[$network\] $nick ($host) has joined the channel"
  151. }
  152.  
  153. bind sign - * relay:sign
  154. proc relay:sign {nick host hand chan args} {
  155.     global network
  156.     set args [lindex $args 0]
  157.     if {![channel get $chan relay] || [isbotnick $nick] || [channel get $chan relayid] == 0} { return }
  158.     putallbots "RELAY QUIT [channel get $chan relayid] $network $nick $args"
  159.     relay:dopost [channel get $chan relayid] $chan "*** \[$network\] $nick has signed off ($args)"
  160. }
  161.  
  162. bind part - * relay:part
  163. proc relay:part {nick host hand chan args} {
  164.     global network
  165.     set args [lindex $args 0]
  166.     if {![channel get $chan relay] || [isbotnick $nick] || [channel get $chan relayid] == 0} { return }
  167.     putallbots "RELAY PART [channel get $chan relayid] $network $nick $args"
  168.     relay:dopost [channel get $chan relayid] $chan "*** \[$network\] $nick left the channel ($args)"
  169. }
  170.  
  171. bind nick - * relay:nick
  172. proc relay:nick {nick host hand chan args} {
  173.     global network
  174.     set args [lindex $args 0]
  175.     if {![channel get $chan relay] || [isbotnick $nick] || [channel get $chan relayid] == 0} { return }
  176.     putallbots "RELAY NICK [channel get $chan relayid] $network $nick $args"
  177.     relay:dopost [channel get $chan relayid] $chan "*** \[$network\] $nick changed nick to $args"
  178. }
  179.  
  180. bind kick - * relay:kick
  181. proc relay:kick {nick host hand chan target reason} {
  182.     global network
  183.     if {![channel get $chan relay] || [channel get $chan relayid] == 0} { return }
  184.     putallbots "RELAY KICK [channel get $chan relayid] $network $target $nick $reason"
  185.     relay:dopost [channel get $chan relayid] $chan "*** \[$network\] $target has been kicked by $nick ($reason)"
  186. }
  187.  
  188. bind mode - * relay:mode
  189. proc relay:mode {nick host hand chan mode target} {
  190.     global network
  191.     if {![channel get $chan relay] || [channel get $chan relayid] == 0 || ![channel get $chan relay_mode]} { return }
  192.     if {$nick == ""} { set nick "SERVER" }
  193.     putallbots "RELAY MODE [channel get $chan relayid] $network $nick $mode $target"
  194.     relay:dopost [channel get $chan relayid] $chan "*** \[$network\] $nick sets mode $mode $target"
  195. }
  196.  
  197. bind pub - !linklist relay:pub:linklist
  198. proc relay:pub:linklist {nick host hand chan args} {
  199.     global network server
  200.     putallbots "RELAY LIST [channel get $chan relayid] $network $nick"
  201.     set repl ""
  202.     foreach lchan [channels] {
  203.         if {[channel get $lchan relayid] == [channel get $chan relayid]} {
  204.             set modes ""
  205.             if {[botisop $lchan]} { lappend modes "@" }
  206.             if {[botishalfop $lchan]} { lappend modes "%" }
  207.             if {[botisvoice $lchan]} { lappend modes "+" }
  208.             lappend repl "[join $modes]$lchan ([llength [chanlist $lchan]])"
  209.         }
  210.     }
  211.     putlog $repl
  212.     putnotc $nick "Links covered by this relay:"
  213.     if {$repl != ""} {
  214.         putnotc $nick "$network ($server): [join $repl]"
  215.     }
  216.     return 1
  217. }
  218.  
  219. bind pub o|o !linkmode relay:pub:linkmode
  220. proc relay:pub:linkmode {nick host hand chan args} {
  221.     global network
  222.     set args [lindex $args 0]
  223.     set rnet [lindex $args 0]
  224.     set modes [lrange $args 1 e]
  225.     if {$modes == ""} {
  226.         putnotc $nick "Usage: !linkmode <network> <modes>"
  227.         return 0
  228.     }
  229.  
  230.     if {[string tolower $rnet] == [string tolower $network]} {
  231.         foreach lchan [channels] {
  232.             if {[channel get $lchan relayid] == [channel get $chan relayid]} {
  233.                 putserv "MODE $lchan $rmodes"
  234.             }
  235.         }
  236.     } else {
  237.         putallbots "RELAY RMODE [channel get $chan relayid] $network $nick $args"
  238.     }
  239.     return 1
  240. }
  241.  
  242. bind pub o|o !linkkick relay:pub:linkkick
  243. proc relay:pub:linkkick {nick host hand chan args} {
  244.     global network
  245.     set args [lindex $args 0]
  246.     set rusr [lindex $args 0]
  247.     set reas [lrange $args 1 e]
  248.     if {$args == ""} {
  249.         putnotc $nick "Usage: !linkkick <nick>@<network> \[reason\]"
  250.         return 0
  251.     }
  252.     if {![string match *@* $rusr]} {
  253.         putnotc $nick "Remote user has to be specified as <nick>@<network>"
  254.         return 0
  255.     }
  256.  
  257.     set rnet [lindex [split [lindex $rusr 0] @] 1]
  258.     if {[string tolower $rnet] == [string tolower $network]} {
  259.         set target [lindex [split [lindex $rusr 0] @] 0]
  260.         set reason "LinkKick by $nick@$network: $reas"
  261.         set found 0
  262.         foreach lchan [channels] {
  263.             if {[channel get $lchan relayid] == [channel get $chan relayid] && [onchan $target $lchan]} {
  264.                 putkick $lchan $target $reason
  265.                 incr found
  266.             }
  267.         }
  268.         if {$found == 0} {
  269.             putnotc $nick "User $target not found in any of the relaychannels on $network"
  270.         }
  271.     } else {
  272.         putallbots "RELAY RKICK [channel get $chan relayid] $network $nick $args"
  273.     }
  274.     return 1
  275. }
  276.  
  277. bind pub o|o !linkwhom relay:pub:linkwhom
  278. proc relay:pub:linkwhom {nick host hand chan args} {
  279.     global network
  280.     set args [lindex $args 0]
  281.     set rnet [lindex $args 0]
  282.     if {$rnet == ""} {
  283.         putnotc $nick "Usage: !linkwhom <network>"
  284.         return 0
  285.     }
  286.     putallbots "RELAY RWHOM [channel get $chan relayid] $network $nick $rnet"
  287.     return 1
  288. }
  289.  
  290. bind pub o|o !linkmsg relay:pub:linkmsg
  291. proc relay:pub:linkmsg {nick host hand chan args} {
  292.     global network
  293.     set args [lindex $args 0]
  294.     set rusr [lindex $args 0]
  295.     set rmsg [lrange $args 1 e]
  296.     if {$args == ""} {
  297.         putnotc $nick "Usage: !linkmsg <nick>@<network> <message>"
  298.         return 0
  299.     }
  300.     if {![string match *@* $rusr]} {
  301.         putnotc $nick "Remote user has to be specified as <nick>@<network>"
  302.         return 0
  303.     }
  304.     set dest [lindex [split $rusr @] 0]
  305.     set rnet [lindex [split $rusr @] 1]
  306.     if {[string tolower $rnet] == [string tolower $network]} {
  307.         putmsg $dest "\[$nick@$network\] $reas"
  308.         putmsg $dest "To reply to this remote message please join $chan"
  309.     } else {
  310.         putallbots "RELAY RMSG [channel get $chan relayid] $network $nick $args"
  311.     }
  312.     return 1   
  313. }
  314.  
Advertisement
RAW Paste Data Copied
Advertisement