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.

!info Simple TCL

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Aditya
Voice
Posts: 8
Joined: Mon May 08, 2006 3:19 am
Location: New York
Contact:

!info Simple TCL

Post by Aditya »

Hi People!

I would like to know if there is a script which has the below feature existing .. if not, can anyone make it up please :)

1) On !info in a channel the bot should respond to the performed chatter with a list of information about the channel

2) The information should be listed as 1) .. 2).. and 3)....

3) The Information should be ONLY through /notice and not /privmsg..


Thanks / Rgds

Aditya @ DALnet
#TownHall, #HomeTown
A
Access
Voice
Posts: 22
Joined: Sun Jun 04, 2006 6:31 am

Post by Access »

which kind of information about the channel?!
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

there are a lot of "trigger scripts" around here, either reading from a file or using integrated strings. In case the desired script uses PRIVMSG instead of NOTICE... I suggest to simply replace PRIVMSG with NOTICE, the syntax of these IRC commands is the same 'COMMAND TARGET[,MORETAGETS,..] :TEXT' :).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
M
Minus
Voice
Posts: 8
Joined: Sat Jul 01, 2006 4:42 pm

Post by Minus »

This is a modified command script see if you like it.

cmds are !info add,del,help

Code: Select all

##
#
# commands.tcl v1.2 - by strikelight ([sL] @ EFNet) (09/21/03)
#
# For eggdrop1.1.5-eggdrop1.6.x
#
# Contact:
# - E-Mail: strikelight@tclscript.com
# - WWW   : http://www.TCLScript.com
# - IRC   : #Scripting @ EFNet
#
##
#
# Description:
#
# This script will allow channel administrators to maintain a list of
# available triggers for the channel, and allow users to view the list
# of available triggers.
#
##
#
# History:
#
# (09/21/03)/v1.2 - Cosmetic fixes
#
# (10/20/02)/v1.1 - Fixed bug with error on startup: 
#                   "can't read 'eggversion': no such variable"
#                   (Why didn't anyone else report this a long time ago?)
#                 - Added option to change the trigger command
#
# (5/27/02)/v1.0  - Initial Release
#
##
#
# Usage:
#
# Edit the configuration below, and
# type "!commands help" in a channel
#
# (Modify '!commands help' with the trigger you choose below in the config)
#
##

## CONFIGURATION ##

# Trigger to use?
set commands_trigger "!info"

# Flag required to add/remove triggers
set commands_adminflag "m"

## END OF CONFIG ##

set commands_version "1.2"
set eggversion [string trimleft [lindex $version 1] 0]

bind pub - $commands_trigger commands:pub

proc handisop {hand chan} {
  return [expr {[validchan $chan] && [isop [hand2nick $hand $chan] $chan]}]
}

if {($eggversion >= 1030000)} {
  proc matchchanattr {handle flags channel} { return [matchattr $handle |$flags $channel] }
}

proc isoporvoice {nick chan} {
  return [expr {[validchan $chan] && ([isop $nick $chan] || [isvoice $nick $chan])}]
}

proc handisoporvoice {hand chan} {
  return [expr {[validchan $chan] && [isoporvoice [hand2nick $hand $chan] $chan]}]
}

proc mymatchattr {hand flags {chan ""}} {
  if {[regsub -all {[^&|().a-zA-Z0-9@+#-]} $flags {} f]} {
    putloglev o * "error: (matchattr): illegal character in flags: $flags"
    return 0
  }
  regsub -all -- {[|&]} $f {&&} f
  regsub -all -- {#-} $f {-#} f
  regsub -all -- {-} $f {!} f
  regsub -all -- {#?[a-zA-Z0-9]} $f {(&)} f
  regsub -all -- {\(#([a-zA-Z0-9])\)} $f {[matchchanattr $hand \1 $chan]} f
  regsub -all -- {\(([a-zA-Z0-9])\)} $f {[matchattr $hand \1]} f
  regsub -all -- {\.} $f {1} f
  regsub -all -- {@} $f {[handisop $hand $chan]} f
  regsub -all -- {\+} $f {[handisoporvoice $hand $chan]} f
  return [expr $f]
}

proc commands:load {} {
  global commands
  catch {unset commands}
  if {![file exists "commands.dat"]} {
    set outfile [open "commands.dat" w]
    close $outfile
  }
  set infile [open "commands.dat" r]
  set buffer [read $infile]
  close $infile
  set buffer [split $buffer "\n"]
  foreach line $buffer {
    if {$line != ""} {
      set dline [split $line "|"]
      set dchan [string tolower [lindex $dline 0]]
      set dcmd [lindex $dline 1]
      set ddesc [lindex $dline 2]
      set commands($dchan,$dcmd) $ddesc
    }
  }
  return 1
}

proc commands:save {} {
  global commands
  set outfile [open "commands.dat" w]
  foreach item [array names commands *,*] {
    set dchan [lindex [split $item ","] 0]
    set dcmd [lindex [split $item ","] 1]
    set ddesc $commands($item)
    if {($dchan != "") && ($dcmd != "") && ($ddesc != "")} {
      puts $outfile "$dchan|$dcmd|$ddesc"
    }
  }
  close $outfile
  return 1
}

proc commands:longestcmd {chan} {
  global commands
  set i 0
  foreach item [array names commands [string tolower $chan],*] {
    set ditem [join [lindex [split $item ","] 1]]
    if {[string length $ditem] > $i} { set i [string length $ditem] }
  }
  return $i
}

proc commands:iscommand {command chan} {
  global commands
  return [info exists commands([string tolower $chan],$command)]
}

proc commands:add {command desc chan} {
  global commands
  if {[commands:iscommand $command $chan]} { return 0 }
  set commands([string tolower $chan],$command) "$desc"
  return 1
}

proc commands:del {command chan} {
  global commands
  if {![commands:iscommand $command $chan]} { return 0 }
  catch {unset commands([string tolower $chan],$command)}
  return 1
}

proc commands:pub {nick uhost hand chan rest} {
  global commands commands_adminflag commands_trigger
  set cmd [string tolower [lindex [split $rest] 0]]
  set chan [string tolower $chan]
  switch $cmd {
    help {
      set tt $commands_adminflag
      puthelp "NOTICE $nick :+- \002info.tcl\002 help"
      puthelp "NOTICE $nick :: [format %-39s "$commands_trigger"] - list of commands available in channel"
      if {[mymatchattr $hand $tt|#$tt $chan]} {
        puthelp "NOTICE $nick :: [format %-39s "$commands_trigger add {<info>} <tekst>"] - add a command to channel"
        puthelp "NOTICE $nick :: [format %-39s "$commands_trigger del {<info>}"] - remove a command for channel"
      }
      puthelp "NOTICE $nick :+- end of help."
      return
    }
    add {
      set tt $commands_adminflag
      if {![mymatchattr $hand $tt|#$tt $chan]} { return }
      set command [lindex $rest 1]
      set desc [join [lrange $rest 2 end]]
      if {($command == "") || ($desc == "")} {
        puthelp "NOTICE $nick :Usage: $commands_trigger add {<info>} <tekst>"
        puthelp "NOTICE $nick :Eg.  : $commands_trigger add {/ctcp lamer test} does something"
        return
      }
      set res [commands:add $command "$desc" $chan]
      if {!$res} {
        puthelp "NOTICE $nick :\002$command\002 is already marked as a info for $chan."
        return
      } else {
        puthelp "NOTICE $nick :Added \002$command\002 as a info for $chan."
        commands:save
        return
      }
    }
    del {
      set tt $commands_adminflag
      if {![mymatchattr $hand $tt|#$tt $chan]} { return }
      set command [lindex $rest 1]
      if {$command == ""} {
        puthelp "NOTICE $nick :Usage: $commands_trigger del <command>"
        return
      }
      set res [commands:del $command $chan]
      if {!$res} {
        puthelp "NOTICE $nick :\002$command\002 is not a command for $chan."
        return
      } else {
        puthelp "NOTICE $nick :Deleted \002$command\002 as a info for $chan."
        commands:save
        return
      }
    }
    default {
      set lngth [commands:longestcmd $chan]
      if {!$lngth} { return }
      if {$lngth < 8} { set lngth 8 }
      puthelp "NOTICE $nick :+- information for \002$chan\002:"
      puthelp "NOTICE $nick :: \037[format %-${lngth}s "info\037"]  - \037tekst\037"
      foreach item [lsort [array names commands $chan,*]] {
        puthelp "NOTICE $nick :: \002[format %-${lngth}s "[lindex [split $item ","] 1]"]\002 - $commands($item)"
      }
      puthelp "NOTICE $nick :+- end of info."
      return
    }
  }
}

commands:load
putlog "info.tcl v$commands_version by strikelight now loaded."
Post Reply