| View previous topic :: View next topic |
| Author |
Message |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Mar 16, 2017 4:29 pm Post subject: |
|
|
Done.
Found a problem.
This line was line wrapped
| Code: |
regsub -all -- {\002|\037|\026|\017|\003([0-9][0-9]?(,[0-9][0-9]?)?)?|||([0-9][0-9]?(,[0-9][0-9]?)?)?|} $text "" text
|
and it has another problem too. Notice the funky character? (It didn't copy and paste to here ... sorry... check it out in your pastebin though )
That's not there, in the line numbered (top) part of your pastebin.
However, I used the bottom part, so I could 'select all' to copy-and-paste.
Then, when I instead copied just that one line, from the top part of the pastebin, and tried to paste it in nano... nano didn't like it. Jumped to some other part of the file.
So I did it char by char, by hand.
| Quote: |
so it's probably better to set https://... instead.
|
Now using:
| Code: |
set alice_url "https://pandorabots.com/pandora/talk?botid=*********"
|
Just double checked.
It will go try to do something now.
Now, it returns this, in the partyline:
| Code: |
Tcl error [alice:pub_query]: bogus URL: https://pandorabots.com/pandora/talk?botid=**********
|
_________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Thu Mar 16, 2017 9:04 pm Post subject: |
|
|
This 'Bogus URL..' comes from egghttp.tcl / proc egghttp:geturl :
| Code: | | if {![regexp -nocase {^(http://)?([^:/]+)(:([0-9]+))?(/.*)?$} $url x protocol server y port path]} { |
This Regex only works for http URLs ,
if you Replace it to :
| Code: | | if {![regexp -nocase {^(http(s|)://)?([^:/]+)(:([0-9]+))?(/.*)?$} $url x protocol server y port path]} { |
it can pass that 'Bogus ...' thing but
I see this egghttp using Eggdrop-Tcl's : connect <host> <port> command instead Tcl's http package or socket command
and I am not realy sure about does that method able to handle https connections.
I don't know why he'd prefer to use this instead but https links returns
| Quote: |
net: connect! sock 11
net: eof!(read) socket 11
|
and if you try http://pandorabots it return :
| Quote: |
DNS lookup failed
Tcl: while executing
Tcl: "connect $server $port"
|
and doesn't give more useful information i can use for debuging what it is the problem.
so I am still testing things with my little test snippets and i see that it is still available to work as https://pandora... and i've tried with using cookies or without it and i can get response.
I am gonna try to edit/re-write the whole fetching procedures with using http and tls packages instead egghttp.tcl but i have to make some more tests to figure out how works things.
it can takes some more time sorry for delay.
and Settore , I just tried once again and i didn't get any error , so i don't know what can i say but it is still working fine from here.
this is what my bot has.
| Code: |
#Bot's Nickname to Respond to: ex. MyBot - Usage: MyBot, what's 1+1?
set pandoraNick "k-bot"
#Your Pandora Bot ID. (Feel free to use the existing one if you want, but the bot will think its name is AlphaBot
set botid "a5cd504e4e342614"
#STOP EDITING HERE
package require http
if {[catch {package require tls 1.6}]} {
putcmdlog "https links requires tcltls : https://core.tcl.tk/tcltls/wiki/Download"
set enabletls 0
} else {
set enabletls 1
tls::init -ssl3 0 -ssl2 0 -tls1 1
http::register https 443 [list ::tls::socket -require 0 -request 1]
}
bind pubm - "% ${pandoraNick}*" talkto
proc talkto {n u h c t} {
set query [::http::formatQuery botid $::botid custid $n input [join [lrange [split $t] 1 end]]]
if {[catch {set token [::http::geturl https://pandorabots.com/pandora/talk-xml -query $query -timeout 16000]} error]} {
putlog "[string map [list \n " ,"] $error] ,[::http::status $token]"
::http::cleanup $token
}
if {[string match -nocase "timeout" [::http::status $token]]} {
putlog "[::http::code $token]"
::http::cleanup $token
}
if {![string equal -nocase [::http::status $token] "ok"]} {
putlog "[::http::code $token] ,[::http::status $token]"
::http::cleanup $token
}
if {[::http::ncode $token] == "200" && [string equal -nocase [::http::status $token] "ok"]} {
set pandata [::http::data $token]
::http::cleanup $token
}
if {![regexp {<that>(.*?)</that>} $pandata -> responce]} {
putlog "This regex sucks!!! Source codes changed or what?!?"
return
} else {
puthelp "privmsg $c :[string map {" \"} $responce]"
}
return 0
}
|
_________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
Settore Voice
Joined: 05 Mar 2017 Posts: 8
|
Posted: Fri Mar 17, 2017 6:50 pm Post subject: Same story... |
|
|
It worked for some time.
Now:
| Code: | | [00:48:53] <(AI> [22:48:53] Tcl error [talkto]: can't read "token": no such variable |
Something is wrong, somewhere... |
|
| Back to top |
|
 |
Koach Voice
Joined: 19 Apr 2009 Posts: 21
|
Posted: Fri Mar 17, 2017 10:18 pm Post subject: |
|
|
Hi heartbroken,
If i wanted the eggdrop to respond if the bot's nick was anywhere in the sentence instead of the beginning only, what would I change in script you posted.
Thanks,
Koach |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sat Mar 18, 2017 3:09 am Post subject: |
|
|
Koach :
| Code: | #Bot's Nickname to Respond to: ex. MyBot - Usage: MyBot, what's 1+1?
set pandoraNick "MyBot"
#Your Pandora Bot ID. (Feel free to use the existing one if you want, but the bot will think its name is AlphaBot
set botid "a5cd504e4e342614"
# enable chat in bot pm : 1 ,disable : 0 or ""
set botpm 1
# user must wait xx seconds between messages to get a response from bot.
set chatstop 10
#STOP EDITING HERE
package require http
if {[catch {package require tls 1.6}]} {
putcmdlog "https links requires tcltls : https://core.tcl.tk/tcltls/wiki/Download"
set enabletls 0
} else {
set enabletls 1
tls::init -ssl3 0 -ssl2 0 -tls1 1
http::register https 443 [list ::tls::socket -require 0 -request 1]
}
# .chanset #channel +talk
setudef flag talk
bind pubm - "*" talkto_pub
bind msgm - "*" talkto_pvt
proc talkto_pub {nick uhost hand chan text} {
if {![channel get $chan talk] || $::pandoraNick ni [fix_chars $text]} { return 0 }
talkto $nick $uhost $hand $chan $text
}
proc talkto_pvt {nick uhost hand text} {
if {$::pandoraNick ni [fix_chars $text]} { return }
if {[string length $::botpm] && $::botpm >= "1"} {
talkto $nick $uhost $hand $nick $text
}
return 0
}
proc talkto {nick uhost hand chan text} {
if {[info exists ::flooder($nick)] && [expr {$::flooder($nick) + $::chatstop}] > [clock seconds]} { return 0 }
regsub -all -- $::pandoraNick [fix_chars $text] {} TxT
set query [::http::formatQuery botid $::botid custid $nick input $TxT]
set ua "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"
set token [::http::config -useragent $ua -urlencoding "utf-8"]
if {[catch {set token [::http::geturl https://pandorabots.com/pandora/talk-xml -query $query -timeout 16000]} error]} {
putlog "[string map [list \n " ,"] $error] ,[::http::status $token]"
::http::cleanup $token
} elseif {[string match -nocase "timeout" [::http::status $token]]} {
putlog "[::http::code $token]"
::http::cleanup $token
} elseif {![string equal -nocase [::http::status $token] "ok"]} {
putlog "[::http::code $token] ,[::http::status $token]"
::http::cleanup $token
} elseif {[::http::ncode $token] == "200" && [string equal -nocase [::http::status $token] "ok"]} {
set pandata [::http::data $token]
::http::cleanup $token
} else {
putlog "Error: [::http::status $token] ,[::http::code $token]"
::http::cleanup $token
}
if {[info exists pandata]} {
if {![regexp {<that>(.*?)</that>} $pandata -> responce]} {
putlog "This regex sucks!!! Source codes changed or what?!?"
return
} else {
puthelp "privmsg $chan :[fix_talk $responce]"
set ::flooder($nick) [clock seconds]
}
}
return 0
}
proc fix_chars {txt} {
return [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\} \$ \\\$ \" \\\"} $txt]
}
proc fix_talk {str} {
return [string map {" " " " "&" {\&} """ "\'" "©" "(c)"\
"&#" "#" "<" "<" ">" ">" "%20" " "} $str]
} |
To activate : .chanset #Your-channel +talk in Partyline.
Settore try this version. I didn't get any error still.
I've added useragent and added an option to see unknown errors or connection failors .and a fix procedure for some html entities into bot response.
+ added another char fix procedure for your $text because if you say somethings to your bot which has some special Tcl characters in it like " { } [ ] \ code throws an error. this procedure (hopefully) fixing this issue.
Edit:
Script updated. Added flood control and bot able to response privat messages now. ( if you wish) _________________ Life iS Just a dReaM oN tHE wAy to DeaTh
Last edited by heartbroken on Sat Mar 18, 2017 9:32 am; edited 1 time in total |
|
| Back to top |
|
 |
Settore Voice
Joined: 05 Mar 2017 Posts: 8
|
Posted: Sat Mar 18, 2017 8:33 am Post subject: Thanks a lot... |
|
|
Thanks a lot.
Will try now. |
|
| Back to top |
|
 |
Koach Voice
Joined: 19 Apr 2009 Posts: 21
|
Posted: Sat Mar 18, 2017 6:46 pm Post subject: |
|
|
Thanks very much for this, heartbroken.
If i wanted to have it so chatters could type uppercase or lowercase for the bot's nick, where would be the easiest place to add that?
thanks again,
Koach |
|
| Back to top |
|
 |
Settore Voice
Joined: 05 Mar 2017 Posts: 8
|
Posted: Sat Mar 18, 2017 8:11 pm Post subject: Still error |
|
|
Thanks, but still gets an error. Eggdrop 1.8.0 on TCL 8.6
| Code: | | 02:10:36] <(AI> [00:10:32] Tcl error [talkto]: Unknown option -urlencoding, must be: -accept, -proxyfilter, -proxyhost, -proxyport, -useragent |
I think I'll quit on the idea of using pandorabots.com and stay at bMotion. |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sun Mar 19, 2017 3:57 am Post subject: |
|
|
Settore :
Do you have another old http.tcl sourced in your bot .conf ?
http::config has -urlencoding -option since http 2.5 and Tcl 8.6 has http 2.8.5 <-> 2.8.10 is the newest one.
http package already included in Tcl. there is no need to source it elsewhere.
and Your Tcl 8.6 / http version 'should' support this -urlencoding http::config -option.
I am testing things with an Eggdrop 1.8.1rc2 bot and Tcl 8.6.6
Older versions doesn't have this .You can check the differences at :
Tcl 8.3 / http man page / http::config : https://www.tcl.tk/man/tcl8.3/TclCmd/http.htm#M6
Tcl 8.4 / http man page / http::config : https://www.tcl.tk/man/tcl8.4/TclCmd/http.htm#M6
or ,for all 'changes' : http://wiki.tcl.tk/405
Add a line outside of the procs, like:
| Code: | | putlog "I am: [lindex $::version 0] with Tcl: [info patchlevel] is in $::tcl_library with http: [package present http] and tcltls: [package present tls] OS: $::tcl_platform(os) $::tcl_platform(osVersion)/$::tcl_platform(machine)" |
this will show you some info while rehash/restart at partyline.
Koach :
Change; proc talkto_pub :
| Code: | | if {![channel get $chan talk] || $::pandoraNick ni [fix_chars $text]} { return 0 } |
to
| Code: | | if {![channel get $chan talk] || ([expr {[lsearch -nocase [fix_chars $text] $::pandoraNick]}] == "-1")} { return 0 } |
and in proc talkto_pvt replace:
| Code: | | if {$::pandoraNick ni [fix_chars $text]} { return } |
line to :
| Code: | | if {[expr {[lsearch -nocase [fix_chars $text] $::pandoraNick]}] == "-1"} { return 0 } | done.
note : lsearch has this -nocase -option since Tcl 8.5 older version didn't support this. _________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
Koach Voice
Joined: 19 Apr 2009 Posts: 21
|
Posted: Sun Mar 19, 2017 5:30 pm Post subject: |
|
|
Thanks heartbroken,
Everything works great.
But, and I hope you don't mind me asking, I have one more question (I hope lol). How can i get the bot to respond when its nick has a trailing comma, or colon. For example "hi bot, how are you" or "Bot: what does this mean."
I really appreciate all the time you have spent answering my questions.
Koach |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sun Mar 19, 2017 10:30 pm Post subject: |
|
|
You can add an asterisk { * } right'n side of $::pandoraNick variable in both [expr [lsearch .. lines. :
${::pandoraNick}* or $::pandoraNick* works. _________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
Koach Voice
Joined: 19 Apr 2009 Posts: 21
|
Posted: Sun Mar 19, 2017 10:38 pm Post subject: |
|
|
Sheesh, I don't know why I always try to make things harder than they are lol
Thanks again for all your help.
Koach |
|
| Back to top |
|
 |
Koach Voice
Joined: 19 Apr 2009 Posts: 21
|
Posted: Thu Mar 23, 2017 11:16 pm Post subject: |
|
|
heartbroken,
I wonder if you, or anyone, might have an answer to this.
When I type the bot's name starting with a lowercase f, the response includes the bot's name inserted in the sentence. An uppercase F, replies correctly.
Example:
<Koach> fovea branson is nuts
<Fovea> Koach: Ok I will add that fact about fovea branson to my database.
<Koach> Fovea branson is nuts
<Fovea> Koach: Ok I will add that fact about branson to my database.
Aside from your recommended changes, the only thing I added was the chatters nick:
puthelp "privmsg $chan $nick: [fix_talk $responce]"
Thanks,
Koach |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Fri Mar 24, 2017 2:58 am Post subject: |
|
|
Script sending your messages as a -query to the pandorabots site and pandorabots doesn't recognize the bot name if the comparison is fail cause they looking for -exact match.
Go to proc talkto :
| Code: | | regsub -all -- $::pandoraNick [fix_chars $text] {} TxT |
and change this line to:
| Code: | | regsub -all -nocase $::pandoraNick [fix_chars $text] {} TxT |
And :
| Code: | | puthelp "privmsg $chan $nick: [fix_talk $responce]" |
line should be :
| Code: | | puthelp "privmsg $chan :$nick: [fix_talk $responce]" | like this. _________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
Koach Voice
Joined: 19 Apr 2009 Posts: 21
|
Posted: Fri Mar 24, 2017 9:16 am Post subject: |
|
|
heartbroken,
Once again, thank you. I should have known that $nick: should be :$nick:.
But, I would not have figured out the change to the regsub line. Thanks for that explanation.
Koach |
|
| Back to top |
|
 |
|