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.

Spychan.tcl on/off switch

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
E
Elements
Voice
Posts: 12
Joined: Thu Mar 19, 2009 11:33 am

Spychan.tcl on/off switch

Post by Elements »

Spychan
http://www.egghelp.org/cgi-bin/tcl_arch ... ad&id=1109
works fine and does all i need but i wonder if anyone
can add an an on/off public command to it like !echo on - !echo off
or anything to make it start/stop relaying on the fly.
Thank you.

Code: Select all

# Info
# Author : MeTroiD - #v1per on Quakenet
# Version: 1.2
set spy(author)  "MeTroiD - #v1per on Quakenet"
set spy(version) "1.2"

# Description

# This script will relay anything said on one channel to the other channel you configure
# I recommend you don't run this script on a bot that already has to do alot
# If the channel you're spying on has alot of users with alot of talking your bot could excess flood

# Configuration

# The channel it reports everything to
set spy(home) "#twilight-zone"

# The channel it gets all the data from and then reports it to the homechannel
set spy(chan) "#v1per"

bind PUBM   -|- *                spychan:chat
bind CTCP   -|- "ACTION"         spychan:action
bind SIGN   -|- "$spy(chan) *"   spychan:sign
bind JOIN   -|- "$spy(chan) *"   spychan:join
bind PART   -|- "$spy(chan) *"   spychan:part
bind SPLT   -|- "$spy(chan) *"   spychan:split
bind KICK   -|- "$spy(chan) *"   spychan:kick
bind RAW     *  "MODE"           spychan:mode


proc spychan:part { nickname hostname handle channel reason } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has left $spy(chan)"
	}
       }


proc spychan:join { nickname hostname handle channel } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has joined $spy(chan)"
	}
       }

proc spychan:kick { nickname hostname handle channel target reason } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $target was kicked from $spy(chan) by $nickname ($reason)"
	}
       }

proc spychan:mode { from key arguments } {
	global spy
	set channel [string trim [lindex [split $arguments] 0]] 
	set modechange [string trim [lindex [split $arguments] 1]] 
	set victims [string trim [join [lrange [split $arguments] 2 end]]] 

	set nickname [string trim [lindex [split $from "!"] 0]] 
	set hostname [string trim [lindex [split $from "!"] 1]]
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname sets mode: $modechange $victims"
	}
       }

proc spychan:sign { nickname hostname handle channel reason } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has quit IRC ($reason)"
	}
       }

proc spychan:split { nickname hostname handle channel arguments } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
	putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname has split from the network"
	}
       }

proc spychan:chat { nickname hostname handle channel arguments } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
        putserv "PRIVMSG $spy(home) :\[$channel\] <$nickname> $arguments"
        }
       }

proc spychan:action { nickname hostname handle channel keyword arguments } {
	global spy
	if {[string equal -nocase $channel $spy(chan)]} {
        putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname $arguments"
        }
       }


putlog "Spychan.tcl version $spy(version) by $spy(author) Loaded!" 
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: Spychan.tcl on/off switch

Post by willyw »

Elements wrote: ...
or anything to make it start/stop relaying on the fly.
One way :

Code: Select all

# Info
# Author : MeTroiD - #v1per on Quakenet
# Version: 1.2
set spy(author)  "MeTroiD - #v1per on Quakenet"
set spy(version) "1.2"

# Description

# This script will relay anything said on one channel to the other channel you configure
# I recommend you don't run this script on a bot that already has to do alot
# If the channel you're spying on has alot of users with alot of talking your bot could excess flood

# Configuration

# The channel it reports everything to
set spy(home) "#twilight-zone"

# The channel it gets all the data from and then reports it to the homechannel
set spy(chan) "#v1per"

bind PUBM   -|- *                spychan:chat
bind CTCP   -|- "ACTION"         spychan:action
bind SIGN   -|- "$spy(chan) *"   spychan:sign
bind JOIN   -|- "$spy(chan) *"   spychan:join
bind PART   -|- "$spy(chan) *"   spychan:part
bind SPLT   -|- "$spy(chan) *"   spychan:split
bind KICK   -|- "$spy(chan) *"   spychan:kick
bind RAW     *  "MODE"           spychan:mode


setudef flag spychan



proc spychan:part { nickname hostname handle channel reason } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has left $spy(chan)"
   }

}
       }


proc spychan:join { nickname hostname handle channel } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has joined $spy(chan)"
   }

}
       }



proc spychan:kick { nickname hostname handle channel target reason } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :\[$channel\] * $target was kicked from $spy(chan) by $nickname ($reason)"
   }

}
       }



proc spychan:mode { from key arguments } {
   global spy

   set channel [string trim [lindex [split $arguments] 0]]

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {

   set modechange [string trim [lindex [split $arguments] 1]]
   set victims [string trim [join [lrange [split $arguments] 2 end]]]

   set nickname [string trim [lindex [split $from "!"] 0]]
   set hostname [string trim [lindex [split $from "!"] 1]]
   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname sets mode: $modechange $victims"
   }
}
       }



proc spychan:sign { nickname hostname handle channel reason } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname ($hostname) has quit IRC ($reason)"
   }

}
       }



proc spychan:split { nickname hostname handle channel arguments } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname has split from the network"
   }

}
       }



proc spychan:chat { nickname hostname handle channel arguments } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
        putserv "PRIVMSG $spy(home) :\[$channel\] <$nickname> $arguments"
        }

}
       }

proc spychan:action { nickname hostname handle channel keyword arguments } {
   global spy

if {([lsearch -exact [channel info $channel] {+spychan}] != -1)} {


   if {[string equal -nocase $channel $spy(chan)]} {
        putserv "PRIVMSG $spy(home) :\[$channel\] * $nickname $arguments"
        }
}
       }



putlog "Spychan.tcl version $spy(version) by $spy(author) Loaded!" 


Enclosed everything in each proc, in an if statement. It checks a user defined channel flag. If set to + , then proc continues.

After installing, log into your bot's partyline via DCC chat or telnet.
Do .chaninfo on the channel set with : set spy(chan)
In this case, it is "#v1per"
and see the current value of "spychan".
When it is -spychan , reporting is off
If you change it to +spychan , reporting is on.
Change it with .chanset +spychan
or
.chanset -spychan

I have not extensively tested this. Only a couple brief tests, and it worked.

I hope this helps.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Another way:

Code: Select all

# Use this script with spychan.tcl
# it unbinds the binds from that script, to effect an "off"
# and will rebind them, to effect and "on"
#
# Usage: For "off", send:         /msg <botnick> !unbind-spy
#
#        For "on", send:          /msg <botnick> !rebind-spy
#
# As is, this script will only allow users with +o flag to trigger it.
#



bind msg o "!rebind-spy" rebind:spy
bind msg o "!unbind-spy" unbind:spy

proc rebind:spy {nick uhost handle text} {
global spy

bind PUBM   -|- *                spychan:chat
bind CTCP   -|- "ACTION"         spychan:action
bind SIGN   -|- "$spy(chan) *"   spychan:sign
bind JOIN   -|- "$spy(chan) *"   spychan:join
bind PART   -|- "$spy(chan) *"   spychan:part
bind SPLT   -|- "$spy(chan) *"   spychan:split
bind KICK   -|- "$spy(chan) *"   spychan:kick
bind RAW     *  "MODE"           spychan:mode

}


proc unbind:spy {nick uhost handle text} {
global spy

unbind PUBM   -|- *                spychan:chat
unbind CTCP   -|- "ACTION"         spychan:action
unbind SIGN   -|- "$spy(chan) *"   spychan:sign
unbind JOIN   -|- "$spy(chan) *"   spychan:join
unbind PART   -|- "$spy(chan) *"   spychan:part
unbind SPLT   -|- "$spy(chan) *"   spychan:split
unbind KICK   -|- "$spy(chan) *"   spychan:kick
unbind RAW     *  "MODE"           spychan:mode
 
}


Elements:
if you decide to try this method, then just use your original spychan script - no need to use the one I modified above.
E
Elements
Voice
Posts: 12
Joined: Thu Mar 19, 2009 11:33 am

Post by Elements »

Thank you very much for your efforts willyw
both are working as it should.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

You're welcome. :D
Post Reply