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 

Ramdom quote from fmylife.com
Goto page 1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
liljim
Voice


Joined: 11 Dec 2007
Posts: 12

PostPosted: Thu Feb 05, 2009 4:01 pm    Post subject: Ramdom quote from fmylife.com Reply with quote

Could someone make a script that pulls a random quote from http://www.fmylife.com/random with a trigger? Perhaps even show the ratings (I agree, your life is f***ed and you deserved that one) along with the post number, though a simple random quote would be cool. Or if you want to get complex maybe a search based on keywords.

I guess it's similar to grouphug.us but even more embarrassing. If anyone feels like giving it a go I'd be grateful.
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Mon Mar 02, 2009 3:46 pm    Post subject: Reply with quote

I hope someone can help looks like great quotes Smile
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Tue Mar 03, 2009 7:56 am    Post subject: Reply with quote

try:
Code:
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !fmylife
set fmylife_channels {#channel1 #channel2}

# time between use !fmylife (seconds)
set fmylife_reuse_time 20

###########################################################
bind pub - !fmylife fm_main_proc

package require http

proc get_fmylife { } {
   set f_http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
   set f_http_token [http::config -useragent $f_http_uagent]
   if {[catch {set f_http_token [::http::geturl "http://www.fmylife.com/random" -timeout 10000]}]} {
      return "error"
   } {
      return [http::data $f_http_token]
   }
}

set fmylife_reuse 1

proc fm_main_proc { nick uhost hand chan arg } {
   global fmylife_channels fmylife_reuse fmylife_reuse_time

        if {[expr [clock seconds] - $fmylife_reuse] <= $fmylife_reuse_time} {
      putquick "PRIVMSG $chan :$nick: to fast, sorry"
      return
   }

   if {[lsearch $fmylife_channels $chan] == -1} {
           return
   }

   set fm_quote ""
   set fm_link ""

   set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putquick "PRIVMSG $chan :problem with connection, try again later, sorry"
      return
   }

   regsub -all -nocase "\n" $fm_quote "" fm_quote
   regsub -all -nocase "\r" $fm_quote "" fm_quote
   regsub -all -nocase "\t" $fm_quote "" fm_quote

   # 1st quote
   regsub -nocase {.*<div\s+class=\"post\"><p>(.+)</p><div\s+class=\"date\"\s+style=\"float:left;\">.*} $fm_quote {\1} fm_quote

   # 1st link
   regsub -nocase {.*<a\s+href=\"([a-z0-9\/ ]+)\"\s+class=\"fmllink\">.*} $fm_quote {\1} fm_link

   # del rest of links from quote
   regsub -all -nocase {<a\s+href=\"[a-z0-9\/ ]+\"\s+class=\"fmllink\">} $fm_quote "" fm_quote

   # the rest of useless tags
   regsub -all -nocase "<\/a>" $fm_quote "" fm_quote

   set fm_link "http://www.fmylife.com$fm_link"

   if {[regexp -nocase {http:\/\/www\.fmylife\.com[a-z0-9\/ ]+} $fm_link]} {
      putquick "PRIVMSG $chan :$fm_quote"
      putquick "PRIVMSG $chan :--| $fm_link"
      set fmylife_reuse [clock seconds]
   } {
      putquick "PRIVMSG $chan :some problem with data, try again later, sorry"
   }
}

putlog "fmylife-quote.tcl ver 0.1 by tomekk loaded"



use: !fmylife on chan

cheers
Back to top
View user's profile Send private message Visit poster's website
liljim
Voice


Joined: 11 Dec 2007
Posts: 12

PostPosted: Tue Mar 03, 2009 9:19 pm    Post subject: Reply with quote

This works well. Thank you very much!
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Wed Mar 04, 2009 7:06 am    Post subject: Reply with quote

Hi tomekk, can i request this script will advertise the quotes on main channel every 30 minutes without typing !fmylife .. thanks a lot in advance Very Happy
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Mar 05, 2009 7:09 am    Post subject: Reply with quote

Code:
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !fmylife
set fmylife_channels {#channel #channel2}

# time between use !fmylife (seconds)
set fmylife_reuse_time 20

# auto query
# 0 - off, 1 - on
set fmylife_auto_query 0

# set auto query interval (minutes)
set fmylife_auto_interval 30

###########################################################
bind pub - !fmylife fm_main_proc

package require http

proc get_fmylife { } {
   set f_http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
   set f_http_token [http::config -useragent $f_http_uagent]
   if {[catch {set f_http_token [::http::geturl "http://www.fmylife.com/random" -timeout 10000]}]} {
      return "error"
   } {
      return [http::data $f_http_token]
   }
}

set fmylife_reuse 1

proc fmylife_timer { } {
   global fmylife_auto_interval
   fm_auto_proc

   if {[string match *fmylife_timer* [timers]] != 1} {
      timer $fmylife_auto_interval fmylife_timer
   }
}

proc fm_auto_proc { } {
   global fmylife_channels

   set fm_quote ""
        set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putlog "auto-quote-fmylife: problem with connection"
      return
   }

   foreach fm_each_chan [split $fmylife_channels] {
      if {$fm_each_chan != ""} {
         set fm_each_chan [string trim $fm_each_chan]

         if {[botonchan $fm_each_chan]} {
             fmylife_print $fm_quote $fm_each_chan
         }
      }
   }
}

proc fm_main_proc { nick uhost hand chan arg } {
   global fmylife_channels fmylife_reuse fmylife_reuse_time

   if {[expr [clock seconds] - $fmylife_reuse] <= $fmylife_reuse_time} {
      putquick "PRIVMSG $chan :$nick: to fast, sorry"
      return
   }

   if {[lsearch $fmylife_channels $chan] == -1} {
      return
   }

   set fm_quote ""
   set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putquick "PRIVMSG $chan :problem with connection, try again later, sorry"
      return
        }

   fmylife_print $fm_quote $chan
}

proc fmylife_print { fm_data fm_chan } {
   set fm_link ""

   regsub -all -nocase "\n" $fm_data "" fm_data
   regsub -all -nocase "\r" $fm_data "" fm_data
   regsub -all -nocase "\t" $fm_data "" fm_data

   # 1st quote
   regsub -nocase {.*<div\s+class=\"post\"><p>(.+)</p><div\s+class=\"date\"\s+style=\"float:left;\">.*} $fm_data {\1} fm_data

   # 1st link
   regsub -nocase {.*<a\s+href=\"([a-z0-9\/ ]+)\"\s+class=\"fmllink\">.*} $fm_data {\1} fm_link

   # del rest of links from quote
   regsub -all -nocase {<a\s+href=\"[a-z0-9\/ ]+\"\s+class=\"fmllink\">} $fm_data "" fm_data

   # the rest of useless tags
   regsub -all -nocase "<\/a>" $fm_data "" fm_data

   set fm_link "http://www.fmylife.com$fm_link"

   if {[regexp -nocase {http:\/\/www\.fmylife\.com[a-z0-9\/ ]+} $fm_link]} {
      putquick "PRIVMSG $fm_chan :$fm_data"
      putquick "PRIVMSG $fm_chan :--| $fm_link"
      set fmylife_reuse [clock seconds]
   } {
      putquick "PRIVMSG $fm_chan :some problem with data, try again later, sorry"
   }
}

if {$fmylife_auto_query != 0} {
   if {[string match *fmylife_timer* [timers]] != 1} {
      timer $fmylife_auto_interval fmylife_timer
   }
}

putlog "fmylife-quote.tcl ver 0.2 by tomekk loaded"


test it
Back to top
View user's profile Send private message Visit poster's website
manipulativeJack
Voice


Joined: 17 Feb 2009
Posts: 13

PostPosted: Thu Mar 05, 2009 3:36 pm    Post subject: Reply with quote

Nice!

Would you mind if I try to use some of this code to /try/ to create the
script I was requesting in http://forum.egghelp.org/viewtopic.php?t=16672 - I am not sure how to do the requesting part but this should work for the displaying part!

Jack
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Mar 05, 2009 4:20 pm    Post subject: Reply with quote

sure, go on Wink

good luck !
Back to top
View user's profile Send private message Visit poster's website
manipulativeJack
Voice


Joined: 17 Feb 2009
Posts: 13

PostPosted: Thu Mar 05, 2009 5:55 pm    Post subject: Reply with quote

I give up! If you get bored take a look at my request Very Happy

Either way thanks for this cool little snippet.
Back to top
View user's profile Send private message
wac
Halfop


Joined: 10 Dec 2006
Posts: 80
Location: in my cardboard box

PostPosted: Wed Mar 11, 2009 4:31 am    Post subject: Reply with quote

script works like a charm, thanks!
_________________
I see j00!
Back to top
View user's profile Send private message
Globulus
Voice


Joined: 20 Mar 2009
Posts: 8

PostPosted: Fri Mar 20, 2009 1:20 pm    Post subject: Reply with quote

Fixed cooldown that doesn't works, uploaded on tcl archive but not yet visible.

Code:

# Author: tomekk modiffied by Globulus
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.3
#
# This Script extract quotes from http://www.fmylife.com/random
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !fml
set fmylife_channels {#channel #channel2}

# time between use !fml (seconds)
set fmylife_reuse_time 5

# auto query
# 0 - off, 1 - on
set fmylife_auto_query 0

# set auto query interval (minutes)
set fmylife_auto_interval 30

###########################################################
bind pub - !fml fm_main_proc

package require http

proc get_fmylife { } {
   set f_http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
   set f_http_token [http::config -useragent $f_http_uagent]
   if {[catch {set f_http_token [::http::geturl "http://www.fmylife.com/random" -timeout 10000]}]} {
      return "error"
   } {
      return [http::data $f_http_token]
   }
}

proc fmylife_timer { } {
   global fmylife_auto_interval
   fm_auto_proc

   if {[string match *fmylife_timer* [timers]] != 1} {
      timer $fmylife_auto_interval fmylife_timer
   }
}

proc fm_auto_proc { } {
   global fmylife_channels

   set fm_quote ""
        set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putlog "auto-quote-fmylife: problem with connection"
      return
   }

   foreach fm_each_chan [split $fmylife_channels] {
      if {$fm_each_chan != ""} {
         set fm_each_chan [string trim $fm_each_chan]

         if {[botonchan $fm_each_chan]} {
             fmylife_print $fm_quote $fm_each_chan
         }
      }
   }
}

proc fm_main_proc { nick uhost hand chan arg } {
   global fmylife_channels fmylife_reuse fmylife_reuse_time

      #Open file and read the variable
      if { [file exists FMLClockFile] == 1 } {

          set FileHandle [open FMLClockFile "r"]
          set TempString [read $FileHandle]
          close $FileHandle
          set lines [split $TempString "\n"]

          set fmylife_reuse [lindex $lines 0]

      } else {

          # Set the last clock to 1 initially
          set fmylife_reuse 1
      }


   if {[expr [clock seconds] - $fmylife_reuse] <= $fmylife_reuse_time} {
      putquick "NOTICE $nick : need to wait [expr [clock seconds] - $fmylife_reuse] sec before reusing..."
      return
   }

   if {[lsearch $fmylife_channels $chan] == -1} {
      return
   }

   set fm_quote ""
   set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putquick "PRIVMSG $chan :problem with connection, try again later, sorry"
      return
        }

   fmylife_print $fm_quote $chan
}

proc fmylife_print { fm_data fm_chan } {
   set fm_link ""

   regsub -all -nocase "\n" $fm_data "" fm_data
   regsub -all -nocase "\r" $fm_data "" fm_data
   regsub -all -nocase "\t" $fm_data "" fm_data

   # 1st quote
   regsub -nocase {.*<div\s+class=\"post\"><p>(.+)</p><div\s+class=\"date\"\s+style=\"float:left;\">.*} $fm_data {\1} fm_data

   # 1st link
   regsub -nocase {.*<a\s+href=\"([a-z0-9\/ ]+)\"\s+class=\"fmllink\">.*} $fm_data {\1} fm_link

   # del rest of links from quote
   regsub -all -nocase {<a\s+href=\"[a-z0-9\/ ]+\"\s+class=\"fmllink\">} $fm_data "" fm_data

   # the rest of useless tags
   regsub -all -nocase "<\/a>" $fm_data "" fm_data

   set fm_link "http://www.fmylife.com$fm_link"

   if {[regexp -nocase {http:\/\/www\.fmylife\.com[a-z0-9\/ ]+} $fm_link]} {
      putquick "PRIVMSG $fm_chan :$fm_data"
      putquick "PRIVMSG $fm_chan :--| $fm_link"
      set fmylife_reuse [clock seconds]

      # Write the variable to file (remember opening with 'w' mode truncates the file contents)
      set FileHandle [open FMLClockFile "w"]
      puts $FileHandle $fmylife_reuse
      close $FileHandle

   } {
      putquick "PRIVMSG $fm_chan :some problem with data, try again later, sorry"
   }
}

if {$fmylife_auto_query != 0} {
   if {[string match *fmylife_timer* [timers]] != 1} {
      timer $fmylife_auto_interval fmylife_timer
   }
}

putlog "fmylife-quote.tcl ver 0.3 by tomekk modified by Globulus loaded"

Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Fri Mar 20, 2009 5:15 pm    Post subject: Reply with quote

he he, thanks for "bug" raport Wink

after when i fixed it to ver 0.2 with auto-quote i forget to add back one global to proc:
Code:
global fmylife_reuse


here is fixed script, ver 0.2:

Code:
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !fmylife
set fmylife_channels {#chan #chan2}

# time between use !fmylife (seconds)
set fmylife_reuse_time 20

# auto query
# 0 - off, 1 - on
set fmylife_auto_query 0

# set auto query interval (minutes)
set fmylife_auto_interval 30

###########################################################
bind pub - !fmylife fm_main_proc

package require http

proc get_fmylife { } {
   set f_http_uagent "Opera/9.61 (Windows i686; U; en) Presto/2.1.1"
   set f_http_token [http::config -useragent $f_http_uagent]
   if {[catch {set f_http_token [::http::geturl "http://www.fmylife.com/random" -timeout 10000]}]} {
      return "error"
   } {
      return [http::data $f_http_token]
   }
}

set fmylife_reuse 1

proc fmylife_timer { } {
   global fmylife_auto_interval
   fm_auto_proc

   if {[string match *fmylife_timer* [timers]] != 1} {
      timer $fmylife_auto_interval fmylife_timer
   }
}

proc fm_auto_proc { } {
   global fmylife_channels

   set fm_quote ""
        set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putlog "auto-quote-fmylife: problem with connection"
      return
   }

   foreach fm_each_chan [split $fmylife_channels] {
      if {$fm_each_chan != ""} {
         set fm_each_chan [string trim $fm_each_chan]

         if {[botonchan $fm_each_chan]} {
             fmylife_print $fm_quote $fm_each_chan
         }
      }
   }
}

proc fm_main_proc { nick uhost hand chan arg } {
   global fmylife_channels fmylife_reuse fmylife_reuse_time

   if {[expr [clock seconds] - $fmylife_reuse] <= $fmylife_reuse_time} {
      putquick "PRIVMSG $chan :$nick: to fast, sorry"
      return
   }

   if {[lsearch $fmylife_channels $chan] == -1} {
      return
   }

   set fm_quote ""
   set fm_quote [get_fmylife]

   if {($fm_quote == "error") || ($fm_quote == "")} {
      putquick "PRIVMSG $chan :problem with connection, try again later, sorry"
      return
        }

   fmylife_print $fm_quote $chan
}

proc fmylife_print { fm_data fm_chan } {
   global fmylife_reuse

   set fm_link ""

   regsub -all -nocase "\n" $fm_data "" fm_data
   regsub -all -nocase "\r" $fm_data "" fm_data
   regsub -all -nocase "\t" $fm_data "" fm_data

   # 1st quote
   regsub -nocase {.*<div\s+class=\"post\"><p>(.+)</p><div\s+class=\"date\"\s+style=\"float:left;\">.*} $fm_data {\1} fm_data

   # 1st link
   regsub -nocase {.*<a\s+href=\"([a-z0-9\/ ]+)\"\s+class=\"fmllink\">.*} $fm_data {\1} fm_link

   # del rest of links from quote
   regsub -all -nocase {<a\s+href=\"[a-z0-9\/ ]+\"\s+class=\"fmllink\">} $fm_data "" fm_data

   # the rest of useless tags
   regsub -all -nocase "<\/a>" $fm_data "" fm_data

   set fm_link "http://www.fmylife.com$fm_link"

   if {[regexp -nocase {http:\/\/www\.fmylife\.com[a-z0-9\/ ]+} $fm_link]} {
      putquick "PRIVMSG $fm_chan :$fm_data"
      putquick "PRIVMSG $fm_chan :--| $fm_link"
      set fmylife_reuse [clock seconds]
   } {
      putquick "PRIVMSG $fm_chan :some problem with data, try again later, sorry"
   }
}

if {$fmylife_auto_query != 0} {
   if {[string match *fmylife_timer* [timers]] != 1} {
      timer $fmylife_auto_interval fmylife_timer
   }
}

putlog "fmylife-quote.tcl ver 0.2 by tomekk loaded"


Quote:
22:13:48 <@tomekk> !fmylife
22:13:48 < botty> tomekk: to fast, sorry


cheers !
Back to top
View user's profile Send private message Visit poster's website
Globulus
Voice


Joined: 20 Mar 2009
Posts: 8

PostPosted: Fri Mar 20, 2009 5:33 pm    Post subject: Reply with quote

Haha, my script works as well but not "proper" as yours.
Thanks for clean fixing and helping TCL newbie Very Happy
Back to top
View user's profile Send private message
arbiter
Voice


Joined: 24 Oct 2005
Posts: 8

PostPosted: Sat Mar 21, 2009 2:13 am    Post subject: Reply with quote

i prefer it when script's use udef triggers instead of a set line, makes it earlier to enable on channels rather then opening ftp and editing or "vi"
Back to top
View user's profile Send private message AIM Address MSN Messenger
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Sat Mar 21, 2009 10:31 am    Post subject: Reply with quote

Good day tomekk, can i request if these word FML on last part of the sentence at http://www.fmylife.com/ quotes can trim or hide so that it will not appear on channel trigger.. example like this:

Today, I got a letter from the Navy saying that they accepted my application to join the Navy. I never applied. FML

.. the bold one at the end.. thanks in advance Very Happy
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
Goto page 1, 2, 3, 4, 5, 6, 7  Next
Page 1 of 7

 
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