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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Pauschi
Voice
Posts: 11 Joined: Tue Sep 03, 2019 11:09 am
Post
by Pauschi » Sun Aug 09, 2020 11:35 am
Hello,
im looking for a easy and simple TCL script, that can be triggered by @(Operators) only:
When a Operator writes:
in the Channel #pizza, it shall open up a connection to website
Code: Select all
http://google.de/pizza.php?user=$IRC_NICKNAME
in the background and respond with the Website's content.
$IRC_Nickname in the URL should be the irc-username that triggered the .pizza command.
Im unable to find such easy script in the WWW yet. Hopefully someone is able to help me!
Thanks
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sun Aug 09, 2020 6:59 pm
Well, I'm not sure that
http://google.de/pizza.php will return anything else than a 404 error...
Btw, requesting a http page is really simple:
Code: Select all
bind pub -|o ".pizza" pizzame
package require http
proc pizzame {nick host handle chan text} {
set tok [::http::geturl "http://google.de/pizza.php?user=$nick"]
set data [::http::data $tok]
putserv "PRIVMSG $chan :$data"
}
Pauschi
Voice
Posts: 11 Joined: Tue Sep 03, 2019 11:09 am
Post
by Pauschi » Mon Aug 10, 2020 12:15 pm
Thank you very much for answering.
I'll check it out and let you know if its working
yeah it was a example URL
EDIT: Somehow the bot is not responding :/
It worked with:
bind pub - ".pizza" pizzame
but not with
bind pub -|o ".pizza" pizzame
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Aug 10, 2020 3:03 pm
It depends on what you mean when you say it must be triggered by operator.
If it's channel operator in the eggdrop' userlist, my bind was right.
If it's being opped in the channel, your bind is right but you have to add a check at the begin of the procedure:
Code: Select all
if {![isop $nick $chan]} { return 1 }
Pauschi
Voice
Posts: 11 Joined: Tue Sep 03, 2019 11:09 am
Post
by Pauschi » Mon Aug 10, 2020 3:19 pm
All OPS and VOICE users in the channel should be allowed to do it.
if {![isop $nick $chan]} { return 1 }
Where do i need to set this? ;P
ComputerTech
Master
Posts: 399 Joined: Sat Feb 22, 2020 10:29 am
Contact:
Post
by ComputerTech » Mon Aug 10, 2020 10:17 pm
Like this
Code: Select all
bind pub - ".pizza" pizzame
package require http
proc pizzame {nick host handle chan text} {
if {![isop $nick $chan]} { return 1 }
set tok [::http::geturl "http://google.de/pizza.php?user=$nick"]
set data [::http::data $tok]
putserv "PRIVMSG $chan :$data"
}
when CrazyCat says procedure, he means basically the proc
Code: Select all
proc pizzame {nick host handle chan text} { << Proc
Pauschi wrote: All OPS and VOICE users in the channel should be allowed to do it.
if {![isop $nick $chan]} { return 1 }
Where do i need to set this? ;P
the above code will Only allow channel op's to use the command, there is also..
Code: Select all
if {![isvoice $nick $chan]} { return 1 }
if you prefer that
ComputerTech
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Aug 11, 2020 2:32 am
Thanks ComputerTech.
@Pauschi: if you want to have it working for voice and ops (add halfop to), the final script is:
Code: Select all
bind pub - ".pizza" pizzame
set desturl "http://google.de/pizza.php"
package require http
proc pizzame {nick host handle chan text} {
if { ![isop $nick $chan] && ![ishalfop $nick $chan] && ![isvoice $nick $chan] } { return 1 }
set query [::http::formatQuery user $nick]
set tok [::http::geturl $::desturl -query $query]
set data [::http::data $tok]
putserv "PRIVMSG $chan :$data"
}
Notice that it won't work with https url.
Pauschi
Voice
Posts: 11 Joined: Tue Sep 03, 2019 11:09 am
Post
by Pauschi » Tue Aug 11, 2020 2:35 am
Thank you guys, appreciate your work and help!
Ive just learned that https links sadly dont work.
Theres no way to avoid this?
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Aug 11, 2020 3:44 am
Sure there is a way
Code: Select all
bind pub - ".pizza" pizzame
set desturl "http://google.de/pizza.php"
package require http
package require tls
proc pizzame {nick host handle chan text} {
if { ![isop $nick $chan] && ![ishalfop $nick $chan] && ![isvoice $nick $chan] } { return 1 }
if { [string match "https://*" $::desturl] } {
::http::register https 443 [list ::tls::socket -autoservername true]
set https 1
} else {
set https 0
}
set query [::http::formatQuery user $nick]
set tok [::http::geturl $::desturl -query $query]
set data [::http::data $tok]
if { $https == 1 } { ::http::unregister https }
putserv "PRIVMSG $chan :$data"
}
I made the script adaptative to url scheme, but you can have troubles with tls handshake, depending on the url you want to access.
Pauschi
Voice
Posts: 11 Joined: Tue Sep 03, 2019 11:09 am
Post
by Pauschi » Tue Aug 11, 2020 9:22 am
CrazyCat wrote: Thanks ComputerTech.
@Pauschi: if you want to have it working for voice and ops (add halfop to), the final script is:
Code: Select all
bind pub - ".pizza" pizzame
set desturl "http://google.de/pizza.php"
package require http
proc pizzame {nick host handle chan text} {
if { ![isop $nick $chan] && ![ishalfop $nick $chan] && ![isvoice $nick $chan] } { return 1 }
set query [::http::formatQuery user $nick]
set tok [::http::geturl $::desturl -query $query]
set data [::http::data $tok]
putserv "PRIVMSG $chan :$data"
}
Notice that it won't work with https url.
Thanks! Im using this script because i better skip the HTTPS thing, since its not working with the servers configuration (https force is on there).
However, i tried setting this URL =>
set desturl "
http://google.de/pizza.php[b]?user=$nick [/b]"
its not using the $nick (IRC Nickname) with this way
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Aug 11, 2020 9:36 am
You may try to understand the script and how it works.
desturl is setted at the beginning, before the proc is called, so adding "user=$nick" is an error because there is no $nick variable setted yet.
In the proc, I create the query (things coming after the ? in url), so:
Code: Select all
set query [::http::formatQuery user $nick]
set tok [::http::geturl $::desturl -query $query]
will create:
http://google.de/pizza.php?user=<$nick > (<$nick> is the user doing .pizza)
The interest of this is that if you have special characters in $nick, they will be adapted. And if you need to post rather than get, it's managed by the http call.
ComputerTech
Master
Posts: 399 Joined: Sat Feb 22, 2020 10:29 am
Contact:
Post
by ComputerTech » Tue Aug 11, 2020 10:08 am
Nice code CrazyCat
I like the way you did this
Code: Select all
if { ![isop $nick $chan] && ![ishalfop $nick $chan] && ![isvoice $nick $chan] } { return 1 }
I will use that for my code from now on
ComputerTech
Pauschi
Voice
Posts: 11 Joined: Tue Sep 03, 2019 11:09 am
Post
by Pauschi » Wed Aug 12, 2020 8:27 am
Thanks Again CrazyCat!
When i check my Apache2 Logs,
only pizza.php gets triggered, without ?user=<$nick>
Code: Select all
"POST /pizza.php HTTP/1.1" 200 220 "-" "Tcl http client package 2.7.13"
pizza.php:
Code: Select all
<?php
$user = $_GET['user'];
$gesamt = file_get_contents("bier_$user.txt");
if (in_array($_GET['user'], ['Thomas', 'h4']))
{
echo "$user: Biere insgesamt: $gesamt"; die;
}else{
echo "Keine Berechtigung, Junge."; die;
die; }
?>
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Aug 12, 2020 5:57 pm
Log is clear: data are sent with POST, not GET.
So, adapt your php if you can (post is more secure than get) or modify the script to force usage of get:
Code: Select all
set tok [::http::geturl $::desturl -method "GET" -query $query]
P.S.: I hope your PHP is just a POC, because you use depreciated things, too much die, ... really bad code
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Thu Aug 13, 2020 12:32 am
Since he has if-else there no need for die actually.
Once the game is over, the king and the pawn go back in the same box.