; ******************************************************
; About DC mBOT and Check for update
; ******************************************************
alias mBAbout { dialog $iif($dialog(mBAbout),-v,-m) mBAbout mBAbout }
alias mBUpdate { dialog $iif($dialog(mBUpdate),-v,-m) mBUpdate mBUpdate }

alias -l DC.Credits {
  if ($1 isnum) {
    goto $1
    :1 | return He's the Author of mIRC Internet Relay Chat Client. Thanks to him for this good Chat Client and its' powerful Scripting Language.
    :2 | return Because he written the MDX.dll and its' stuff and enabaled us to creating/writing better scripts.
    :3 | return For /delete snippet.
    :4 | return He is one of my good friends. beside that he is my primary Beta Tester for any Scripts/Addons/Snippets of mine.
    :5 | return For xSeen v3.9
    :6 | return He did written the hOS.dll and enabled us get some good things more than ordinary stuffs.
    :7 | return For process bar window.
    :8 | return Here we are, Thank you my dear users for Downloading and/or Using and/or Supporting DC mBOT :)
  }
}

dialog mBAbout {
  title "About DC mBOT"
  size -1 -1 236 247
  option dbu
  icon $DC.Imgs(MB.ico)
  list 1, -6 -1 253 30, disable size
  list 2, 4 4 25 25, disable size
  text "About DC mBOT", 3, 29 3 216 15
  text "Let's know the Author and some information about this script...", 4, 30 17 215 10
  tab "General", 5, 3 31 230 202
  box "What is DC mBOT?", 6, 8 49 220 30, tab 5
  text " It's an Internet Relay Chat (IRC) Bot Script which works under mIRC product (Written by Khaled Mardam-Bey) and its prowerful Scripting Language (mSL).", 7, 14 59 207 15, tab 5
  box "About", 8, 8 80 220 57, tab 5
  text "Author:", 9, 11 90 45 8, tab 5 right
  text "", 10, 59 90 80 8, tab 5
  text "Version:", 11, 11 101 45 8, tab 5 right
  text "", 12, 59 101 80 8, tab 5
  text "Published At:", 13, 11 112 45 8, tab 5 right
  text "", 14, 59 112 80 8, tab 5
  text "Initial Release:", 15, 11 123 45 8, tab 5 right
  text "", 16, 59 123 80 8, tab 5
  icon 17, 179 88 42 42,  $DC.Imgs(DC_.png), 0, tab 5
  box "Contacts", 18, 8 138 220 65, tab 5
  text " You can contact me via E-mail or visit me at mentioned IRC Networks below. Also you can visit my Website, there are some other ways to be in touch with me...", 19, 14 148 207 16, tab 5
  text "Website:", 20, 11 168 45 8, tab 5 right
  link "Http://DCScript.PersianGig.com/", 21, 59 168 85 8, tab 5
  text "E-mail:", 22, 11 179 45 8, tab 5 right
  link "Masoud.1984@Gmail.com", 23, 59 179 85 8, tab 5
  text "IRC Networks:", 24, 11 190 45 8, tab 5 right
  link "DAL.net", 25, 59 190 27 8, tab 5
  link "UnderNet.org", 26, 90 190 40 8, tab 5
  link "Bedehi.com", 27, 135 190 34 8, tab 5
  box "Update", 28, 8 204 220 24, tab 5
  text " Looking for updates?", 29, 14 214 60 8, tab 5
  link "Click here", 30, 75 214 30 8, tab 5
  tab "Credits", 31
  box "Notes", 32, 8 49 220 98, tab 31
  text " In the first step I must say a 'Thank You' for Downloading or Using this mIRC Script. Please read up the 'Help files' before asking me for anything.", 33, 14 60 206 16, tab 31
  text " If you've found any kind of Bugs and/or Errors in DC mBOT; Please contact me via my E-mail or any other ways which I've written for you. If you're using this script and you'd like it or even you don't; Please let me know what is/was your opinion about it. All suggestions are welcome...", 34, 14 80 206 30, tab 31
  text " If you want to be a Beta tester of this script just send me an E-mail and then we can talking more about it.", 35, 14 114 206 16, tab 31
  text " Thank you for making your choice DC mBOT.", 36, 14 133 206 8, tab 31
  box "Credits", 37, 8 148 220 80, tab 31
  text " Let's know those other people who helped me to writing this script or I just used their DLLs/Snippets. Choose a persons from the combobox below and read the reason... (Accept my apology if I forgot anyones.)", 38, 14 158 206 24, tab 31
  text "Choose &one:", 39, 10 187 36 8, tab 31 right
  combo 40, 48 186 85 50, tab 31 size drop
  text "", 41, 48 198 173 26, tab 31
  button "&Help Centre", 42, 3 235 50 10
  button "&Continue...", 43, 183 235 50 10, cancel
}

on *:dialog:mBAbout:*:*:{
  if ($devent == close) { unset %DC.Clicked }
  if ($devent == init) {
    MDX MarkDialog $dname
    MDX SetMircVersion $version
    MDX SetControlMDX $dname 2 Toolbar flat nodivider wrap list arrows > $Bars
    MDX SetBorderStyle $dname 1,2 simple
    MDX SetFont $dname 3 +a 25 700 Ringbearer
    MDX SetFont $dname 4 +a 14 700 Arial
    MDX SetColor $dname 1,2,3,4 background $rgb(199,199,199)
    MDX SetColor $dname 1,2,3,4 textbg $rgb(199,199,199)
    MDX SetColor $dname 1,3 text $rgb(65,141,255)
    MDX SetColor $dname 4 text $rgb(0,0,0)
    MDX SetBorderStyle $dname 10,12,14,16,41 Staticedge
    did -b $dname 1,2
    did -i $dname 2 1 bmpsize 32 32
    did -i $dname 2 1 setimage icon normal $noqt($DC.Imgs(MB.ico))
    did -a $dname 2 +a 1 $chr(9) $+ About DC mBOT
    did -ra $dname 3 About DC mBOT $DC.Ver
    did -ra $dname 10 $DC.Author
    did -ra $dname 12 $remove($DC.Ver,v)
    did -ra $dname 14 $DC.Release
    did -ra $dname 16 $DC.InitialRelease
    didtok $dname 40 44 Khaled Mardam-Bey,DragonZap,Flobse,Navid,xDaeMoN,}|-|yRoN{,Suchorski,YOU!
    did -c $dname 40 1
    did -ra $dname 41 $DC.Credits(1)
    unset %DC.Clicked
  }
  if ($devent == sclick) {
    if ($did == 17) {
      if (%DC.Clicked) { did -g $dname 17 $DC.Imgs(DC_.png) | unset %DC.Clicked }
      else { did -g $dname 17 $DC.Imgs(DC.png) | set %DC.Clicked . }
    }
    if ($did == 21) { url -an $did($did).text }
    if ($did == 23) { .clipboard $did($did).text }
    if ($istok(25 26 27,$did,32)) {
      var %servs = IRC.DAL.net IRC.UnderNet.org IRC.Bedehi.com
      server $iif($server,-m) $+($gettok(%servs,$calc($did - 24),32),:,6667)
    }
    if ($did == 30) { mBUpdate }
    if ($did == 40) && ($did(40).sel) { did -ra $dname 41 $DC.Credits($did(40).sel) }
    if ($did == 42) { Start_Help }
  }
}

; [Check for update]
alias GetNum return $remove($lower($1-),a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)

dialog mBUpdate {
  title "Checking for Update..."
  size -1 -1 146 46
  option dbu
  icon $DC.Imgs(MB.ico)
  box "", 1, 3 0 140 31
  text "", 2, 7 9 131 16, center
  button "&Close", 3, 102 33 40 10, disable cancel
  button "Get It Now!", 4, 3 33 71 10, hide disable
}

on *:dialog:mBUpdate:*:*:{
  if ($devent == init) {
    if ($sock(mBUpdate)) { .sockclose mBUpdate }
    hOS EnableCloseBox $dialog($dname).hwnd false
    did -b $dname 3,4
    did -h $dname 4
    unset %msg
    did -ra $dname 2 Connecting to mBOT home page, please wait...
    if (!$sock(mBUpdate)) { .sockopen mBUpdate dcscript.persiangig.com 80 }
  }
  if ($devent == sclick) && ($did == 4) { run http://dcscript.persiangig.com/mbot.html | dialog -x $dname }
}

On *:SockOpen:mBUpdate:{
  if ($sockerr) { did -ra mBUpdate 2 Atleast an error occurred while checking for update... | did -e mBUpdate 3 | return }
  did -ra mBUpdate 2 Connected, Now sending information...
  sockwrite -n $sockname GET $+(/,mbot.html) HTTP/1.1
  sockwrite -n $sockname Host: $+(dcscript.persiangig.com,$crlf,$crlf)
  sockwrite -n $sockname Connection: Keep-Alive
}

On *:SockRead:mBUpdate:{
  if ($sockerr) { did -ra mBUpdate 2 Atleast an error occurred while checking for update... | did -e mBUpdate 3 | return }
  did -ra mBUpdate 2 The connection established, Now reading data...
  var %m
  sockread %m
  if (%m) {
    if (*DC mBOT* iswm %m) && (*Version: * iswm %m) {
      var %ver = $gettok($GetNum($striphtml(%m)),4,32)
      if (%ver == $remove($DC.Ver,v)) { set %msg You're using the latest version of the DC mBOT. | return }
      elseif (%ver > $remove($DC.Ver,v)) { set %msg A newer version of DC mBOT is available to download! | return }
      else { set %msg No update is available. }
    }
  }
}

On *:SockClose:mBUpdate:{
  if ($dialog(mBUpdate)) && (%msg) {
    did -ra mBUpdate 2 %msg
    if (*newer version* iswm %msg) { did -ve mBUpdate 4 }
    unset %msg
    did -ve mBUpdate 3
  }
}
