Random FML for eggdrop

By FordLawnmower on Jul 15, 2011

  • Requested by TwinShadow
    Returns a random quote from fmylife.com

Usage:

  • Copy this code and paste to a new file in wordpad or w/e not notepad
  • Save with a unique filename with the extension .tcl
  • Copy/Upload the .tcl file to your eggdrops scripts directory.
  • Add a line like this to your eggdrop.conf -:
source scripts/fml.tcl

Rehash or restart the eggdrop.
(In the Party Line) Type .chanset #ChannelName +fml
+/- fml as needed.

That's it. The script will respond to !fml in channels with the +fml flag.
See the top of the script to change the logo or text color.

SCREEN:
Image

##############################################################################################
##  ##     fml.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help          ##  ##
##############################################################################################
## To use this script you must set channel flag +fml (ie .chanset #chan +fml)               ##
##############################################################################################
##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
## Change fml_cmdchar to the character you want to use.                                     ##
set fml_cmdchar "!"
proc fml {nick host hand chan args} {
  if {[lsearch -exact [channel info $chan] +fml] != -1} {
## Change the characters between the "" below to change the logo shown with each result.    ##
    set fmllogo "\002\00301,11-FML-\002\003"
## Change the format codes between the "" below to change the color/state of the text.      ##
    set textf "\0034"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################  
    set fmlsite "www.fmylife.com"
    set fmlurl "/random"
    if {[catch {set fmlSock [socket -async $fmlsite 80]} sockerr]} {
      putserv "PRIVMSG $chan :$fmlsite $fmlurl $sockerr error"
      return 0
      } else {
      puts $fmlSock "GET $fmlurl HTTP/1.0"
      puts $fmlSock "Host: $fmlsite"
      puts $fmlSock ""
      flush $fmlSock
      while {![eof $fmlSock]} {
        set fmlvar " [gets $fmlSock] "
        if {[regexp {(Today.*?)FML<\/a>} $fmlvar match fmlresult]} {
          putserv "PRIVMSG $chan :${textf}[fmldehex [fmlstrip $fmlresult]] ${fmllogo}"
          close $fmlSock
          return 0
        }
      }
      close $fmlSock
      return 0 
    }
  }
}
proc fmlstrip {string} {
  regsub -all {<[^<>]+>} $string "" string
  return $string
}
proc fmldehex {string} {
  regsub -all {[\[\]]} $string "" string
  set string [subst [regsub -nocase -all {\&#([0-9]{2});} $string {[format %c \1]}]]
  return [string map {&quot; \"} $string]
}
bind pub - [string trimleft $fml_cmdchar]fml fml
setudef flag fml
putlog "\002*Loaded* \002\00301,11-FML-\002\003 \002Random by Ford_Lawnmower irc.GeekShed.net #Script-Help"

Comments

Sign in to comment.
xnite   -  Nov 09, 2017

The script doesn't work unless you change line 32 to read: if {[regexp {(Today.*?)FML} $fmlvar match fmlresult]} {

 Respond  
FordLawnmower   -  May 14, 2012

Looks good Hawkee :) Just in time , I had just noticed that it was effecting all of my socket script posts.
Thanks :)

 Respond  
Hawkee   -  May 14, 2012

@FordLawnmower I've corrected the problem with the &. Let me know if everything looks proper.

 Respond  
frederik   -  May 13, 2012

Perfect thank you FordLawnmower

all working :)

 Respond  
FordLawnmower   -  May 12, 2012

The google script has the same issue frederik.
Try getting it from here: http://pastebin.com/46NsLDJG

 Respond  
frederik   -  May 12, 2012

thanks its working really good now

have an other question for u on your advanced script google for tcl

i got this error

[16:10:15] [21:10:39] Tcl error [googleweb]: unmatched open quote in list

thanks

 Respond  
FordLawnmower   -  May 12, 2012

Thanks for the info frederik.
The problem here is that &quote; is being parsed for some reason even though it's inside the "codebox"
I've tested this on several browsers and it appears parsed to " on all of them.
I can't fix the code because it's not broken. When I go to edit it , the code is unparsed and correct.
Image

So for now just change line 50 from:

return [string map {" \"} $string]

to:

return [string map {&quote; \"} $string]
 Respond  
frederik   -  May 06, 2012

got the same problem
it always returns "unmatched open quote in list"

thanks

 Respond  
pawz   -  May 06, 2012

nevermind that. it was due to bad indenting when i pasted the text into a file. i pasted it via a proper text editor and the chanset works but now it always returns "unmatched open quote in list"

 Respond  
pawz   -  May 06, 2012

I can't use this on 1.6.21 ... when I try and do the .chanset it says "invalid mode".

 Respond  
Emo_Pikachu   -  Feb 06, 2012

I have no probs any more thanks

 Respond  
FollowTheSchism   -  Feb 06, 2012

@FordLawnmower -- Nice job here. I used it briefly on my Eggdrop before I accidentally rm -r'd my /var/lib/ on my VPS. It responded almost instantly, and the lag was due to the VPS restrictions, not your TCL.

 Respond  
FordLawnmower   -  Feb 04, 2012

@Emo_Pikachu I made a small change to the script. Please try the updated code and let me know if you still have a problem.
If you still have issues, please post back your eggdrop version, OS, and the line number of the error.

 Respond  
Emo_Pikachu   -  Feb 04, 2012

FordLawnmower i got this error msg on from my eggdrop bot Tcl error [fml]: wrong # args: should be "regsub ?switches? exp string subSpec varName"
do you think you can help with that?

 Respond  
FordLawnmower   -  Oct 29, 2011

Thanks itskamel :)
I didn't forget about the twitter one, I just got busy with a few other things.
I will message you when I post the update.

 Respond  
itskamel   -  Oct 29, 2011

nice script. its works flawless.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.