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.

help me on join chan auto whois code pls

Help for those learning Tcl or writing their own scripts.
Post Reply
k
kn1ghtt
Voice
Posts: 10
Joined: Mon Aug 01, 2022 12:54 am

help me on join chan auto whois code pls

Post by kn1ghtt »

hello all

help me on join chan auto whois code pls code ..

Code: Select all

##############################################################################################
##  ##     whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help        ##  ##
##############################################################################################
## To use this script you must set channel flag +whois (ie .chanset #chan +whois)           ##
##############################################################################################
##      ____                __                 ###########################################  ##
##     / __/___ _ ___ _ ___/ /____ ___   ___   ###########################################  ##
##    / _/ / _ `// _ `// _  // __// _ \ / _ \  ###########################################  ##
##   /___/ \_, / \_, / \_,_//_/   \___// .__/  ###########################################  ##
##        /___/ /___/                 /_/      ###########################################  ##
##                                             ###########################################  ##
##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
namespace eval whois {
## change cmdchar to the trigger you want to use                                        ##  ##
  variable cmdchar "!"
## change command to the word trigger you would like to use.                            ##  ##
## Keep in mind, This will also change the .chanset +/-command                          ##  ##
  variable command "whois"
## change textf to the colors you want for the text.                                    ##  ##
  variable textf "\017\00302"
## change tagf to the colors you want for tags:                                         ##  ##
  variable tagf "\017\002"
## Change logo to the logo you want at the start of the line.                           ##  ##
  variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
## Change lineout to the results you want. Valid results are channel users modes topic  ##  ##
  variable lineout "channel users modes topic"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################
  variable channel ""
  setudef flag $whois::command
  bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::lst
  bind raw -|- "311" whois::311
  bind raw -|- "312" whois::312
  bind raw -|- "319" whois::319
  bind raw -|- "317" whois::317
  bind raw -|- "313" whois::multi
  bind raw -|- "310" whois::multi
  bind raw -|- "335" whois::multi
  bind raw -|- "301" whois::301
  bind raw -|- "671" whois::multi
  bind raw -|- "320" whois::multi
  bind raw -|- "401" whois::multi
  bind raw -|- "318" whois::318
  bind raw -|- "307" whois::307
}
proc whois::311 {from key text} {
  if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
    putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Nick e IP virtual:${whois::textf} \
        $nick \(${ident}@${host}\)"
   putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Nombre:${whois::textf} $realname"
  }
}
proc whois::multi {from key text} {
  if {[regexp {\:(.*)$} $text match $key]} {
  set keys [subst $$key]
  set keys [lrange $keys 4 8]
  if {"$keys" == "Nick no presente en IRC"} { set keys [encoding convertfrom utf-8 "El nick que buscas, no está conectado al IRC."];
      putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Info:${whois::textf} $keys";
         return 1    
   }   
  }
}
proc whois::312 {from key text} {
  regexp {([^\s]+)\s\:} $text match server
  putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Servidor:${whois::textf} $server"
}
proc whois::319 {from key text} {
  if {[regexp {.+\:(.+)$} $text match channels]} {
    putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Canales:${whois::textf} $channels"
  }
}
proc whois::317 {from key text} {
  if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
  set signonsp [duration [expr [unixtime] - $::uptime]]
  set signonsp [string map [list "year" "años" "years" "años" "month" "mes" "months" "meses" "week" "semana" "weeks" "semanas" "day" "día" "days" "días" "hour" "hora" "hours" "horas" "minute" "minuto" "minutes" "minutos" "second" "segundo" "seconds" "segundos"] $signonsp]
  set idlesp [duration $idle]
  set idlesp [string map [list "year" "años" "years" "años" "month" "mes" "months" "meses" "week" "semana" "weeks" "semanas" "day" "día" "days" "días" "hour" "hora" "hours" "horas" "minute" "minuto" "minutes" "minutos" "second" "segundo" "seconds" "segundos"] $idlesp]
    putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Conectado :${whois::textf} \
        $signonsp ${whois::tagf}Inactivo:${whois::textf} $idlesp"
  }
}
proc whois::301 {from key text} {
  if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
    putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
  }
}
proc whois::318 {from key text} {
  namespace eval whois {
        variable channel ""
  }
  variable whois::channel ""
}
proc whois::307 {from key text} {
  putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Estado:${whois::textf} Nick Registrado"
}
proc whois::lst {nick host hand chan text} {
  if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
    namespace eval whois {
          variable channel ""
        }
    variable whois::channel $chan
##In the chathispano network the correct command is '/whois nick nick', if you put only '/whois nick' the network hidden  'uptime' and 'idle'  information of nick.##
    putserv "WHOIS $text $text"
  }
}
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

What is the trouble ? You just want to make the script run automatically on join ?
Add a bind join.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

That's gonna be extremely spammy tho and possibly have your bot disconnect due to excess flood (excessive command use )
k
kn1ghtt
Voice
Posts: 10
Joined: Mon Aug 01, 2022 12:54 am

Post by kn1ghtt »

example :

Code: Select all

set whois_debugchan "#canal_ops"
set whois_mainchan "#canal"

bind join -|- * whois_cmd
bind raw -|- "319" whois_channels

proc whois_cmd {n u h c} {
	global whois_mainchan
	if {[string tolower $c] == [string tolower $whois_mainchan]} {
		putserv "WHOIS $n"
	}
}

proc whois_channels {f k t} {
	global whois_debugchan whois_mainchan botnick
	set whois_nick [lindex [split $t " "] 1]
	set whois_chan [string range [lindex [lrange [split $t " "] 2 end-1]] 1 end]
	if {$whois_nick != $botnick } {
		putserv "PRIVMSG $whois_debugchan :Canales de \002$whois_nick\002 -> $whois_chan"
	}
}

putlog "Script autowhois cargado"


bot: (Join) nick ident@vhost ingresa a #chan
bot: Modos: CHaN aplica +v nick en #chan
bot: (Realname) realnamenick
bot: (channels) #chan1 #chan2 chan3
bot: (IP) vhost.aqui de nick
bot: (Nodo) server.connect
bot: (ID) nick ident Chat
bot: (Conectado) 8secs (Inactividad) 5secs de nick
bot: (Quit) nick Deja el canal #chan


please help me and code
k
kn1ghtt
Voice
Posts: 10
Joined: Mon Aug 01, 2022 12:54 am

Post by kn1ghtt »

CrazyCat wrote:What is the trouble ? You just want to make the script run automatically on join ?
Add a bind join.
yes automatically on join whois

channel1 "#channel"
channelreport "#channelbotinfowhois"

example bot report #channelbotinfowhois join user #channel

bot: (Join) nick ident@vhost ingresa a #chan
bot: Modos: CHaN aplica +v nick en #chan
bot: (Realname) realnamenick
bot: (channels) #chan1 #chan2 chan3
bot: (IP) vhost.aqui de nick
bot: (Nodo) server.connect
bot: (ID) nick ident Chat
bot: (Conectado) 8secs (Inactividad) 5secs de nick
bot: (Quit) nick Deja el canal #chan
User avatar
abah
Halfop
Posts: 74
Joined: Sun Dec 01, 2013 3:04 am
Location: Indonesia

meby this help you

Post by abah »

kn1ghtt wrote: Mon Aug 01, 2022 1:01 pm
CrazyCat wrote:What is the trouble ? You just want to make the script run automatically on join ?
Add a bind join.
yes automatically on join whois

channel1 "#channel"
channelreport "#channelbotinfowhois"

example bot report #channelbotinfowhois join user #channel

bot: (Join) nick ident@vhost ingresa a #chan
bot: Modos: CHaN aplica +v nick en #chan
bot: (Realname) realnamenick
bot: (channels) #chan1 #chan2 chan3
bot: (IP) vhost.aqui de nick
bot: (Nodo) server.connect
bot: (ID) nick ident Chat
bot: (Conectado) 8secs (Inactividad) 5secs de nick
bot: (Quit) nick Deja el canal #chan

Code: Select all

#############################################################################
## CheckNick.tcl 1.1  (17/01/2022)  			                           ##
##                                                                         ##
##                              Copyright 2008 - 2022 @ WwW.TCLScripts.NET ##
##         _   _   _   _   _   _   _   _   _   _   _   _   _   _           ##
##        / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \          ##
##       ( T | C | L | S | C | R | I | P | T | S | . | N | E | T )         ##
##        \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/          ##
##                                                                         ##
##                       ® BLaCkShaDoW Production ®                        ##
##                                                                         ##
##                                PRESENTS                                 ##
##									                                     ® ##
###########################   CHECK NICK TCL   ##############################
##	DESCRIPTION: 														   ##
## This script offers the posibility foreach user to save a list of nicks  ##
## that the eggdrop will check if there are OFFLine or ONLine and message  ##
## the user if the status foreach nick changed.							   ##
##																		   ##
#############################################################################
##																		   ##
##  COMMANDS:  															   ##
##																		   ##
## !cnick add <nickname> - to add a nickname							   ##
## !cnick list - to list nicks											   ##
## !cnick del <nickname> - to remove a nickname							   ##
## !cnick help															   ##
##																		   ##
#############################################################################
##								                                           ##
##  PERSONAL AND NON-COMMERCIAL USE LIMITATION.                            ##
##                                                                         ##
##  This program is provided on an "as is" and "as available" basis,       ##
##  with ABSOLUTELY NO WARRANTY. Use it at your own risk.                  ##
##                                                                         ##
##  Use this code for personal and NON-COMMERCIAL purposes ONLY.           ##
##                                                                         ##
##  Unless otherwise specified, YOU SHALL NOT copy, reproduce, sublicense, ##
##  distribute, disclose, create derivatives, in any way ANY PART OF       ##
##  THIS CONTENT, nor sell or offer it for sale.                           ##
##                                                                         ##
##  You will NOT take and/or use any screenshots of this source code for   ##
##  any purpose without the express written consent or knowledge of author.##
##                                                                         ##
##  You may NOT alter or remove any trademark, copyright or other notice   ##
##  from this source code.                                                 ##
##                                                                         ##
##              Copyright 2008 - 2022 @ WwW.TCLScripts.NET                 ##
##                                                                         ##
#############################################################################
#############################################################################
##                              CONFIGURATIONS                             ##
#############################################################################

##
#Set here what flags can add nicks for check (owner mn|- for all -|-)
set cnick(flags) "-|-"

##
#Set here the time for checking (minutes)
set cnick(check_time) "1"

##
#Filename
set cnick_file "cnick_nicks"

##############################################################################
###        DO NOT MODIFY HERE UNLESS YOU KNOW WHAT YOU'RE DOING            ###
##############################################################################

if {![file exists $cnick_file]} {
	set file [open $cnick_file w]
	close $file
}

if {![info exists cnick(timer_start)]} {
	timer $cnick(check_time) cnick:timer
	set cnick(timer_start) 1
}

bind pub $cnick(flags) !cnick proc:cnick

###
proc proc:cnick {nick host hand chan arg} {
	global cnick cnick_file
	set who [lindex [split $arg] 0]
if {$who == ""} {
	putserv "PRIVMSG $chan :Use !cnick help for more help"
	return
}

switch $who {
	add {
	set nick_2add [lindex [split $arg] 1]
if {$nick_2add == ""} {
	putserv "PRIVMSG $chan :Use !cnick add <nickname>"
	return
		}
	set exists [cnick:exists $hand $nick_2add]
if {$exists == "1"} {
	putserv "PRIVMSG $chan :\002$nick_2add\002 sudah berada dalam databases."
	return
		}
	set file [open $cnick_file a]
	puts $file "$hand $nick_2add"
	close $file
	putserv "PRIVMSG $chan :\002$nick_2add\002 berhasil ditambahkan...!!!"
	}
	
	list {
	set list [cnick:list $hand]
if {$list == 0} {
	putserv "PRIVMSG $chan :There is nothing in your list."
	return
		}
	
foreach n [cnick:wordwrap $list 400] {
	putserv "PRIVMSG $chan :Nicks :$n"	
		}
	}
	del {
	set nick_2del [lindex [split $arg] 1]
if {$nick_2del == ""} {
	putserv "PRIVMSG $chan :Use !cnick del <nickname>"
	return
		}
	set exists [cnick:exists $hand $nick_2del]
if {$exists == "0"} {
	putserv "PRIVMSG $chan :\002$nick_2del\002 tidak ada dalam database."
	return
		}
	cnick:remove $hand $nick_2del
if {[info exists cnick(status:$nick_2del)]} {
	unset cnick(status:$nick_2del)
}
	putserv "PRIVMSG $chan :\002$nick_2del\002 berhasil dihapus...!!!"
	}
	
	help {
	putserv "PRIVMSG $chan :Use !cnick add <nickname> - to add ; !cnick list - to list ; !cnick del <nickname> - to remove"
	}
	
	default  {
	putserv "PRIVMSG $chan :Use !cnick help for more help"
		}
	}
}

###
proc cnick:wordwrap {str {len 100} {splitChr { }}} { 
   set out [set cur {}]; set i 0 
   foreach word [split [set str][unset str] $splitChr] { 
     if {[incr i [string len $word]]>$len} { 
         lappend out [join $cur $splitChr] 
         set cur [list $word] 
         set i [string len $word] 
      } { 
         lappend cur $word 
      } 
      incr i 
   } 
   lappend out [join $cur $splitChr] 
}


###
proc cnick:list {hand} {
	global cnick cnick_file
	set file [open $cnick_file r]
	set read [read -nonewline $file]
	close $file
foreach line [split $read "\n"] {
	set read_hand [lindex [split $line] 0]
	set read_nick [lindex [split $line] 1]
if {[string equal -nocase $read_hand $hand]} {
	lappend nicks $read_nick
	}
}
if {![info exists nicks]} {
	return 0
	}
	return [join $nicks ", "]
}


###
proc cnick:remove {hand nick} {
	global cnick cnick_file
	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
	set temp "$cnick_file.new.$timestamp"
	set tempwrite [open $temp w]
	set file [open $cnick_file r]
	set read [read -nonewline $file]
	close $file
foreach line [split $read "\n"] {
	set read_hand [lindex [split $line] 0]
	set read_nick [lindex [split $line] 1]
if {[string equal -nocase $read_hand $hand] && [string equal -nocase $nick $read_nick]} {
	continue
} else {
	puts $tempwrite $line
	}
}
	close $tempwrite
	file rename -force $temp $cnick_file	
}

###
proc cnick:exists {hand nick} {
	global cnick cnick_file
	set found 0
	set file [open $cnick_file r]
	set read [read -nonewline $file]
	close $file	
if {$read == ""} { return 0 }
foreach line [split $read "\n"] {
	set read_hand [lindex [split $line] 0]
	set read_nick [lindex [split $line] 1]
if {[string equal -nocase $read_hand $hand] && [string equal -nocase $nick $read_nick]} {
	set found 1
	break
		}
	}
	return $found
}

###
proc cnick:timer {} {
	global cnick cnick_file
	set verify_list ""
	set file [open $cnick_file r]
	set read [read -nonewline $file]
	close $file
if {$read == ""} {
	timer $cnick(check_time) cnick:timer
	return
}
	array set thelist [list]
foreach line [split $read "\n"] {
	set hand [lindex [split $line] 0]
	set nick [lindex [split $line] 1]
	lappend thelist($hand) $nick
}
if {[array size thelist] == "0"} {
	timer $cnick(check_time) cnick:timer
	return	
}
foreach h [array names thelist] {
	lappend verify_list [list $h $thelist($h)]
}
	cnick:verify $verify_list 0
}

proc cnick:verify {verify_list num} {
	global cnick
	set entry [lindex $verify_list $num]
	set handle [lindex $entry 0]
	set nicks [lindex $entry 1]
	set hand [hand2nick $handle]
if {$hand != ""} {
	cnick:verify:nicks $hand $verify_list $num $nicks 0
	} else {
	set inc [expr $num + 1]
if {[lindex $verify_list $inc] != ""} {
	cnick:verify $verify_list $inc
		} else {
	timer $cnick(check_time) cnick:timer	
		}
	}
}

###
proc cnick:verify:nicks {handle verify_list num_line nicks num_nicks} {
	global cnick
	set first_nick [lindex $nicks $num_nicks]
	putserv "USERHOST :$first_nick"
	set ::cnick_handle $handle
	set ::cnick_verify_list $verify_list
	set ::cnick_num_line $num_line
	set ::cnick_nicks $nicks
	set ::cnick_num_nicks $num_nicks
	set ::cnick_nick $first_nick
	set ::cnick_hand $handle
	bind RAW - 302 cnick:check
}

###
# Credits
set infodomain(projectName) "CheckNick"
set infodomain(author) "BLaCkShaDoW"
set infodomain(website) "wWw.TCLScriptS.NeT"
set infodomain(email) "blackshadow\[at\]tclscripts.net"
set infodomain(version) "v1.1"

###
proc cnick:check {from keyword arguments} {
	global cnick
	set hosts [lindex [split $arguments] 1]
	set nick $::cnick_nick
	set hand $::cnick_hand
	set hostname [lindex [split $hosts "="] 1]
	regsub {^[-+]} $hostname "" hostname
if {$hosts == ":"} {
if {![info exists cnick(status:$nick)]} {
	set cnick(status:$nick) "0:[unixtime]"
	putserv "PRIVMSG #roomput :$nick $hostname 4OFFLine."
	} else {
	set split_it [split $cnick(status:$nick) ":"]
if {[lindex $split_it 0] == "1"} {
	set cnick(status:$nick) "0:[unixtime]"
	putserv "PRIVMSG #roomput :$nick $hostname 4OFFLine (ONLine [ctime [lindex $split_it 1]])."
			}
		}
	} else { 
if {![info exists cnick(status:$nick)]} {
	set cnick(status:$nick) "1:[unixtime]"
	putserv "PRIVMSG #roomput :$nick $hostname 3ONLine."
	} else {
	set split_it [split $cnick(status:$nick) ":"]
if {[lindex $split_it 0] == "0"} {
	set cnick(status:$nick) "1:[unixtime]"
	putserv "PRIVMSG #roomput :$nick $hostname 3ONLine (4OFFLine [ctime [lindex $split_it 1]])."
		}
	}
}
	set nick_num [expr $::cnick_num_nicks + 1]
if {[lindex $::cnick_nicks $nick_num] != ""} {
	utimer 5 [list cnick:verify:nicks $::cnick_handle $::cnick_verify_list $::cnick_num_line $::cnick_nicks $nick_num]
} else {
	set line_num [expr $::cnick_num_line + 1]
if {[lindex $::cnick_verify_list $line_num] != ""} {
	cnick:verify $::cnick_verify_list $line_num
	unbind RAW - 302 cnick:check
	unset ::cnick_handle
	unset ::cnick_verify_list
	unset ::cnick_num_line
	unset ::cnick_nicks
	unset ::cnick_num_nicks
	} else {
	timer $cnick(check_time) cnick:timer
	unbind RAW - 302 cnick:check
	unset ::cnick_handle
	unset ::cnick_verify_list
	unset ::cnick_num_line
	unset ::cnick_nicks
	unset ::cnick_num_nicks	
		}
	}
}

putlog "\002$infodomain(projectName) $infodomain(version)\002 coded by\002 $infodomain(author)\002 ($infodomain(website)): Loaded & initialised.."
abah - Kota Makassar - Indonesia
Post Reply