alias radyoX { 
  .dialog -m os.radiosys os.radiosys
} 

alias radyo { 
  if (!$dialog(os.radiosys)) { 
    .dialog -m os.radiosys os.radiosys
  }
}

alias os.radiosys { 
  if $server { 
    join #radyo 
  } 
  if (!$dialog(os.radiosys)) { 
    dialog -m os.radiosys os.radiosys 
  } 
  else { 
    dialog -iev os.radiosys 
  } 
}
dialog os.radiosys {
  title %Scriptversion - Radyo Player
  size 67 99 583 88
  option pixels
  text "00:00", 6, 10 10 50 20, center
  text " hazır.", 7, 65 10 210 20
  list 8, 10 35 80 20, size
  text "0 Kbps", 9, 95 35 50 20, center
  text "0 KHz", 10, 150 35 40 20, center
  text "Mono", 11, 195 35 35 20, center
  text "Stereo", 12, 235 35 40 20, center
  text "Çalıyor", 13, 10 60 45 15, center
  text "Hafızada", 14, 60 60 55 15, center
  text "", 15, 120 60 155 15
  edit "", 17, 10 80 170 20, center read autohs
  box "", 131, 285 1 125 105
  button "Duraklat", 20, 195 80 80 20
  text "Radyo:", 28, 292 13 45 15
  text "N/A", 29, 352 13 50 15
  text "DJ:", 32, 292 33 45 15
  text "N/A", 33, 352 33 50 15
  text "Gelen byte:", 36, 292 58 60 15
  text "N/A", 37, 352 58 50 15
  text "Hız:", 38, 292 78 50 15
  text "N/A", 39, 352 78 50 15
  text "Versiyon:", 30, 292 133 45 30
  text "N/A", 31, 352 133 205 30
  text "Web Site:", 34, 292 153 50 15
  text "N/A", 35, 352 153 205 15
  box "", 132, 415 1 70 105
  button "!durum", 133, 420 15 60 17, 
  button "!dinleyici", 134, 420 32 60 17
  button "!dinleyen", 135, 420 49 60 17
  button "!dj", 136, 420 66 60 17
  button "!istek", 137, 420 83 60 17

  box "", 138, 490 1 70 105
  icon 836, 490 12 72 72 , SohbetSen\ico\grafik\SohbetSen10.png, noborder
  button "Bilgi Al", 139, 495 83 60 17

  button "X", 140, 564 6 17 17
  box "", 5, 5 1 275 105
  button "", 42, 0 0 0 0, hide cancel
  text "Online DJ", 108, 10 164 265 16, center
}
on *:dialog:os.radiosys:init:*: { 
  { Splay $mircdirSohbetSen\sounds\Menu.wav }
  os.mdxdll SetMircVersion $version 
  os.mdxdll MarkDialog $dname 
  mdx SetDialog $dname style dlgmodal
  os.mdxdll SetFont $dname 108 13 700 tahoma 
  os.mdxdll SetBorderStyle $dname 6,7,8,9,10,11,12,13,14,15,20,21,24,26,27,29,31,33,35,37,39 staticedge 
  os.mdxdll SetFont 6 16 700 Verdana 
  os.mdxdll SetFont 7,9,10,12,15,16,17,20,21,22,24,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41 13 400 Tahoma 
  os.mdxdll SetFont 13,14 12 400 Tahoma 
  os.mdxdll SetControlMDX $dname 8 trackbar tooltips > SohbetSen\dll\bars.mdx 
  did -i os.radiosys 8 1 params $os.vol.w 0 100 0 0 0 0 15 
  os.mdxdll SetControlMDX $dname 15 ProgressBar smooth > SohbetSen\dll\ctl_gen.mdx 
  did -a $dname 15 50 0 100 
  os.mdxdll SetControlMDX $dname 22 listview rowselect nosortheader grid showsel single report > SohbetSen\dll\views.mdx 
  os.ampdll PluginManager Load output SohbetSen\dll\out_wave.dll 
  os.ampdll PluginManager Load input SohbetSen\dll\in_mp3.dll
  dialog -o $dname
  .timer 1 7 dialog-o $dname
  os.interr 
  os.monvol 
  os.contatore 
  .timeros-.k/s 0 1 os.k/s 
  os.preferitibar 
  if ($exists($+($shortfn($mircdirSohbetSen\ini\),RSYS_Preferiti.ini)) != $true) { 
    write -c $+($shortfn($mircdirSohbetSen\ini\),RSYS_Preferiti.ini) 
  } 
  $iif($os.read(help) = YES,dialog -mo os.helpradio os.helpradio) 
  $iif($os.read(addr),did -a os.radiosys 17 $ifmatch) 
  did -ra $dname 17 irc.sohbetsen.org #Radyo
  _rbaglan
}
alias dialog-o {
  if $dialog($1) {
    dialog -n $1
  }
}
on *:dialog:os.radiosys:dclick:22: {
  did -c $dname 1 
  did -ra $dname 17 $mid($gettok($did($dname,22).seltext,2,9),11) 
  os.write addr $mid($gettok($did($dname,22).seltext,2,9),11) 
  os.interr 
  sockopen os.radiosys-0 $gettok($did($dname,17),1,58) $gettok($did($dname,17),2,58) 
  os.wradio Connessione in corso 
}
on *:dialog:os.radiosys:sclick:*: { 
  if ($did = 8) { 
    os.write vol $calc($gettok($did($dname,8,1),1,32) * 655.35) 
    vol -w $os.read(vol) 
  } 
  elseif ($did = 20) { 
    if ($os.ampdll(CurrentMusic,status) != OK paused) { 
      os.ampdll CurrentMusic pause 
      did -a $dname 20 Devam... 
    } 
    else { 
      os.ampdll CurrentMusic unpause 
      did -a $dname 20 Duraklat 
    } 
  } 
  elseif ($did = 21) { 
    os.helpradio 
  } 
  elseif ($did = 24) { 
    os.addserver 
  }
  elseif ($did = 26) { 
    write -dl $+ $calc($did($dname,22).sel -1) $+($shortfn($mircdirSohbetSen\ini\),RSYS_Preferiti.ini) 
    did -d $dname 22 $did($dname,22).sel 
  } 
  elseif ($did = 27) { 
    did -r $dname 22 
    write -c $+($shortfn($mircdirSohbetSen\ini\),RSYS_Preferiti.ini) 
    os.preferitibar 
  } 
  elseif ($did = 42) { 
    os.interr 
    if ($dialog(os.helpradio)) { 
      dialog -x os.helpradio 
    } 
    if ($dialog(os.addserver)) { 
      dialog -x os.addserver 
    } 
    os.ampdll FlushAllPlugins . 
  }
  if ($did == 133) {  join  #radyo | .timerUAEH 1 2 /msg #radyo !durum }
  if ($did == 134) {  join  #radyo | .timerUAEH 1 2 /msg #radyo !dinleyici }
  if ($did == 135) {  join  #radyo | .timerUAEH 1 2 /msg #radyo !dinleyen }
  if ($did == 136) {  join  #radyo | .timerUAEH 1 2 /msg #radyo !dj }
  if ($did == 137) {  join  #radyo | .timerUAEH 1 2 /msg #radyo !istek $$?="Radyo çalınmasını istediğiniz şarkının adını giriniz" }
  if ($did == 139) {  oydar irc.sohbetsen.org:8181 }
  if ($did == 140) {  os.interr | dialog -x $dname }
}
alias removex {
  if $file($1) {
    .remove $1
  }
}
on *:sockclose:os.radiosys-0: { 
  os.interr 
  os.wradio Bağlantı kesildi. 
}
on *:sockclose:os.radiosys-1: { 
  os.interr 
  os.wradio Bağlantı kesildi. 
}
on *:sockopen:os.radiosys-0: { 
  if ($sockerr = 0) { 
    .removex $+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3) 
    sockwrite -n $sockname GET / HTTP/1.0 $+ $lf $+ Host: $ip $+ $lf $+ User-Agent: Radio-SYS-v0.2-By-}|-|yRoN{-}Y{asta|<illa-Team-©2002/2003 $+ $lf $+ Accept: */* $+ $lf $+ Icy-MetaData:1 $+ $lf $+ Connection: close $+ $lf $+ $crlf 
    os.wradio Bağlantı kuruluyor...
  }
  else { 
    os.interr 
    os.wradio Radyoya bağlanılamıyor. 
  }
}
on *:sockread:os.radiosys-*: { 
  if ($sockerr = 0) { 
    if (*0 iswm $sockname) { 
      sockread %os.radiodata
      if (!%os.radiodata) {
        os.wradio Bağlantı kuruluyor... 
        os.infoserver
        sockrename $sockname os.radiosys-1 
      } 
      else { 
        os.writeinfo $gettok(%os.radiodata,1,58) $gettok(%os.radiodata,2-,58) 
      } 
    }
    elseif (*1 iswm $sockname) { 
      sockread &os.radiodata 
      bwrite $+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3) -1 &os.radiodata 
      if ($os.mp3 >= 8000) { 
        did -ra os.radiosys 15 0 0 100 
        sockrename $sockname os.radiosys-2 
        os.infomp3 
        .timeros.playing 0 0 os.playing 
      } 
      else { 
        did -b os.radiosys 13 
        did -e os.radiosys 14 
        did -a os.radiosys 15 $os.probuff 0 100 
      } 
    } 
    else { 
      sockread &os.radiodata 
      bwrite $+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3) -1 &os.radiodata 
    } 
  } 
  else { 
    os.wradio Errore di dialogo, disconnesso 
  } 
}
alias os.wradio did -a os.radiosys 7 $chr(160) $+ $1-
alias os.mdxdll return $dll(SohbetSen\dll\mdx.dll,$1,$2-)
alias mdx return $dll(SohbetSen\dll\mdx.dll,$1,$2-)
alias os.ampdll return $dll(SohbetSen\dll\amp_in.dll,$1,$2-)
alias os.vol.w return $int($calc($vol(wave) / 655.35))
alias os.preferitibar return | ;did -i os.radiosys 22 1 headerdims $iif($lines($+($shortfn($mircdirSohbetSen\ini\),RSYS_Preferiti.ini)) < 5,135,120) $+ :1 125:2
alias os.infoserver $iif($os.readinfo(icy-name),did -a os.radiosys 29 $ifmatch) | $iif($os.readinfo(Server),did -a os.radiosys 31 $ifmatch) | $iif($os.readinfo(icy-notice2),did -a os.radiosys 31 $remove($ifmatch,<BR>)) | $iif($os.readinfo(icy-genre),_djset $ifmatch) | $iif($os.readinfo(icy-url),did -a os.radiosys 35 $ifmatch)
alias os.infomp3 did -a os.radiosys 9 $mp3($+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3)).bitrate Kbps | did -a os.radiosys 10 $int($calc($mp3($+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3)).sample /1000)) Khz | did -e os.radiosys $iif($mp3($+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3)).mode = Single Channel,11,12)
alias os.read return $readini($+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini),RadioSYS,$1)
alias os.write writeini $+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini) RadioSYS $1 $2-
alias os.del remini $+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini) RadioSYS $1
alias os.readinfo return $readini($+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini),InfoServer,$1)
alias os.writeinfo $iif($2-,writeini $+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini) InfoServer $1 $2-)
alias os.delinfo $iif($1,remini $+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini) InfoServer $1,remini $+($shortfn($mircdirSohbetSen\ini\),RSYS_Options.ini) InfoServer)
alias os.monvol if ($dialog(os.radiosys)) { if ($os.read(vol) != $vol(wave)) { os.write vol $vol(wave) | did -i os.radiosys 8 1 params $os.vol.w 0 100 0 0 0 0 15 } | .timeros-.monvol -m 1 100 os.monvol }
alias os.pos return $gettok($os.ampdll(CurrentMusic,position),2,32)
alias os.mp3 return $round($calc($file($+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3)).size / $mp3($+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3)).bitrate * 7.99999),0)
alias os.interr .timeros.* off | sockclose os.radiosys-* | os.ampdll Stop . | os.delinfo | did -a os.radiosys 29,31,33,35,37,39 N/A | did -a os.radiosys 9 0 Kbps | did -a os.radiosys 10 0 KHz | did -b os.radiosys 11,12,13,14,20 | did -ra os.radiosys 15 0 0 100 | did -a os.radiosys 20 Duraklat 
alias os.playing if ($os.pos = WAE0) && ($sock(os.radiosys-2)) && ($os.readinfo(pos) >= $calc($os.mp3 - 2000)) { os.wradio Bağlantı buffering durumunda. | .timeros.buffering 0 0 os.buffering | .timeros.playing off } | elseif ($os.pos = WAE0) && ($sock(os.radiosys-2)) { os.ampdll Play $+($shortfn($mircdirSohbetSen\ini\),SohbetSen.mp3) | os.ampdll CurrentMusic seek $os.readinfo(pos) | os.delinfo pos | os.wradio Bağlantı doğrulanıyor. } | elseif ($os.pos = WAE0) && (!$sock(os.radiosys-2)) { os.interr | os.wradio Bağlantı koptu. } | else { if (!$os.readinfo(pos)) { did -e os.radiosys 13,20 | did -b os.radiosys 14 | os.wradio HayaL-FM  -  En ideaL Sanal Radyo..... } | os.writeinfo pos $os.pos }
alias os.probuff return $round($calc($calc($os.mp3 - $os.readinfo(pos)) * 100 / 8000),0)
alias os.buffering if ($calc($os.mp3 - $os.readinfo(pos)) <= 8000) && ($sock(os.radiosys-2)) { did -b os.radiosys 13,20 | did -e os.radiosys 14 | did -a os.radiosys 15 $os.probuff 0 100 } | else { did -ra os.radiosys 15 0 0 100 | .timeros.buffering off | .timeros.playing 0 0 os.playing }
alias os.contatore if ($dialog(os.radiosys)) { did -a os.radiosys 6 $gmt($calc($os.readinfo(pos) /1000),nn:ss) | .timeros-.contatore -m 1 100 os.contatore }
alias os.k/s if ($dialog(os.radiosys)) { if (!$sock(os.radiosys-0)) && ($sock(os.radiosys-*)) { did -a os.radiosys 39 $bytes($calc($sock(os.radiosys-*).rcvd - $os.readinfo(bytesrcvd)),k) K/s | did -a os.radiosys 37 $bytes($sock(os.radiosys-*).rcvd,b) | os.writeinfo bytesrcvd $sock(os.radiosys-*).rcvd } } | else { .timeros-.k/s off }

alias _djset {
  did -a os.radiosys 33 $1
  did -a os.radiosys 108 Şu anda DJ: $1
}
alias _rbaglan {
  os.write addr irc.sohbetsen.org:8181/listen.pls
  sockopen os.radiosys-0 irc.sohbetsen.org 8181 
  os.wradio Bağlanılıyor... 
}

alias radyo.giris { 
  if ($dialog(radyo.giris)) {  } 
  else { dialog -m radyo.giris radyo.giris }
}
on *:dialog:radyo.giris:init:0:{ 
  { Splay $mircdirSohbetSen\sounds\Menu.wav }
  mdx SetMircVersion $version 
  mdx MarkDialog $dname
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style dlgmodal
  mdx SetDialog $dname style dlgmodal
}
on 1:dialog:radyo.giris:sclick:*:{
  if ($did == 4) { RadyoX }
}
dialog radyo.giris {
  title "HaYaL-FM Radyo Giris"
  size -1 -1 288 100
  option pixels
  icon 836, 10 30 72 72 , SohbetSen\ico\grafik\SohbetSen11.png, noborder
  box "HaYaL-FM - En iDEaL Sanal Radyo...", 1, 6 4 276 112
  icon 2, 17 23 79 79
  text "Şu an #Radyo kanalındasınız. Radyo dinlemek için HaYaL-FM Radyo Player'inizin açılmasını istiyor musunuz?", 3, 110 24 164 58, center
  button "Evet", 4, 110 84 74 20, ok
  button "Hayır", 5, 200 84 74 20, cancel
}

on ^1:join:#:{
  if ($nick == $me) && ($chan == #Radyo) { radyo.giris }
