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 request list songs

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 request list songs

Post by kn1ghtt »

hello greetings .. I would like you to help me with this code it is to see the list of requests .. but I manage to show them .. delete them .. but I need that when they put the command !pedido request the songs that they request are saved in the text requestlist.txt
please help.



Code: Select all

######################################################################################################################
######################################################################################################################

proc pub_wish { nick uhost handle chan arg } {
global CanalesRadio CanalAdmins CanalDjs limit

set temp [open "peticiones" r]
             set peticiones [gets $temp]
     close $temp
     if {$peticiones == "Abiertas"} {
   
if {$arg == ""} { putquick  [encoding convertfrom utf-8 "privmsg $chan :6 $nick 14Por Favor 13Especifica 14El Tema Que 13Deseas Pedir.6 !pedido Artista - Tema  14Gracias Por 13Sintonizar: 1 fanaticaextrema(com)   "]; return 0}
set host [lindex [split [getchanhost $nick $chan] @] 1]
     set idents [lindex [split [getchanhost $nick $chan] @] 0]
     if {[onchan $nick]} {set im "*!*@[join [lrange [split $host .] 0 end] .]"} else {set im "$nick"}
 if {[onchan $nick]} {set ident1 "*![join $idents]@*" }
 if {"$idents" == "ircap"} {set ident1 "*![join $idents]@[join $host]"
     } else {
     set ident1 "*![join $idents]@[join $host]" }
#para probarlo SOLO modifique la linea siguiente por if $chan == $CanalesRadio, porque el proceso/archivo status esta en otra parte del codigo y siempre daba q la radio estaba off        
if { [info exist arg] } {
set temp [open "djnick" r]
set djnick [gets $temp]
close $temp

if {![info exist limit]} { set limit 360}
     foreach {_nick time} [array get ::flood] { if {[expr [clock seconds] - $time] > $limit} { unset ::flood($_nick) } }
     foreach {_ident1 time} [array get ::flood] { if {[expr [clock seconds] - $time] > $limit} { unset ::flood($_ident1) } }
# Crear una variable global que guarde el tiempo en segundos que se ejecutó el comando:

# (al final del todo está)

# Comprobar si la variable existe y todavía no ha transcurrido el tiempo límite de 360 segundos

if {([info exists ::flood($nick)]) || ([info exists ::flood($ident1)])} {

# Existe, así que comprobar el tiempo transcurrido

set timeago [expr [clock seconds] - $::flood($nick)]
set timeago [expr [clock seconds] - $::flood($ident1)]
 # ahora $timeago contiene el tiempo que ha pasado entre ahora y cuando lo ejecutó

# si $timeago es menos tiempo que el que pusimos de límite...
if {$timeago < $limit} {

 set rest [expr $limit - $timeago]
     putmsg  $chan [encoding convertfrom utf-8 "6 $nick 14espera 4 [duration $rest] 14para solicitar otra 6canción nuevamente."]
if { $rest > 340 } {
newignore $im $handle "antiflood 2min" "2"
#putquick "PRIVMSG $chan :6 $nick 14espera 4 [duration $rest] 14para solicitar otra 6canción nuevamente.4?"
putlog "Ignore ($nick): $im $handle antiflood 2min"
newignore $ident1 $handle "antiflood2min" "2"
putlog "Ignore ($nick): $ident1 $handle antiflood 2min"
putmsg $CanalAdmins "4AVISO1!!!14 Se ha puesto en \002ignore\002 a \002$nick\002 (Antiflood 2 minutos) "
     } else { return }
}
} else {
# Este usuario es nuevo, le creamos la variable

putquick  [encoding convertfrom utf-8 "privmsg $CanalDjs :1Petición / En 01 $chan  el nick 6 $nick  solicita: 06 $arg "]
putquick  [encoding convertfrom utf-8 "privmsg $CanalAdmins :1Petición / En 01 $chan  el nick 6 $nick  solicita: 06 $arg "]
putquick  [encoding convertfrom utf-8 "privmsg $djnick :1Petición / En 01 $chan  el nick 6 $nick  solicita: 06 $arg "]

putquick  [encoding convertfrom utf-8 "privmsg $chan :6Tema 6aceptado 14con exito 06 $nick  14En un momento más 6la escucharas."]

set ::flood($nick) [clock seconds]
set ::flood($ident1) [clock seconds]
}
} else {
putquick "privmsg $chan :6Lo Siento 14El Comando 13No Se Puede 6Usar La 13Radio 14Está 6Fuera 13De 14Línea." }
} else {
              putquick  [encoding convertfrom utf-8 "privmsg $chan : 4Error1!  01 $nick  1Por ahora las peticiones estan cerradas."]
             return 0
}
}

######################################################################################################################
######################################################################################################################

## Advert the Request List
bind pub -|- !listapedidos requestlist
proc requestlist {nick uhost hand chan arg} {
       global CanalDjs
       if {$chan == $CanalDjs} {
               set reqnumber 0
               set filename "requestlist.txt"
               set in [open $filename r]
               while {1} {
                       set line [gets $in]
                       if {$line == ""} {
                               putnow "PRIVMSG $CanalDjs :There are no requests at the moment."
                               break
                       } else {
                               if {[eof $in]} {
                                       putnow "PRIVMSG $CanalDjs :Fin Listado peticiones"
                                       close $in
                                       break
                               }
                               if {$reqnumber == 0} {
                                       putnow "PRIVMSG $CanalDjs :Inicio Listado peticiones"
                                       incr reqnumber
                               } else {
                                       putnow "PRIVMSG $CanalDjs :$reqnumber: $line"
                                       incr reqnumber
                               }
                       }
               }
       }
}

## Clear the Request List
bind pub -|- !limpiarlista clearlist
proc clearlist {nick uhost hand chan arg} {
       global CanalDjs
       if {$chan == $djchan} {
               if {[isop $nick $chan] == 1 || [ishalfop $nick $chan] == 1} {
                       set filename "requestlist.txt"
                       set out [open $filename w]
                       set line ""
                       puts $out $line
                       putnow "PRIVMSG $CanalDjs :$nick has cleared the request list."
                       close $out
               }
       }
}

## Delete Request Func + Timer
bind pub -|- !borrarpedido requestproc
proc requestproc {reqitem} {
       set filename "requestlist.txt"
       set testin [open $filename r]
       set line [gets $testin]
       close $testin
       if {$line == ""} {
               set out [open $filename [list RDWR APPEND CREAT]]
               set newline $reqitem
               puts -nonewline $out $newline
               close $out
       } else {
               # Create a Timestamp for the file
               set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
               # Create a Temp and Backup File
               set temp $filename.new.$timestamp
               # Set In/Out to Open Peak.txt in Read-Only/Write-Only
               set in [open $filename r]
               set out [open $temp [list RDWR APPEND CREAT]]
               set line $reqitem
               puts $out $line
               set file_data [read $in]
               puts -nonewline $out $file_data
               close $in
               close $out
               file rename -force $temp $filename
       }
}

######################################################################################################################
######################################################################################################################
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Please, do not double post.

Just add this part of code:

Code: Select all

bind pub -|- !pedido addrequest
proc addrequest {nick uhost handle chan text} {
   set fo [open requestlist.txt a]
   puts $fo $text
   close $fo
   puthelp "PRIVMSG $nick :Request added"
}
k
kn1ghtt
Voice
Posts: 10
Joined: Mon Aug 01, 2022 12:54 am

Post by kn1ghtt »

and code complet CrazyCat please help me

channel #radio_fanatica

[ 15¦33¦57¦pm] @kn1ght: !pedido song1
[ 15¦33¦58¦pm] @fanaticaBot: Tema aceptado con exito kn1ght En un momento más la escucharas.

and channel #fanatica_djs command:

!listapedidos

[ 15¦27¦01¦pm] @kn1ght: !listapedidos
[ 15¦27¦01¦pm] @fanaticaBot: Inicio Listado peticiones
[ 15¦27¦01¦pm] @fanaticaBot: Fin Listado peticiones


and no add list archive requestlist.txt

and tcl is

and channel example command !listapedidos

[ 15¦27¦01¦pm] @fanaticaBot: Inicio Listado peticiones
[ 15¦27¦01¦pm] @fanaticaBot: 1: song1
[ 15¦27¦01¦pm] @fanaticaBot: Fin Listado peticiones


ples help me


Code: Select all

set scwishtrigger "!pedido"

bind pub - $scwishtrigger  pub_wish
bind msg - $scwishtrigger  msg_wish

proc pub_wish { nick uhost handle chan arg } {
global CanalesRadio CanalAdmins CanalDjs limit

set temp [open "peticiones" r]
              set peticiones [gets $temp]
      close $temp
      if {$peticiones == "Abiertas"} {
     
if {$arg == ""} { putquick  [encoding convertfrom utf-8 "privmsg $chan :6 $nick 14Por Favor 13Especifica 14El Tema Que 13Deseas Pedir.6 !pedido Artista - Tema  14Gracias Por 13Sintonizar: 1 fanaticaextrema(com)   "]; return 0}
set host [lindex [split [getchanhost $nick $chan] @] 1]
      set idents [lindex [split [getchanhost $nick $chan] @] 0]
      if {[onchan $nick]} {set im "*!*@[join [lrange [split $host .] 0 end] .]"} else {set im "$nick"}
  if {[onchan $nick]} {set ident1 "*![join $idents]@*" }
  if {"$idents" == "ircap"} {set ident1 "*![join $idents]@[join $host]"
      } else {
      set ident1 "*![join $idents]@[join $host]" }
#para probarlo SOLO modifique la linea siguiente por if $chan == $CanalesRadio, porque el proceso/archivo status esta en otra parte del codigo y siempre daba q la radio estaba off        
if { [info exist arg] } {
set temp [open "djnick" r]
set djnick [gets $temp]
close $temp

if {![info exist limit]} { set limit 360}
      foreach {_nick time} [array get ::flood] { if {[expr [clock seconds] - $time] > $limit} { unset ::flood($_nick) } }
      foreach {_ident1 time} [array get ::flood] { if {[expr [clock seconds] - $time] > $limit} { unset ::flood($_ident1) } }
# Crear una variable global que guarde el tiempo en segundos que se ejecutó el comando:

# (al final del todo está)

# Comprobar si la variable existe y todavía no ha transcurrido el tiempo límite de 360 segundos

if {([info exists ::flood($nick)]) || ([info exists ::flood($ident1)])} {

# Existe, así que comprobar el tiempo transcurrido

set timeago [expr [clock seconds] - $::flood($nick)]
set timeago [expr [clock seconds] - $::flood($ident1)]
  # ahora $timeago contiene el tiempo que ha pasado entre ahora y cuando lo ejecutó
 
# si $timeago es menos tiempo que el que pusimos de límite...
if {$timeago < $limit} {

  set rest [expr $limit - $timeago]
      putmsg  $chan [encoding convertfrom utf-8 "6 $nick 14espera 4 [duration $rest] 14para solicitar otra 6canción nuevamente."]
if { $rest > 340 } {
newignore $im $handle "antiflood 2min" "2"
#putquick "PRIVMSG $chan :6 $nick 14espera 4 [duration $rest] 14para solicitar otra 6canción nuevamente.4?"
putlog "Ignore ($nick): $im $handle antiflood 2min"
newignore $ident1 $handle "antiflood2min" "2"
putlog "Ignore ($nick): $ident1 $handle antiflood 2min"
putmsg $CanalAdmins "4AVISO1!!!14 Se ha puesto en \002ignore\002 a \002$nick\002 (Antiflood 2 minutos) "
      } else { return }
}
} else {
# Este usuario es nuevo, le creamos la variable

putquick  [encoding convertfrom utf-8 "privmsg $CanalDjs :1Petición / En 01 $chan  el nick 6 $nick  solicita: 06 $arg "]
putquick  [encoding convertfrom utf-8 "privmsg $CanalAdmins :1Petición / En 01 $chan  el nick 6 $nick  solicita: 06 $arg "]
putquick  [encoding convertfrom utf-8 "privmsg $djnick :1Petición / En 01 $chan  el nick 6 $nick  solicita: 06 $arg "]

putquick  [encoding convertfrom utf-8 "privmsg $chan :6Tema 6aceptado 14con exito 06 $nick  14En un momento más 6la escucharas."]
set ::flood($nick) [clock seconds]
set ::flood($ident1) [clock seconds]
}
} else {
putquick "privmsg $chan :6Lo Siento 14El Comando 13No Se Puede 6Usar La 13Radio 14Está 6Fuera 13De 14Línea." }
} else {
               putquick  [encoding convertfrom utf-8 "privmsg $chan : 4Error1!  01 $nick  1Por ahora las peticiones estan cerradas."]
              return 0
}
}

######################################################################################################################
######################################################################################################################

## Advert the Request List 
bind pub -|- !listapedidos requestlist 
proc requestlist {nick uhost hand chan arg} {
	global CanalDjs 
	if {$chan == $CanalDjs} {
		set reqnumber 0
		set filename "requestlist.txt"
		set in [open $filename r]
		while {1} {
			set line [gets $in]
			if {$line == ""} {
				putnow "PRIVMSG $CanalDjs :There are no requests at the moment."
				break
			} else {
				if {[eof $in]} {
					putnow "PRIVMSG $CanalDjs :Fin Listado peticiones"
					close $in
					break
				}
				if {$reqnumber == 0} {
					putnow "PRIVMSG $CanalDjs :Inicio Listado peticiones"
					incr reqnumber
				} else {
					putnow "PRIVMSG $CanalDjs :$reqnumber: $line"
					incr reqnumber
				}
			}
		}
	}
}

## Clear the Request List 
bind pub -|- !limpiarlista clearlist 
proc clearlist {nick uhost hand chan arg} {
	global CanalDjs 
	if {$chan == $djchan} {
		if {[isop $nick $chan] == 1 || [ishalfop $nick $chan] == 1} {
			set filename "requestlist.txt"
			set out [open $filename w]
			set line ""
			puts $out $line
			putnow "PRIVMSG $CanalDjs :$nick has cleared the request list."
			close $out
		}
	}
}

## Delete Request Func + Timer
bind pub -|- !borrarpedido requestproc 
proc requestproc {reqitem} {
	set filename "requestlist.txt"
	set testin [open $filename r]
	set line [gets $testin]
	close $testin
	if {$line == ""} {
		set out [open $filename [list RDWR APPEND CREAT]]
		set newline $reqitem
		puts -nonewline $out $newline
		close $out
	} else {
		# Create a Timestamp for the file
		set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
		# Create a Temp and Backup File
		set temp $filename.new.$timestamp
		# Set In/Out to Open Peak.txt in Read-Only/Write-Only
		set in [open $filename r]
		set out [open $temp [list RDWR APPEND CREAT]]
		set line $reqitem
		puts $out $line
		set file_data [read $in]
		puts -nonewline $out $file_data
		close $in
		close $out
		file rename -force $temp $filename
	}
}


please help me 
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Just add the part of code I gave you in your script, and rehash your eggdrop
k
kn1ghtt
Voice
Posts: 10
Joined: Mon Aug 01, 2022 12:54 am

Post by kn1ghtt »

thanks CrazyCat ^^
Post Reply