| View previous topic :: View next topic |
| Author |
Message |
Elements Voice
Joined: 19 Mar 2009 Posts: 12
|
Posted: Thu Aug 12, 2010 12:28 am Post subject: Spychan.tcl on/off switch |
|
|
Spychan
http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&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: |
# 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!"
|
|
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Aug 12, 2010 1:17 pm Post subject: Re: Spychan.tcl on/off switch |
|
|
| Elements wrote: |
...
or anything to make it start/stop relaying on the fly.
|
One way :
| Code: |
# 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. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Aug 12, 2010 3:58 pm Post subject: |
|
|
Another way:
| Code: |
# 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. |
|
| Back to top |
|
 |
Elements Voice
Joined: 19 Mar 2009 Posts: 12
|
Posted: Fri Aug 13, 2010 1:15 am Post subject: |
|
|
Thank you very much for your efforts willyw
both are working as it should. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Fri Aug 13, 2010 9:40 am Post subject: |
|
|
You're welcome.  |
|
| Back to top |
|
 |
|