Daily Garfield

Here is room for additional scripts for Gamers.IRC.

You are highly advised to read the How-To first!
User avatar
Tuxman
Administrator
Posts: 1873
Joined: 24.10.2003 00:13
Status: That guy
Contact:

Daily Garfield

Unread postby Tuxman » 28.05.2011 21:10

This add-on displays a daily Garfield comic directly within mIRC. :)
You can make it show Sunday strips in a larger, dedicated frame by clicking it.

You will need the nconvert.exe file in the script directory. If you download the addon from within Gamers.IRC, it is included anyway.

Code: Select all

; Copyright © 2008-2018 by Gamers.Interactive. All Rights Reserved.
; Contact via world wide web (http://gamersirc.net) or e-mail (contact1@gamersirc.net)
; Feel free to modify and distribute this code as long as it fits to the GNU General Public License (http://gnu.org/licenses/gpl.html)
; which is included within Gamers.IRC.

; Forum: http://forum.gamersirc.net/viewtopic.php?f=34&t=1574


dialog dlgSonntag {
  title "Sunday Strip - xx.xx.xxxx"
  size -1 -1 625 456
  option pixels
  icon 1, 2 4 620 420
  button "Close", 2, 1 429 624 25, default flat ok cancel
}

on *:dialog:dlgSonntag:init:*:{
  did -g dlgSonntag 1 $qt($scriptdirgarfield.bmp)
  dialog -t dlgSonntag $replace($dialog(dlgSonntag).title,$gettok($dialog(dlgSonntag).title,4,32),$+($gettok($did(dlgGarfield,3).text,1,47),.,$gettok($did(dlgGarfield,3).text,2,47),.,$gettok($did(dlgGarfield,3).text,3,47)))
}

alias -l grfSonntag {
  if ($dialog(dlgSonntag)) {
    did -g dlgSonntag 1 $qt($scriptdirgarfield.bmp)
    dialog -t dlgSonntag $replace($dialog(dlgSonntag).title,$gettok($dialog(dlgSonntag).title,4,32),$+($gettok($did(dlgGarfield,3).text,1,47),.,$gettok($did(dlgGarfield,3).text,2,47),.,$gettok($did(dlgGarfield,3).text,3,47)))
  }
  else {
    dialog -md dlgSonntag dlgSonntag
  }
}

; ========================================

dialog dlgGarfield {
  title "Daily Garfield"
  size -1 -1 632 246
  option pixels
  icon 1, 6 23 620 195
  text "Daily Garfield - xx.xx.xxxx:", 2, 6 4 226 16
  edit "", 3, 123 222 200 21
  text "Date (dd/mm/yyyy):", 4, 6 225 113 16
  button "View comic", 5, 325 223 84 20, default flat
  button "<", 6, 586 223 20 20, flat
  button ">", 7, 607 223 20 20, flat
  button "close", 8, 551 1 75 20, flat ok
  button "visit website", 9, 464 1 85 20, flat
  text "Status", 11, 280 3 195 16, center
  link "view online", 12, 440 226 76 16
}

alias -l grfShow {
  if ($sock(scGarfield)) { sockclose scGarfield }
  set -u20 %grfStartFile 0
  .timer 1 1 did -ra dlgGarfield 2 $replace($did(dlgGarfield,2).text,$gettok($did(dlgGarfield,2).text,4,32),$+($gettok(%grfDate,1,47),.,$gettok(%grfDate,2,47),.,$gettok(%grfDate,3,47))) $+ :
  if ($exists($qt($scriptdirgarfield.gif))) { .remove $qt($scriptdirgarfield.gif) }
  did -ra dlgGarfield 11 ... downloading ...
  sockopen -e scGarfield d1ejxu6vysztl5.cloudfront.net 443
}

alias -l grfCheckDate {
  return $regex($did(dlgGarfield,3).text, /\d\d\/\d\d\/\d\d\d\d/)
}

on *:dialog:dlgGarfield:init:*:{
  did -ra $dname 2 $replace($did(2).text,xx.xx.xxxx,$+($gettok($date,1,47),.,$gettok($date,2,47),.,$gettok($date,3,47)))
  did -ra $dname 3 $date
  did -r $dname 11
  did -b $dname 7
  did -h $dname 12
  if (!$exists($qt($scriptdirnconvert.exe))) {
    var %grfErrorMsg = $input(NConvert could not be found! $+ $crlf $+ No download will happen. $+ $crlf $+ $crlf $+ You can download NConvert from the following website: $+ $crlf $+ http://www.xnview.com/en/nconvert/, oi, Information,)
    if (%grfErrorMsg) {
      if ($exists($qt($scriptdirgarfield.bmp))) {
        did -g $dname 1 $qt($scriptdirgarfield.bmp)
      }
      else {
        dialog -x dlgGarfield
      }
      halt
    }
  }
  set %grfDate $date
  set %grfFileSize 0
  grfShow
}

on *:dialog:dlgGarfield:close:*:{
  if ($sock(scGarfield)) { sockclose scGarfield }
  if (%grfDate) { unset %grfDate }
  if (%grfFileSize) { unset %grfFileSize }
}

on *:dialog:dlgGarfield:edit:3:{
  if (!$did(3).text) { did -ra $dname 3 $date }
  if (!$grfCheckDate) { did -b $dname 5-7 | did -h $dname 12 }
  else { did -e $dname 5-7 | did -v $dname 12 }
}

on *:dialog:dlgGarfield:sclick:*:{
  if ($did == 1) {
    if ($asctime($ctime($did(3).text),ddd) == Sun && $exists($qt($scriptdirgarfield.bmp)) && $did($dname,11).text != No today's Garfield yet.) {
      grfSonntag
    }
  }
  elseif ($did == 5) {
    if ($did(3).text) {
      if ($regex($did(3).text, /\d\d\.\d\d\.\d\d\d\d/)) {
        ; xx.xx.xxxx
        did -ra 3 $replace($did(3).text,.,/)
      }
      elseif ($regex($did(3).text, /\d\d\.\d\d\.\d\d/)) {
        ; xx.xx.xx
        did -ra 3 $replace($replace($did(3).text,.,/),$gettok($replace($did(3).text,.,/),3,47),$iif($gettok($replace($did(3).text,.,/),3,47) > 90,19,20) $+ $gettok($replace($did(3).text,.,/),3,47)
      }
      elseif ($regex($did(3).text, /\d\d\/\d\d\\/\d\d/)) {
        ; xx/xx/xx
        did -ra 3 $replace($did(3).text,$gettok($did(3).text,3,47),$iif($gettok($did(3).text,3,47) > 90,19,20) $+ $gettok($did(3).text,3,47))
      }
      elseif (!$regex($did(3).text, /\d\d\/\d\d\/\d\d\d\d/)) {
        did -ra $dname 11 Invalid date!
        .timer 1 5 did -r $dname 11
        halt
      }
      set %grfDate $did(3).text
      grfShow
    }
  }
  elseif ($did == 6) {
    var %grfTag = $gettok($did(3).text,1,47)
    var %grfMnt = $gettok($did(3).text,2,47)
    var %grfJhr = $gettok($did(3).text,3,47)
    if (%grfTag == 1) {
      %grfTag = $iif(%grfMnt == 01 || %grfMnt == 02 || %grfMnt == 04 || %grfMnt == 06 || %grfMnt == 09 || %grfMnt == 11,31,$iif(%grfMnt == 03,$iif($calc(%grfJhr % 4) == 0,29,28),30))
      if (%grfMnt == 1) {
        dec %grfJhr
        %grfMnt = 12
      }
      else {
        dec %grfMnt
      }
    }
    else {
      dec %grfTag
    }
    did -ra $dname 3 $iif($len(%grfTag) == 1,0 $+ %grfTag,%grfTag) $+ / $+ $iif($len(%grfMnt) == 1,0 $+ %grfMnt,%grfMnt) $+ / $+ %grfJhr
    set %grfDate $did(3).text
    grfShow
  }
  elseif ($did == 7) {
    var %grfTag = $gettok($did(3).text,1,47)
    var %grfMnt = $gettok($did(3).text,2,47)
    var %grfJhr = $gettok($did(3).text,3,47)
    if (%grfTag == 31) {
      if (%grfMnt == 12) {
        inc %grfJhr
        %grfMnt = 1
      }
      else {
        inc %grfMnt
      }
      %grfTag = 1
    }
    else {
      inc %grfTag
    }
    did -ra $dname 3 $iif($len(%grfTag) == 1,0 $+ %grfTag,%grfTag) $+ / $+ $iif($len(%grfMnt) == 1,0 $+ %grfMnt,%grfMnt) $+ / $+ %grfJhr
    set %grfDate $did(3).text
    grfShow
  }
  elseif ($did == 9) {
    run https://www.garfield.com
  }
  elseif ($did == 12) {
    run https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/ $+ $right($gettok($did(3).text,3,47),4) $+ / $+ $right($gettok($did(3).text,3,47),4) $+ - $+ $gettok($did(3).text,2,47) $+ - $+ $gettok($did(3).text,1,47) $+ .gif
  }
}

; ========================================

on *:sockopen:scGarfield:{
  if ($sockerr || !%grfDate) { did -ra dlgGarfield 11 Download failed! | halt }
  sockwrite -n $sockname GET /comics/garfield/ $+ $right($gettok($did(dlgGarfield,3).text,3,47),4) $+ / $+ $right($gettok($did(dlgGarfield,3).text,3,47),4) $+ - $+ $gettok($did(dlgGarfield,3).text,2,47) $+ - $+ $gettok($did(dlgGarfield,3).text,1,47) $+ .gif HTTP/1.1
  sockwrite -n $sockname Host: d1ejxu6vysztl5.cloudfront.net
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (X11; FreeBSD x86_64; rv:42.0) Gecko/20100101 Firefox/42.0
  sockwrite -n $sockname $crlf
}

on *:sockread:scGarfield:{
  if (%grfStartFile != 1) {
    var %x
    sockread %x
    if (Not Found isin %x) {
      did -ra dlgGarfield 11 No today's Garfield yet.
      sockclose scGarfield
    }
    if (Content-Length isin %x) { %grfFileSize = $gettok(%x,2,32) }
    if (%x == $null) { %grfStartFile = 1 }
  }
  else {
    var &tmpGarfield
    sockread &tmpGarfield
    bwrite $qt($scriptdirgarfield.gif) -1 -1 &tmpGarfield
    if ($file($qt($scriptdirgarfield.gif)).size == %grfFileSize) {
      sockclose scGarfield
      did -ra dlgGarfield 11 ... converting ...
      if ($exists($qt($scriptdirgarfield.bmp))) { .remove $qt($scriptdirgarfield.bmp) }
      run -n $qt($scriptdirnconvert.exe) -quiet -D -out bmp $qt($scriptdirgarfield.gif)
      .timer 1 3 did -rg dlgGarfield 1 $qt($scriptdirgarfield.bmp)
      .timer 1 3 did -r dlgGarfield 11
      if ($ctime($did(dlgGarfield,3).text) < $ctime($date)) { did -e dlgGarfield 7 }
      else { did -b dlgGarfield 7 }
      did -v dlgGarfield 12
    }
  }
}

; ========================================

alias garfield { dialog $iif($dialog(dlgGarfield), -x, -md) dlgGarfield dlgGarfield }
menu channel,status,query,menubar {
  -
  Daily Garfield:garfield
}
^\__/
..O.o

This is Einkaufswagen. Copy Einkaufswagen into your signature to help him on his way to world domination.
chris1
Administrator
Posts: 3029
Joined: 11.09.2003 20:17
Status: Gamers.IRC Coder

Re: Daily Garfield

Unread postby chris1 » 10.05.2018 22:13

Kann das sein, dass das nicht mehr geht? Ich glaube die haben da was geändert. Link usw.
User avatar
Tuxman
Administrator
Posts: 1873
Joined: 24.10.2003 00:13
Status: That guy
Contact:

Re: Daily Garfield

Unread postby Tuxman » 25.05.2018 09:26

Entschuldige, gar nicht gesehen - keine Mail bekommen...

Sehr gute Frage. Ich schaue mir das morgen an!
^\__/
..O.o

This is Einkaufswagen. Copy Einkaufswagen into your signature to help him on his way to world domination.
chris1
Administrator
Posts: 3029
Joined: 11.09.2003 20:17
Status: Gamers.IRC Coder

Re: Daily Garfield

Unread postby chris1 » 25.05.2018 23:14

Tuxman wrote:
25.05.2018 09:26
(20:02:29) (@SpongeTux) https://d1ejxu6vysztl5.cloudfront.net/c ... -MM-DD.gif ist die neue adresse...
(20:02:45) (@SpongeTux) statt vorher garfield.com/uploads/strips/irgendwas.jpg

Who is online

Users browsing this forum: No registered users and 0 guests