Top

Metal Gear Solid (1-4) Memorable Quotes


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  6.3 (of 3 scores)
Date Added  May 07, 2009
Last Updated  May 07, 2009
Tags  gear  kirby  memorable  metal  mgs  mirc  quotes  solid 

Introduction

Just a small socket bot script I whipped up, mainly focusing on more regex and some hash tables.
This script just gets a random memorable quote from one of the four pages on IMDb.


If you played the Metal Gear Solid series, you'd probably be familiar with these quotes...

Syntax: .mgs <1 ~ 4>

* The number represents the game number in the whole series.


Here's a picture for those with good eye sight:


Here's a picture for those who are blind:


Enjoy! :D

Grab the Code

#MGS On
on $*:text:/^[.!@]mgs*/Si:#: {
  if ($2 !isnum 1-4) .notice $nick Syntax: $1 <1 ~ 4>
  elseif ($2 isnum 1-4) && (!$sock(mgs)) {
    sockopen mgs www.imdb.com 80
    sockmark mgs # $2 $iif($2 == 1,$r(1,96) tt0180825,$iif($2 == 2,$r(1,140) tt0249008,$iif($2 == 3,$r(1,79) tt0365498,$iif($2 == 4,$r(1,36) tt0462423)))))
  }
}
#MGS End
menu * {
  $iif($group(#MGS) == On,$style(1)) Metal Gear Solid Memorable Quotes
  .$iif($group(#MGS) == On,$style(2)) On: .enable #MGS
  .$iif($group(#MGS) == Off,$style(2)) Off: .disable #MGS
}
on *:sockopen:mgs: {
  sockwrite -n $sockname GET $+(/title/,$gettok($sock(mgs).mark,4,32),/quotes) HTTP/1.0
  sockwrite -n $sockname Host: www.imdb.com
  sockwrite -n $sockname $crlf
}
on *:sockread:mgs: {
  sockread %mgs
  if ($regex(%mgs,<a name="qt[\d]+"></a>)) {
    hinc -m MGS 1
    if ($hget(MGS,1) == $gettok($sock(mgs).mark,3,32)) {
      while (!$regex(%mgs,<hr width="30%">)) {
        sockread %mgs
        if ($regex(%mgs,<b><a href="/name/.*/">(.*)</a></b>:|<b>(.*)</b>:)) {
          hinc -m MGS 2 | hadd -m MGS_Quotes $hget(MGS,2) $+(<,$gettok(~.&.@.%.+.,$r(1,5),46),$regml(1),>)
          sockread %mgs
          hinc -m MGS 2 | hadd -m MGS_Quotes $hget(MGS,2) $regsubex(%mgs,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null)
        }
      }
    }
  }
  elseif ($regex(%mgs,<title>.*:(.*) \([\d]+\)|<title>(.*) \([\d]+\))) hadd -m MGS Name $regml(1)
}
on *:sockclose:mgs: {
  tokenize 32 $sock(mgs).mark
  var %x 1, %y $hget(MGS_Quotes,0).item | $iif(%y > 2,msg $1 $+([Metal Gear Solid ,$2, - $qt($hget(MGS,Name)) Quote]:))
  while (%x <= %y) { msg $1 $iif(%y <= 2,$+([,$qt($hget(MGS,Name)) Quote]:)) $hget(MGS_Quotes,%x) $hget(MGS_Quotes,$calc(%x + 1)) | inc %x 2 }
  hfree -w MGS* | unset %mgs
}

Comments

  (8)  RSS
Kirby
Comments: 475
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 7, 2009 12:26 am
I tried to make the quotes look IRC-like, but it seems it doesn't work that way. :D

LAUGH ALL YOU WANT NEMESIS!!! ;]
Jethro_
Comments: 437
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 7, 2009 1:36 am
Gee, I love playing metal gear solid 4! I can't wait for the series 5 to come out in the future. It's the best stealth game ever!
Kirby
Comments: 475
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 7, 2009 6:14 am
Haha, same. :D
jonesy44
Comments: 1,856
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 7, 2009 1:52 pm
Why the second sockread %mgs?
Kirby
Comments: 475
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 7, 2009 2:53 pm
jonesy44 said:
Quote:
Why the second sockread %mgs?


I need the second sockread %mgs because that is used to get the actual quote itself.

Let's take
Code:
<b><a href="/name/nm0371684/">Solid Snake</a></b>:
This reminds me of when we first met.
<br>
for instance.

Code:
        if ($regex(%mgs,<b><a href="/name/.*/">(.*)</a></b>:|<b>(.*)</b>:)) {
gets the person who said the quote from the <b><a href="/name/nm0371684/">Solid Snake</a></b>: part, and then after that, I need to get the actual quote itself. By using sockread again, I can get the next line, which contains the quote.

Hope this clarifies your question.
bone282
Comments: 31
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 7, 2009 8:06 pm
is there no \r \n in mirc regex?
Jethro_
Comments: 437
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 8, 2009 2:37 am
\n = Matches a new line

\r = Carriage return

Below is an example:
Text: an anaconda ate Anna Jones
Regex: \w+\r\n
Match: ate

Depending on your operating system you might have to combine the \r and \n character escapes to create the correct new line sequence for your platform. For Microsoft Windows systems you should generally use \r\n which is a carriage return then line feed (CRLF). To simply match the end of a line or string use the dollar sign ($).

Souce: from from what I read about Regex.
jonesy44
Comments: 1,856
 
mIRC Snippet:  Metal Gear Solid (1-4) Memorable Quotes
Posted on May 8, 2009 12:19 pm
ahh i see! very nice :)

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom