This is the new home of the egghelp.org community forum. 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!
			
		
				
			
				
								_niCk 							 
						Voice 			
		Posts:  4 Joined:  Mon Oct 08, 2018 10:20 amLocation:  [IN] 
		
						
					
													
							
						
									
						Post 
					 
								by _niCk  Mon Nov 19, 2018 5:33 pm 
			
			
			
			
			
			Greetings,
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								heartbroken 							 
						Op 			
		Posts:  110 Joined:  Thu Jun 23, 2011 11:15 pmLocation:  somewhere out there 
		
						
					
						 
													
							
						
									
						Post 
					 
								by heartbroken  Tue Nov 20, 2018 7:37 am 
			
			
			
			
			
			.chanset #channel +FML
TclTLS : 
https://core.tcl.tk/tcltls/wiki/Download  (tls package)
tcllib : 
https://github.com/tcltk/tcllib  (htmlparse package)
Code: Select all 
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.
					Last edited by 
heartbroken  on Wed Nov 21, 2018 8:08 am, edited 2 times in total.
									
Life iS Just a dReaM oN tHE wAy to DeaTh
			
						 
		 
				
		
		 
	 
				
		
				
			
				
								_niCk 							 
						Voice 			
		Posts:  4 Joined:  Mon Oct 08, 2018 10:20 amLocation:  [IN] 
		
						
					
						 
													
							
						
									
						Post 
					 
								by _niCk  Tue Nov 20, 2018 4:57 pm 
			
			
			
			
			
			Thank you for the script, heartbroken. 
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 
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
 
		 
				
		
		 
	 
				
		
				
			
				
								heartbroken 							 
						Op 			
		Posts:  110 Joined:  Thu Jun 23, 2011 11:15 pmLocation:  somewhere out there 
		
						
					
						 
													
							
						
									
						Post 
					 
								by heartbroken  Wed Nov 21, 2018 8:05 am 
			
			
			
			
			
			I've edited the script above. You're welcome!
			
			
									
						
							Life iS Just a dReaM oN tHE wAy to DeaTh
			
						 
		 
				
		
		 
	 
				
		
				
			
				
								Dominatez 							 
						Halfop 			
		Posts:  50 Joined:  Mon Jan 14, 2019 5:08 pmLocation:  United Kingdom 
		
						
					
						 
													
							
						
									
						Post 
					 
								by Dominatez  Mon May 27, 2019 4:49 pm 
			
			
			
			
			
			This for some odd reason was working and now has stopped.
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								heartbroken 							 
						Op 			
		Posts:  110 Joined:  Thu Jun 23, 2011 11:15 pmLocation:  somewhere out there 
		
						
					
						 
													
							
						
									
						Post 
					 
								by heartbroken  Mon May 27, 2019 6:29 pm 
			
			
			
			
			
			just replace :
Code: Select all 
foreach {null data} [regexp -all -inline {block hidden\-xs\">.+?<a href=\"/article/today.+?.html\">(.*?)</a>} $html] {
to:
Code: Select all 
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
			
						 
		 
				
		
		 
	 
				
		
				
			
				
								Dominatez 							 
						Halfop 			
		Posts:  50 Joined:  Mon Jan 14, 2019 5:08 pmLocation:  United Kingdom 
		
						
					
						 
													
							
						
									
						Post 
					 
								by Dominatez  Fri May 31, 2019 5:50 am 
			
			
			
			
			
			Thank you Heartbroken.
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								Dominatez 							 
						Halfop 			
		Posts:  50 Joined:  Mon Jan 14, 2019 5:08 pmLocation:  United Kingdom 
		
						
					
						 
													
							
						
									
						Post 
					 
								by Dominatez  Sun May 24, 2020 5:36 pm 
			
			
			
			
			
			Just tested this script and when i use !fml it answers with 0
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								TimeRider 							 
						Voice 			
		Posts:  32 Joined:  Tue Jul 07, 2020 3:46 pm
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by TimeRider  Mon Dec 26, 2022 11:24 am 
			
			
			
			
			
			This script isn't working anymore again. Does anybody have a solution or a working TCL script for it?
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								heartbroken 							 
						Op 			
		Posts:  110 Joined:  Thu Jun 23, 2011 11:15 pmLocation:  somewhere out there 
		
						
					
						 
													
							
						
									
						Post 
					 
								by heartbroken  Mon Dec 26, 2022 12:41 pm 
			
			
			
			
			
			need to update that line:
Code: Select all 
foreach {null data} [regexp -all -inline {block hidden\-xs\">.+?<a href=\"/article/today.+?.html\">(.*?)</a>} $html] { 
to this one:
Code: Select all 
foreach {null data} [regexp -all -inline {hidden="true">.+?<a href="/article/.+?.html".+?>(.*?)</a>} $html] { Life iS Just a dReaM oN tHE wAy to DeaTh
			
						 
		 
				
		
		 
	 
				
		
				
			
				
								TimeRider 							 
						Voice 			
		Posts:  32 Joined:  Tue Jul 07, 2020 3:46 pm
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by TimeRider  Mon Dec 26, 2022 1:33 pm 
			
			
			
			
			
			Thank you heartbroken, the Tcl script works now! 
 
		 
				
		
		 
	 
				
		
				
			
				
								vam2u 							 
						Voice 			
		Posts:  35 Joined:  Sat Mar 27, 2021 11:19 pmLocation:  Malaysia 
		
						
					
						 
													
							
						
									
						Post 
					 
								by vam2u  Sun Apr 23, 2023 11:39 am 
			
			
			
			
			
			I need help, it shows below error:-
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								heartbroken 							 
						Op 			
		Posts:  110 Joined:  Thu Jun 23, 2011 11:15 pmLocation:  somewhere out there 
		
						
					
						 
													
							
						
									
						Post 
					 
								by heartbroken  Sun Apr 23, 2023 2:32 pm 
			
			
			
			
			
			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
			
						 
		 
				
		
		 
	 
				
		
				
			
				
								vam2u 							 
						Voice 			
		Posts:  35 Joined:  Sat Mar 27, 2021 11:19 pmLocation:  Malaysia 
		
						
					
						 
													
							
						
									
						Post 
					 
								by vam2u  Mon Apr 24, 2023 5:10 am 
			
			
			
			
			
			Looks like the text editor is the culprit, but I observed some other issue.
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
				
			
				
								heartbroken 							 
						Op 			
		Posts:  110 Joined:  Thu Jun 23, 2011 11:15 pmLocation:  somewhere out there 
		
						
					
						 
													
							
						
									
						Post 
					 
								by heartbroken  Tue Apr 25, 2023 9:45 am 
			
			
			
			
			
			Code: Select all 
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