View previous topic :: View next topic |
Author |
Message |
flink Halfop

Joined: 21 Feb 2021 Posts: 70 Location: Canarias
|
Posted: Fri Jan 06, 2023 9:53 am Post subject: a help for this part of a tcl |
|
|
First of all, congratulations all Happy New Year 2023.
When users make a musical request, the bot sends it to the dj room and writes it in a txt.
When I request the order list
It always comes out, whether there are requests or not: No requests at the moment.
Any suggestion to fix it?
Code: | bind pub -|- !listapedidos requestlist
proc requestlist {nick uhost hand chan arg} {
global adminchans1
if {$chan == $adminchans1} {
set reqnumber 1
set filename "lista_peticiones.txt"
set in [open $filename r]
while {1} {
set line [gets $in]
if {$line == ""} {
putnow "PRIVMSG $adminchans1 :No hay solicitudes por el momento."
break
} else {
if {[eof $in]} {
putnow "PRIVMSG $adminchans1 :Fin Listado peticion."
close $in
break
}
if {$reqnumber == 0} {
putnow "PRIVMSG $adminchans1 :Inicio Listado peticiones"
incr reqnumber
} else {
putnow "PRIVMSG $adminchans1 :$reqnumber: $line "
#putnow "PRIVMSG $adminchans1 :Fin Listado peticiones"
incr reqnumber
}
}
}
}
} |
_________________ Mi ingles: no es el mejor, Manda el traductor...  |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1108 Location: France
|
|
Back to top |
|
 |
flink Halfop

Joined: 21 Feb 2021 Posts: 70 Location: Canarias
|
Posted: Fri Jan 06, 2023 2:15 pm Post subject: Re: a help for this part of a tcl |
|
|
hello crazycat
with this code I request the list of requests
flink wrote: | First of all, congratulations all Happy New Year 2023.
When users make a musical request, the bot sends it to the dj room and writes it in a txt.
When I request the order list
It always comes out, whether there are requests or not: No requests at the moment.
Any suggestion to fix it?
Code: | bind pub -|- !listapedidos requestlist
proc requestlist {nick uhost hand chan arg} {
global adminchans1
if {$chan == $adminchans1} {
set reqnumber 1
set filename "lista_peticiones.txt"
set in [open $filename r]
while {1} {
set line [gets $in]
if {$line == ""} {
putnow "PRIVMSG $adminchans1 :No hay solicitudes por el momento."
break
} else {
if {[eof $in]} {
putnow "PRIVMSG $adminchans1 :Fin Listado peticion."
close $in
break
}
if {$reqnumber == 0} {
putnow "PRIVMSG $adminchans1 :Inicio Listado peticiones"
incr reqnumber
} else {
putnow "PRIVMSG $adminchans1 :$reqnumber: $line "
#putnow "PRIVMSG $adminchans1 :Fin Listado peticiones"
incr reqnumber
}
}
}
}
} |
|
this is how you write lista_peticiones.txt
Code: | set tempeti [open "lista_peticiones.txt" a]
puts $tempeti "$nick A Solicitado $arg En El Canal $chan"
close $tempeti |
what it does when there are requests:
@dj : !listapedidos
@radio : pepe A Solicitado cuatro pizzas para llevar En El Canal #pruebas
@radio : pepe A Solicitado unas hamburguesas con todo En El Canal #pruebas
@radio : pepe A Solicitado una lechuga verde En El Canal #pruebas
@radio : pepe A Solicitado uno de lomo con todo En El Canal #pruebas
@radio : pepe A Solicitado una lechuga amarilla En El Canal #pruebas
@radio : pepe A Solicitado una cocacola sin gas En El Canal #pruebas
@radio : No hay solicitudes por el momento.
when should it be:
@dj : !listapedidos
@radio : pepe A Solicitado cuatro pizzas para llevar En El Canal #pruebas
@radio : pepe A Solicitado unas hamburguesas con todo En El Canal #pruebas
@radio : pepe A Solicitado una lechuga verde En El Canal #pruebas
@radio : pepe A Solicitado uno de lomo con todo En El Canal #pruebas
@radio : pepe A Solicitado una lechuga amarilla En El Canal #pruebas
@radio : pepe A Solicitado una cocacola sin gas En El Canal #pruebas
@radio : Fin Listado petición.
when there is no request list it should be like this:
@dj : !listapedidos
@radio : No hay solicitudes por el momento.
That's what I need the code to do if you can contribute, thank you. _________________ Mi ingles: no es el mejor, Manda el traductor...  |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 826 Location: Tennessee, USA
|
Posted: Fri Jan 06, 2023 5:37 pm Post subject: try this. |
|
|
Try this
Code: | proc requestlist {nick uhost hand chan arg} {
global adminchans1
if {$chan == $adminchans1} {
set filename "lista_peticiones.txt"
set in [open $filename r]
set reqnumber 0
set data [split [read -nonewline $in] "\n"]
close $in
if {![llength $data]} {
putnow "PRIVMSG $adminchans1 :No hay solicitudes por el momento."
return 0
}
foreach line $data { incr reqnumber
putnow "PRIVMSG $adminchans1 :$reqnumber: $line "
}
putnow "PRIVMSG $adminchans1 :Fin Listado peticion."
}
return 0
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
flink Halfop

Joined: 21 Feb 2021 Posts: 70 Location: Canarias
|
Posted: Sat Jan 07, 2023 7:14 am Post subject: |
|
|
Hi Spike^^
Thank you for collaborating. What you have posted works, it seems that I forgot to put in the previous examples when the list begins with: Start List of requests. One last bit of help could be that when I send the list it goes like this:
@dj : !listapedidos
@radio : Inicio Listado peticiones.
@radio : pepe A Solicitado una lechuga amarilla En El Canal #pruebas
@radio : pepe A Solicitado una cocacola sin gas En El Canal #pruebas
@radio : Fin Listado petición.
In this part how can I put timestamps on it so that it would look like this in the listings:
@radio : pepe A Requested four takeaway pizzas on 07/01/23 at 12:15 In The Channel #tests
Code: | set tempeti [open "lista_peticiones.txt" a]
put $tempeti "$nick A Solicitado $arg En El Canal $chan"
close $tempeti |
_________________ Mi ingles: no es el mejor, Manda el traductor...  |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 826 Location: Tennessee, USA
|
Posted: Sat Jan 07, 2023 10:29 am Post subject: |
|
|
This should add the new "Start List of requests" line...
Code: | proc requestlist {nick uhost hand chan arg} {
global adminchans1
if {$chan == $adminchans1} {
set filename "lista_peticiones.txt"
set in [open $filename r]
set reqnumber 0
set data [split [read -nonewline $in] "\n"]
close $in
if {![llength $data]} {
putnow "PRIVMSG $adminchans1 :No hay solicitudes por el momento."
return 0
}
putnow "PRIVMSG $adminchans1 :Inicio Listado peticiones."
foreach line $data { incr reqnumber
putnow "PRIVMSG $adminchans1 :$reqnumber: $line "
}
putnow "PRIVMSG $adminchans1 :Fin Listado peticion."
}
return 0
} |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
flink Halfop

Joined: 21 Feb 2021 Posts: 70 Location: Canarias
|
Posted: Sat Jan 07, 2023 12:02 pm Post subject: |
|
|
thanks SpiKe^^
the list solution works for me.
for the date and time to be written in each request to be written in list_requests.txt can you help me thank you _________________ Mi ingles: no es el mejor, Manda el traductor...  |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 826 Location: Tennessee, USA
|
Posted: Sat Jan 07, 2023 7:46 pm Post subject: strftime |
|
|
Try put this, or something like this, in the text you want dated... Code: | [strftime "on %x at %X"] |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
flink Halfop

Joined: 21 Feb 2021 Posts: 70 Location: Canarias
|
Posted: Sun Jan 08, 2023 6:39 am Post subject: |
|
|
Thanks SpiKe^^
you have solved the whole code for me all working _________________ Mi ingles: no es el mejor, Manda el traductor...  |
|
Back to top |
|
 |
|