egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Do anyone has the working !fml tcl for the eggdrop?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
_niCk
Voice


Joined: 08 Oct 2018
Posts: 4
Location: [IN]

PostPosted: Mon Nov 19, 2018 5:33 pm    Post subject: Do anyone has the working !fml tcl for the eggdrop? Reply with quote

Greetings,

It's been more than a month now, the !fml script has stopped giving a result while triggered.

Please help!


Best,
_niCk
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 110
Location: somewhere out there

PostPosted: Tue Nov 20, 2018 7:37 am    Post subject: Reply with quote

.chanset #channel +FML

TclTLS : https://core.tcl.tk/tcltls/wiki/Download (tls package)
tcllib : https://github.com/tcltk/tcllib (htmlparse package)

Code:
package require http
package require tls
package require htmlparse

proc do_fml {} {
   if {[package vcompare [package present tls] 1.7] > 0} {
      ::http::register https 443 [list ::tls::socket -autoservername true]
   } else {
      ::http::register https 443 [list ::tls::socket -request 0 -require 1 -ssl2 0 -ssl3 0 -tls1 1]
   }
   ::http::config -useragent "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e" -urlencoding "utf-8"
   if {[catch {set token [http::geturl https://www.fmylife.com/random -binary 0 -timeout 15000]} err]} {
      putlog "FML Error: $err"
      return 0
   }
   if {[http::status $token] eq "ok" && [http::ncode $token] == "200"} {
      set html [http::data $token]
      ::http::cleanup $token
      set out [list ]
      foreach {null data} [regexp -all -inline {block hidden\-xs\">.+?<a href=\"/article/today.+?.html\">(.*?)</a>} $html] {
         regsub -all -- {(<[^<>]+/>)} $data "" data
         regsub -all {FML} $data \00304\002\\0\003 data
         lappend out [split [string trim $data]]
      }
      set fmlout [lindex $out [expr {int(rand()*[llength $out])}]]
   } else {
      set fmlout "FML Error: [http::status $token] - [http::code $token]"
      ::http::cleanup $token
   }
   ::http::unregister https
   return $fmlout
}

bind pub -|- !fml fml_pubin

proc fml_pubin {nick uhost hand chan text} {
   if {![channel get $chan FML]} { return 0 }
   puthelp "PRIVMSG $chan :[join [htmlparse::mapEscapes [do_fml]]]"
}

setudef flag FML


Edited: ::http::register https … lines moved inside of the proc.
_________________
Life iS Just a dReaM oN tHE wAy to DeaTh


Last edited by heartbroken on Wed Nov 21, 2018 8:08 am; edited 2 times in total
Back to top
View user's profile Send private message
_niCk
Voice


Joined: 08 Oct 2018
Posts: 4
Location: [IN]

PostPosted: Tue Nov 20, 2018 4:57 pm    Post subject: Reply with quote

Thank you for the script, heartbroken. Smile

The script worked just great at the very first trigger but after that, it didn't give the results instead returned 0.

PS

@_niCK ¦ !fml
+Twitler ¦ Today, after moving in with a couple of vegan zoologists a few weeks ago, I discover that they don't believe that we have the right to kill cockroaches, and will not allow me to do so. The house is infested, and it's spread to my bedroom. FML
@_niCk ¦ !fml
+Twitler ¦ 0
@_niCk ¦ !fml
+Twitler ¦ 0


In the bot party line, I am getting this error!

FML Error: Unsupported URL type "https"
FML Error: Unsupported URL type "https"


Please advise.

Thnx,
_niCk
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 110
Location: somewhere out there

PostPosted: Wed Nov 21, 2018 8:05 am    Post subject: Reply with quote

I've edited the script above. You're welcome!
_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
Dominatez
Halfop


Joined: 14 Jan 2019
Posts: 48
Location: United Kingdom

PostPosted: Mon May 27, 2019 4:49 pm    Post subject: Reply with quote

This for some odd reason was working and now has stopped.

Keeps with the error :

FML Error: timeout -

Any ideas ?
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 110
Location: somewhere out there

PostPosted: Mon May 27, 2019 6:29 pm    Post subject: Reply with quote

just replace :
Code:
foreach {null data} [regexp -all -inline {block hidden\-xs\">.+?<a href=\"/article/today.+?.html\">(.*?)</a>} $html] {

to:
Code:
foreach {null data} [regexp -all -inline {article\-topbar\">.+?<a href=\"/article/today.+?.html\">(.*?)</a>} $html] {

_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
Dominatez
Halfop


Joined: 14 Jan 2019
Posts: 48
Location: United Kingdom

PostPosted: Fri May 31, 2019 5:50 am    Post subject: Reply with quote

Thank you Heartbroken.

Works like a charm.
Back to top
View user's profile Send private message
Dominatez
Halfop


Joined: 14 Jan 2019
Posts: 48
Location: United Kingdom

PostPosted: Sun May 24, 2020 5:36 pm    Post subject: Reply with quote

Just tested this script and when i use !fml it answers with 0

Yep. That's a ZERO.

Not sure what the issue is.

Just noticed inside the eggdrop when i logged in, that it is spitting this out.

FML Error: error flushing "sock2bf05e0": connection reset by peer

UPDATE : Ok Now. Updating To 19.10 Linux has cured whatever issue it had.
Back to top
View user's profile Send private message
TimeRider
Voice


Joined: 07 Jul 2020
Posts: 27

PostPosted: Mon Dec 26, 2022 11:24 am    Post subject: Reply with quote

This script isn't working anymore again. Does anybody have a solution or a working TCL script for it?
_________________
Online chat
Nepal chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
heartbroken
Op


Joined: 23 Jun 2011
Posts: 110
Location: somewhere out there

PostPosted: Mon Dec 26, 2022 12:41 pm    Post subject: Reply with quote

need to update that line:
Code:
foreach {null data} [regexp -all -inline {block hidden\-xs\">.+?<a href=\"/article/today.+?.html\">(.*?)</a>} $html] {

to this one:
Code:
foreach {null data} [regexp -all -inline {hidden="true">.+?<a href="/article/.+?.html".+?>(.*?)</a>} $html] {

_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
TimeRider
Voice


Joined: 07 Jul 2020
Posts: 27

PostPosted: Mon Dec 26, 2022 1:33 pm    Post subject: Reply with quote

Thank you heartbroken, the Tcl script works now! Smile
_________________
Online chat
Nepal chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
vam2u
Voice


Joined: 27 Mar 2021
Posts: 30
Location: Malaysia

PostPosted: Sun Apr 23, 2023 11:39 am    Post subject: Reply with quote

I need help, it shows below error:-

[09:39:17] Tcl error [fml_pubin]: invalid command name " "
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 110
Location: somewhere out there

PostPosted: Sun Apr 23, 2023 2:32 pm    Post subject: Reply with quote

I've just tested and :


it is still working fine... possibly a copy-paste failor from your side. or may be you are using a txt editor which doesn't have Tcl support . like Windows notepad.
_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
vam2u
Voice


Joined: 27 Mar 2021
Posts: 30
Location: Malaysia

PostPosted: Mon Apr 24, 2023 5:10 am    Post subject: Reply with quote

Looks like the text editor is the culprit, but I observed some other issue.
It does not happen consistantly. Only sometimes as below.

[17:05:36] <Bot> </h2> <div class="flex justify-between"> <p class="text-blue-300 dark:text-white text-sm mt-2"> By kay-z <i class="fa fa-female" aria-hidden="true"></i> - 21/06/2014 20:32 - United States </p> </div> </div> </div> <a href="/article/miscommunication_136227.html" class="block text-blue-500 dark:text-white my-4 "> Today, my dad heard that the guy who bullied me at school died recently of a drug overdose. For some reason, he thinks we wer
[17:05:47] <@me> !fml
[17:05:48] <bot> Today, while I was in the break room at work, one of my coworkers walked in on me playing with my animal crackers, complete with animal noises. Now, the entire department won't stop teasing me and calling me Tarzan. FML
[17:05:55] <@me> !fml
[17:05:58] <bot> Today, my college basketball team Florida Atlantic University was winning 71-70 against San Diego State University. San Diego State scored a 2 pointer at the very last second of the second half of the game making us lose 71-72. FML
[17:06:00] <@me> !fml
[17:06:02] <bot> </h2> <div class="flex justify-between"> <p class="text-blue-300 dark:text-white text-sm mt-2"> By Olivia23 <i class="fa fa-female" aria-hidden="true"></i> - 08/07/2021 11:00 </p> </div> </div> </div> <a href="/article/dick_357500.html" class="block text-blue-500 dark:text-white my-4 spicy-hidden"> Today, my husband threw an epic temper tantrum because I wouldn’t have sex with him. I recently suffered from a miscarriage and the th
Back to top
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 110
Location: somewhere out there

PostPosted: Tue Apr 25, 2023 9:45 am    Post subject: Reply with quote

Code:
package require http
package require tls
package require htmlparse

 proc do_fml {} {
    if {[package vcompare [package present tls] 1.7] > 0} {
       ::http::register https 443 [list ::tls::socket -autoservername true]
    } else {
       ::http::register https 443 [list ::tls::socket -request 0 -require 1 -ssl2 0 -ssl3 0 -tls1 1]
    }
    ::http::config -useragent "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e" -urlencoding "utf-8"
    if {[catch {set token [http::geturl https://www.fmylife.com/random -binary 0 -timeout 15000]} err]} {
       putlog "FML Error: $err"
    }
    if {[http::status $token] eq "ok" && [http::ncode $token] == "200"} {
       set html [http::data $token]
       ::http::cleanup $token
       set out [list ]
       foreach {null data} [regexp -all -inline {<a href="/article/.+?.html".+?>(.*?)</a>} $html] {
          regsub -all -- {(<[^<>]+/>)} $data "" data
          regsub -all {FML} $data \00304\002\\0\003 data
          lappend out [split [string trim $data]]
       }
       set fmlout [lindex $out [expr {int(rand()*[llength $out])}]]
    } else {
       set fmlout "FML Error: [http::status $token] - [http::code $token]"
       ::http::cleanup $token
    }
    ::http::unregister https
    return [string trimleft [regsub -all -- {(</h2>.+?my\-4.+?>)} $fmlout {}] \}]
 }

 bind pub -|- !fml fml_pubin

 proc fml_pubin {nick uhost hand chan text} {
    if {![channel get $chan FML]} { return 0 }
    puthelp "PRIVMSG $chan :[join [htmlparse::mapEscapes [do_fml]]]"
 }

 setudef flag FML

_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber