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.

Radio script help

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
T
TheViP
Voice
Posts: 2
Joined: Thu May 17, 2007 9:36 am

Radio script help

Post by TheViP »

Hello.
I found a script, who write in chanel the audition from our Internet Radio. I add all auditions with prv command to bot

Code: Select all

+dodaj HH:MM Text
eg : +dodaj 21:00 Music
But all have an acces to this command. I want to change the script that, only some persons have acces to +dodaj command. The best veryficantion will be by the hostnames.

Code: Select all

# Author: Tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.4
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# manual
# /msg <nazwa_bota> +dodaj 21:30 cos tam - dodaje ramowke, czas musi byc w formacie HH:MM,
# /msg <nazwa_bota> +czysc - pokaze liste z ramowkami i ich numerami
# /msg <nazwa_bota> +czysc <numer> - usunie ramowke o podanym numerze
# /msg <nazwa_bota> +czysc all - usunie wszystkie
# /msg <nazwa_bota> +czas - pokaze aktualny interwal (domyslnie co 15 minut)
# /msg <nazwa_bota> +czas <interwal> - zmieni obecny interwal na podany (minuty)

# kanal badz kanaly
set rm_channels {#kanal1 #kanal2}

#########################################
bind msgm - "*" privates_fct
bind time - "00 00 * * *" reset_ramowki

set ramowki_dir "ramowki"
set ramowki_db "$ramowki_dir/ramowki.db"
set ramowki_time "$ramowki_dir/time.db"

if {![file exists $ramowki_dir]} {
   file mkdir $ramowki_dir
}

if {![file exists $ramowki_time]} {
        set touch_time [open $ramowki_time w]
   puts $touch_time 15
   close $touch_time
}

if {![file exists $ramowki_db]} {
        set touch_db [open $ramowki_db w]
        close $touch_db
}
      
proc grab_time {} {
   global ramowki_time
   set tfs_open [open $ramowki_time r]
   gets $tfs_open time_out
   close $tfs_open
   return $time_out
}

proc set_rtime { rntime } {
   global ramowki_time
   set tfs_write [open $ramowki_time w]
   puts $tfs_write $rntime
   close $tfs_write
}

proc odliczadlo { } {
   show_ramowki
   if {[string match *odliczadlo* [timers]] != 1} {
      timer [grab_time] odliczadlo
   }
}

proc reset_db { } {
   global ramowki_db

   set clear_db [open $ramowki_db w]
   close $clear_db
}

proc get_db_data { } {
   global ramowki_db

   set open_db [open $ramowki_db]
        set all_db_data [read $open_db]
        close $open_db

   set all_db_lines [split $all_db_data "\n"]

   return $all_db_lines
}

proc add_ramowke { body } {
   global ramowki_db

   set file_hndl [open $ramowki_db a]
   puts $file_hndl "$body"
   close $file_hndl
}

proc del_ramowke { nrr } {
   global ramowki_db
   
   set uchwyt [open $ramowki_db]
        set all_ramowki [read $uchwyt]
        close $uchwyt

        set all_ramowki_lines [split $all_ramowki "\n"]
        set counter [llength $all_ramowki_lines]

   set handler [open $ramowki_db w]
        for {set i 0} {$i < $counter} {incr i 1} {
      if {$i == $nrr} {
         continue
      } {
         set each_ramowka_line [lindex $all_ramowki_lines $i]
         if {$each_ramowka_line != ""} {
            puts $handler $each_ramowka_line
         }
      }
   }
   close $handler
}

proc list_ramowki { niick } {
   set x 0
   foreach ramowka [get_db_data] {
      if {$ramowka != "" } {
         putquick "PRIVMSG $niick :$x\) $ramowka"
         incr x 1
      }
   }
}

proc privates_fct { nick uhost hand arg } {
   set all_args [split $arg]
   set first_arg [lindex $all_args 0]
   set second_arg [lindex $all_args 1]
   set other_arg [lrange $all_args 2 end]

   if {$first_arg == "+dodaj"} {
      if {$other_arg != "" } {
         add_ramowke "$second_arg $other_arg"
         putquick "PRIVMSG $nick :dodano"
      }
   }

   if {$first_arg == "+czysc"} {
      if {$second_arg == ""} {
         list_ramowki $nick
      } elseif {[regexp {^([0-9]+)$} $second_arg]} {
         del_ramowke $second_arg
         putquick "PRIVMSG $nick :usunieto"
      } elseif {$second_arg == "all"} {
         reset_db
         putquick "PRIVMSG $nick :usunieto wszystkie ramowki"
      }
   }

   if {$first_arg == "+czas"} {
      if {$second_arg == ""} {
         putquick "PRIVMSG $nick :aktualny interwal to [grab_time] minut|a|y"
      } elseif {[regexp {^([0-9]+)$} $second_arg]} {
         set_rtime $second_arg
         putquick "PRIVMSG $nick :zmieniono"
      }
   }
}

proc show_ramowki { } {
   global rm_channels
   
   foreach db_line [lsort [get_db_data]] {
      if {$db_line != ""} {
         set splited [split $db_line]
         set first_sp [lindex $splited 0]
         set other_sp [lrange $splited 1 end]

         foreach rchan $rm_channels {
            if {$rchan != ""} {
               if {[botonchan $rchan] == 1} {
                  putquick "PRIVMSG $rchan :\002$first_sp\002 $other_sp"
               }
            }
         }
      }
   }
}

proc reset_ramowki { min hour day month year } {
   reset_db
}

if {[string match *odliczadlo* [timers]] != 1} {
   timer [grab_time] odliczadlo
}

putlog "ramowki.tcl ver 0.4 by Tomekk loaded"
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Code: Select all

# Author: Tomekk 
# e-mail:  tomekk/@/oswiecim/./eu/./org 
# home page: http://tomekk.oswiecim.eu.org/ 
# 
# Version 0.4 
# 
# This file is Copyrighted under the GNU Public License. 
# http://www.gnu.org/copyleft/gpl.html 

# manual 
# /msg <nazwa_bota> +dodaj 21:30 cos tam - dodaje ramowke, czas musi byc w formacie HH:MM, 
# /msg <nazwa_bota> +czysc - pokaze liste z ramowkami i ich numerami 
# /msg <nazwa_bota> +czysc <numer> - usunie ramowke o podanym numerze 
# /msg <nazwa_bota> +czysc all - usunie wszystkie 
# /msg <nazwa_bota> +czas - pokaze aktualny interwal (domyslnie co 15 minut) 
# /msg <nazwa_bota> +czas <interwal> - zmieni obecny interwal na podany (minuty) 

# kanal badz kanaly 
set rm_channels {#kanal1 #kanal2} 

set allowuser {
"*!*@I.love.eggdrop,.org"
"*!*@127.0.0.*"
}
######################################### 
bind msgm - "*" privates_fct 
bind time - "00 00 * * *" reset_ramowki 

set ramowki_dir "ramowki" 
set ramowki_db "$ramowki_dir/ramowki.db" 
set ramowki_time "$ramowki_dir/time.db" 

if {![file exists $ramowki_dir]} { 
   file mkdir $ramowki_dir 
} 

if {![file exists $ramowki_time]} { 
        set touch_time [open $ramowki_time w] 
   puts $touch_time 15 
   close $touch_time 
} 

if {![file exists $ramowki_db]} { 
        set touch_db [open $ramowki_db w] 
        close $touch_db 
} 
      
proc grab_time {} { 
   global ramowki_time 
   set tfs_open [open $ramowki_time r] 
   gets $tfs_open time_out 
   close $tfs_open 
   return $time_out 
} 

proc set_rtime { rntime } { 
   global ramowki_time 
   set tfs_write [open $ramowki_time w] 
   puts $tfs_write $rntime 
   close $tfs_write 
} 

proc odliczadlo { } { 
   show_ramowki 
   if {[string match *odliczadlo* [timers]] != 1} { 
      timer [grab_time] odliczadlo 
   } 
} 

proc reset_db { } { 
   global ramowki_db 

   set clear_db [open $ramowki_db w] 
   close $clear_db 
} 

proc get_db_data { } { 
   global ramowki_db 

   set open_db [open $ramowki_db] 
        set all_db_data [read $open_db] 
        close $open_db 

   set all_db_lines [split $all_db_data "\n"] 

   return $all_db_lines 
} 

proc add_ramowke { body } { 
   global ramowki_db 

   set file_hndl [open $ramowki_db a] 
   puts $file_hndl "$body" 
   close $file_hndl 
} 

proc del_ramowke { nrr } { 
   global ramowki_db 
    
   set uchwyt [open $ramowki_db] 
        set all_ramowki [read $uchwyt] 
        close $uchwyt 

        set all_ramowki_lines [split $all_ramowki "\n"] 
        set counter [llength $all_ramowki_lines] 

   set handler [open $ramowki_db w] 
        for {set i 0} {$i < $counter} {incr i 1} { 
      if {$i == $nrr} { 
         continue 
      } { 
         set each_ramowka_line [lindex $all_ramowki_lines $i] 
         if {$each_ramowka_line != ""} { 
            puts $handler $each_ramowka_line 
         } 
      } 
   } 
   close $handler 
} 

proc list_ramowki { niick } { 
   set x 0 
   foreach ramowka [get_db_data] { 
      if {$ramowka != "" } { 
         putquick "PRIVMSG $niick :$x\) $ramowka" 
         incr x 1 
      } 
   } 
} 

proc privates_fct { nick uhost hand arg } { 
   global allowuser
   set all_args [split $arg] 
   set first_arg [lindex $all_args 0] 
   set second_arg [lindex $all_args 1] 
   set other_arg [lrange $all_args 2 end] 

   if {$first_arg == "+dodaj"} { 
      if {$other_arg != "" } { 
    foreach allowuser [string tolower $allowuser] {
    if {[string match *$allowuser* [string tolower $uhost]]} {
         add_ramowke "$second_arg $other_arg" 
         putquick "PRIVMSG $nick :dodano" 
        } 
     } 
  }
}
   if {$first_arg == "+czysc"} { 
      if {$second_arg == ""} { 
         list_ramowki $nick 
      } elseif {[regexp {^([0-9]+)$} $second_arg]} { 
         del_ramowke $second_arg 
         putquick "PRIVMSG $nick :usunieto" 
      } elseif {$second_arg == "all"} { 
         reset_db 
         putquick "PRIVMSG $nick :usunieto wszystkie ramowki" 
      } 
   } 

   if {$first_arg == "+czas"} { 
      if {$second_arg == ""} { 
         putquick "PRIVMSG $nick :aktualny interwal to [grab_time] minut|a|y" 
      } elseif {[regexp {^([0-9]+)$} $second_arg]} { 
         set_rtime $second_arg 
         putquick "PRIVMSG $nick :zmieniono" 
      } 
   } 
} 

proc show_ramowki { } { 
   global rm_channels 
    
   foreach db_line [lsort [get_db_data]] { 
      if {$db_line != ""} { 
         set splited [split $db_line] 
         set first_sp [lindex $splited 0] 
         set other_sp [lrange $splited 1 end] 

         foreach rchan $rm_channels { 
            if {$rchan != ""} { 
               if {[botonchan $rchan] == 1} { 
                  putquick "PRIVMSG $rchan :\002$first_sp\002 $other_sp" 
               } 
            } 
         } 
      } 
   } 
} 

proc reset_ramowki { min hour day month year } { 
   reset_db 
} 

if {[string match *odliczadlo* [timers]] != 1} { 
   timer [grab_time] odliczadlo 
} 

putlog "ramowki.tcl ver 0.4 by Tomekk loaded" 
try this should work, have'nt tested though.
|AmDeAtH @ Undernet
Death is only the *Beginning*...
T
TheViP
Voice
Posts: 2
Joined: Thu May 17, 2007 9:36 am

Post by TheViP »

yes, thx worx propertly but can u do that too for commands : +czysc and +czas

Thanx
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Code: Select all

# Author: Tomekk 
# e-mail:  tomekk/@/oswiecim/./eu/./org 
# home page: http://tomekk.oswiecim.eu.org/ 
# 
# Version 0.4 
# 
# This file is Copyrighted under the GNU Public License. 
# http://www.gnu.org/copyleft/gpl.html 

# manual 
# /msg <nazwa_bota> +dodaj 21:30 cos tam - dodaje ramowke, czas musi byc w formacie HH:MM, 
# /msg <nazwa_bota> +czysc - pokaze liste z ramowkami i ich numerami 
# /msg <nazwa_bota> +czysc <numer> - usunie ramowke o podanym numerze 
# /msg <nazwa_bota> +czysc all - usunie wszystkie 
# /msg <nazwa_bota> +czas - pokaze aktualny interwal (domyslnie co 15 minut) 
# /msg <nazwa_bota> +czas <interwal> - zmieni obecny interwal na podany (minuty) 

# kanal badz kanaly 
set rm_channels {#kanal1 #kanal2} 

set allowuser {
"*!*@I.love.eggdrop,.org"
"*!*@127.0.0.*"
}
######################################### 
bind msgm - "*" privates_fct 
bind time - "00 00 * * *" reset_ramowki 

set ramowki_dir "ramowki" 
set ramowki_db "$ramowki_dir/ramowki.db" 
set ramowki_time "$ramowki_dir/time.db" 

if {![file exists $ramowki_dir]} { 
   file mkdir $ramowki_dir 
} 

if {![file exists $ramowki_time]} { 
        set touch_time [open $ramowki_time w] 
   puts $touch_time 15 
   close $touch_time 
} 

if {![file exists $ramowki_db]} { 
        set touch_db [open $ramowki_db w] 
        close $touch_db 
} 
      
proc grab_time {} { 
   global ramowki_time 
   set tfs_open [open $ramowki_time r] 
   gets $tfs_open time_out 
   close $tfs_open 
   return $time_out 
} 

proc set_rtime { rntime } { 
   global ramowki_time 
   set tfs_write [open $ramowki_time w] 
   puts $tfs_write $rntime 
   close $tfs_write 
} 

proc odliczadlo { } { 
   show_ramowki 
   if {[string match *odliczadlo* [timers]] != 1} { 
      timer [grab_time] odliczadlo 
   } 
} 

proc reset_db { } { 
   global ramowki_db 

   set clear_db [open $ramowki_db w] 
   close $clear_db 
} 

proc get_db_data { } { 
   global ramowki_db 

   set open_db [open $ramowki_db] 
        set all_db_data [read $open_db] 
        close $open_db 

   set all_db_lines [split $all_db_data "\n"] 

   return $all_db_lines 
} 

proc add_ramowke { body } { 
   global ramowki_db 

   set file_hndl [open $ramowki_db a] 
   puts $file_hndl "$body" 
   close $file_hndl 
} 

proc del_ramowke { nrr } { 
   global ramowki_db 
    
   set uchwyt [open $ramowki_db] 
        set all_ramowki [read $uchwyt] 
        close $uchwyt 

        set all_ramowki_lines [split $all_ramowki "\n"] 
        set counter [llength $all_ramowki_lines] 

   set handler [open $ramowki_db w] 
        for {set i 0} {$i < $counter} {incr i 1} { 
      if {$i == $nrr} { 
         continue 
      } { 
         set each_ramowka_line [lindex $all_ramowki_lines $i] 
         if {$each_ramowka_line != ""} { 
            puts $handler $each_ramowka_line 
         } 
      } 
   } 
   close $handler 
} 

proc list_ramowki { niick } { 
   set x 0 
   foreach ramowka [get_db_data] { 
      if {$ramowka != "" } { 
         putquick "PRIVMSG $niick :$x\) $ramowka" 
         incr x 1 
      } 
   } 
} 

proc privates_fct { nick uhost hand arg } { 
   global allowuser
   set all_args [split $arg] 
   set first_arg [lindex $all_args 0] 
   set second_arg [lindex $all_args 1] 
   set other_arg [lrange $all_args 2 end] 

   if {$first_arg == "+dodaj"} { 
      if {$other_arg != "" } { 
    foreach allowuser [string tolower $allowuser] {
    if {[string match *$allowuser* [string tolower $uhost]]} {
         add_ramowke "$second_arg $other_arg" 
         putquick "PRIVMSG $nick :dodano" 
        } 
     } 
  }
}
   if {$first_arg == "+czysc"} { 
      if {$second_arg == ""} { 
      foreach allowuser [string tolower $allowuser] { 
      if {[string match *$allowuser* [string tolower $uhost]]} { 
         list_ramowki $nick 
      } elseif {[regexp {^([0-9]+)$} $second_arg]} { 
         del_ramowke $second_arg 
         putquick "PRIVMSG $nick :usunieto" 
      } elseif {$second_arg == "all"} { 
         reset_db 
         putquick "PRIVMSG $nick :usunieto wszystkie ramowki" 
        } 
     } 
  }
}  
   if {$first_arg == "+czas"} { 
      if {$second_arg == ""} { 
    foreach allowuser [string tolower $allowuser] { 
    if {[string match *$allowuser* [string tolower $uhost]]} { 
       putquick "PRIVMSG $nick :aktualny interwal to [grab_time] minut|a|y" 
      } elseif {[regexp {^([0-9]+)$} $second_arg]} { 
         set_rtime $second_arg 
         putquick "PRIVMSG $nick :zmieniono" 
        } 
      } 
    } 
  }
}
proc show_ramowki { } { 
   global rm_channels 
    
   foreach db_line [lsort [get_db_data]] { 
      if {$db_line != ""} { 
         set splited [split $db_line] 
         set first_sp [lindex $splited 0] 
         set other_sp [lrange $splited 1 end] 

         foreach rchan $rm_channels { 
            if {$rchan != ""} { 
               if {[botonchan $rchan] == 1} { 
                  putquick "PRIVMSG $rchan :\002$first_sp\002 $other_sp" 
               } 
            } 
         } 
      } 
   } 
} 

proc reset_ramowki { min hour day month year } { 
   reset_db 
} 

if {[string match *odliczadlo* [timers]] != 1} { 
   timer [grab_time] odliczadlo 
} 

putlog "ramowki.tcl ver 0.4 by Tomekk loaded" 
Try this and tell me if there is any problem.
|AmDeAtH @ Undernet
Death is only the *Beginning*...
Post Reply