Simple FML Script.
Disclaimer:
The parser used to retrieve data from is property of RuneScript. I do not own the parser or the bot.
Their parser. My script.
(09:18:00 PM) (@Trev) !fml
(09:18:02 PM) —› (Notice:) -W|R|I|S|T- (Random FML™) Today, my boyfriend broke up with me. He said I was way too good at sex so I must have lied about not having much experience, and he "wouldn't be with someone who is hiding something." WTF? FML
Alias c1 return $+($chr(3),01,$1-)
Alias c2 return $+($chr(3),02,$1-)
Alias lg return $+($c1($chr(40)),$c2($1),$c1($chr(153)),$c1($chr(41)))
On $*:Text:/^[!.@]FML/Si:#: {
sockopen FML. rscript.org 80
set %fml.temp $iif($mid($1,1,1) == $chr(64),msg #,.notice $nick)
}
On *:SOCKOPEN:FML.: {
sockwrite -n $sockname GET /lookup.php?type=fml HTTP/1.1
sockwrite -n $sockname Host: rscript.org
sockwrite -n $sockname $crlf
}
On *:SOCKREAD:FML.: {
if ($sockerr) { halt }
Else {
var %fml
sockread %fml
if (Text:* iswm %fml) {
tokenize 32 %fml
set %fml.text $cc2($2-)
%fml.temp $lg(Random FML) %fml.text
unset %fml.*
sockclose FML.
}
}
}
Does anyone know how to modify this script so that it is triggered by !fml just like this one and not a /command
;;; Aliases needed for colouring. Changing colour by changing "$Chr(3),12,$Chr(2)" to "Chr(3),,$Chr(2)" $h is the main colour, $hh is the secondary colour.
alias h { return $+($chr(3),12,$chr(2),$chr(2),$1-,$chr(3),$chr(2),$chr(2)) }
alias hh { return $+($chr(3),14,$chr(2),$chr(2),$1-,$chr(3),$chr(2),$chr(2)) }
Alias Tags { Return $+($hh([),$h($1-),$hh(]) $hh(—),$h(>),) }
;;;
alias FML {
if ($Sock(FML)) { SockClose FML }
Set %FMLOut $iif($1 = -s, Say, Echo -a)
Sockopen FML rscript.org 80
}
On :SockOpen:FML: {
Sockwrite -nt FML GET /lookup.php?type=fml
SockWrite -nt FML Host: rscript.org
SockWrite -nt FML $crlf
}
on :SockRead:FML: {
if ($SockErr) { SockClose FML | SockOpen FML rscript.org 80 }
Var %FML
SockRead %FML
if ($Regex(%FML,ID:)) { Set %FMLID $GetTok(%FML,2-,32) }
if ($Regex(%FML,Cate:)) { Set %FMLCate $GetTok(%FML,2-,32) }
if ($Regex(%FML,Text:)) { Set %FMLText $hh($GetTok(%FML,2-,32)) }
if ($Regex(%FML,Agree:)) { Set %FMLAggree $Bytes($GetTok(%FML,2-,32),bd) }
if ($Regex(%FML,Deserved:)) { Set %FMLDisaggree $Bytes($GetTok(%FML,2-,32),bd) }
if ($Regex(%FML,Comments:)) { Set %FMLComments $Bytes($GetTok(%FML,2-,32),bd) }
if ($Regex(%FML,END)) { SockClose FML }
if (!$Sock(FML)) {
%FMLOut $Tags(FML) $hh(FML:) $h(%FMLText)
Echo -a $Tags(FML) $hh(Information:) $hh(Agreed:) $h(%FMLAggree) $hh($(|)) $hh(Deserved) $h(%FMLDisaggree) $hh($(|)) $hh(Comments:) $h(%FMLComments)
Echo -a $Tags(FML) $hh(Link:) $h($+(,http://www.fmylife.com,/,%FMLCate,/,%FMLID,/,))
Unset %FML*
}
}
The fml script stopped working since yesterday.
I guess its cause the adress "http://www.rscript.org/lookup.php?type=fml" ain't up and running anymore?!
the fml didn't work for me so i looked at the th script and i add www. to the fml script :
On $:Text:/^([!.@])FML$/Si:#:{
if ($sock(FML.)) sockclose $v1
sockopen FML. www.rscript.org 80
sockmark FML. $iif($regml(1) = @,.msg #,.notice $nick)~$&
$+($chr(3),1,$chr(40),$chr(3),2,Random FML™,$chr(3),1,$chr(41))
}
On :SOCKOPEN:FML.:{
sockwrite -n $sockname GET /lookup.php?type=fml HTTP/1.1
sockwrite -n $sockname Host: rscript.org $+ $str($crlf,2)
}
On :SOCKREAD:FML.:{
if (!$sockerr) {
var %fml | sockread %fml
if (Text: iswm %fml) {
$gettok($sock(FML.).mark,1,126) $&
$replace($v2,Text:,$gettok($sock(FML.).mark,2,126))
sockclose FML.
}
}
}
b0sse, that website's source code is different from the original one. Here is the working modification:
on $*:text:/^([!.@])TH$/Si:#:{
if (!%pro) { inc -u4 %pro | if ($sock(TH.)) sockclose $v1
sockopen TH. www.thathigh.com 80
sockmark TH. $iif($regml(1) = !,msg #,notice $nick)~$&
$+($chr(3),1,$chr(40),$chr(3),2,Random ThatHigh™,$chr(3),1,$chr(41))
}
}
On *:SOCKOPEN:TH.:{
if (!$sockerr) {
sockwrite -n $sockname GET /random/ HTTP/1.1
sockwrite -n $sockname Host: $sock(TH.).addr $+ $str($crlf,2)
}
}
On *:SOCKREAD:TH.:{
if (!$sockerr) {
var %TH | sockread %TH | if (storylink isin %TH) {
tokenize 62 $remove($v2,<a class=" $+ $v1 $+ " href="//",</a)
$gettok($sock(TH.).mark,1,126) $* | sockclose $sockname
}
}
}
thanks, Jethro_
your version works great.
I changed it so that the !fml is the msg one, and the @fml and .fml are the notices ones though.
by the way, I tried to modify your code to work with thathigh.com, but couldnt get it to work. Can you help me out? I just changed all the FML to TH, and added the adress to thathigh.com and the /random etc.
On $*:Text:/^([!.@])TH$/Si:#:{
if ($sock(TH.)) sockclose $v1
sockopen TH. thathigh.com 80
sockmark TH. $iif($regml(1) = !,.msg #,.notice $nick)~$&
$+($chr(3),1,$chr(40),$chr(3),2,ThatHigh,$chr(3),1,$chr(41))
}
On *:SOCKOPEN:TH.:{
sockwrite -n $sockname GET /random HTTP/1.1
sockwrite -n $sockname Host: thathigh.com $+ $str($crlf,2)
}
On *:SOCKREAD:TH.:{
if (!$sockerr) {
var %th | sockread %th
if (Text:* iswm %th) {
$gettok($sock(TH.).mark,1,126) $&
$replace($v2,Text:,$gettok($sock(TH.).mark,2,126))
sockclose TH.
}
}
}
Np man... lol i never try make code short... i code to make it work.. no matter how it may look... if it works, its a script... on here i have seen people redo other peoples code in such a manner u have to really look at it to understand what it does now... but im not like that... i follow my protocols... im not a sheep :D
http://www.hawkee.com/snippet/6377/#c58744 he most likely forgot to re-add after an update
Trev's script could have been improved quite a bit without global vars and aliases:
On $*:Text:/^([!.@])FML$/Si:#:{
if ($sock(FML.)) sockclose $v1
sockopen FML. rscript.org 80
sockmark FML. $iif($regml(1) = @,.msg #,.notice $nick)~$&
$+($chr(3),1,$chr(40),$chr(3),2,Random FML™,$chr(3),1,$chr(41))
}
On *:SOCKOPEN:FML.:{
sockwrite -n $sockname GET /lookup.php?type=fml HTTP/1.1
sockwrite -n $sockname Host: rscript.org $+ $str($crlf,2)
}
On *:SOCKREAD:FML.:{
if (!$sockerr) {
var %fml | sockread %fml
if (Text:* iswm %fml) {
$gettok($sock(FML.).mark,1,126) $&
$replace($v2,Text:,$gettok($sock(FML.).mark,2,126))
sockclose FML.
}
}
}
Though a trigger protection is recommended.
Alias cc1 return $+($chr(3),10,$1-)
Alias cc2 return $+($chr(3),10,$1-)
Alias lg return ~4 $1 ~
On $*:TEXT:/^[!.@]fml/Si:#: {
sockopen FML. rscript.org 80
set %fml.temp $iif($mid($1,1,1) == $chr(64),msg #,msg #)
}
On *:SOCKOPEN:FML.: {
sockwrite -n $sockname GET /lookup.php?type=fml HTTP/1.1
sockwrite -n $sockname Host: rscript.org
sockwrite -n $sockname $crlf
}
On *:SOCKREAD:FML.: {
if ($sockerr) { halt }
Else {
var %fml
sockread %fml
if (Text:* iswm %fml) {
tokenize 32 %fml
set %fml.text $2-
%fml.temp $lg(Fkuc My Life) %fml.text
unset %fml.*
sockclose FML.
}
}
}
just my own little spin on it... :D
DragonHeart.
To change the color of the outputs, using the alias I provided you simply need to change the number within the alias
I.E.
Alias cc1 return $+($chr(3),01,$1-)
Alias cc2 return $+($chr(3),02,$1-)
Alias lg return $+($cc1($chr(40)),$cc2($1 $+ $chr(153)),$cc1($chr(41)))
$chr(3),01 <- Change that number
replace line 10 with this and all works again
if $regex(%fml,/"fmllink">(.*?)) {