Advertisement
Guest User

radio

a guest
Mar 14th, 2017
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 30.29 KB | None | 0 0
  1. #################################################
  2. #        shoutcast.tcl v.1.0 By Calvin          #
  3. #           plaNETWORK TEAM                 #
  4. #         visit www.planetwork.web.id           #
  5. #################################################
  6.  
  7. ############### Setting Sonfig ##################
  8. set radiochans ""
  9. set adminchans "#radio"
  10. set streamip "128.199.88.71"
  11. set streamport "8000"
  12. set streampass "stream"
  13. #set scstatstrigger ".stats"
  14. #set scstreamtrigger ".stream"
  15. #set scplayingtrigger ".play"
  16. #set sclistenertrigger ".listener"
  17. #set scdjtrigger ".rj"
  18. set scsetdjtrigger "!setdj"
  19. set scunsetdjtrigger "!unsetdj"
  20. #set screquesttrigger ".request"
  21. #set screquesttrigger2 ".req"
  22. set scgreettrigger "!pesan"
  23. #set sclastsongstrigger ".list"
  24. #set schelptrigger ".radio"
  25. #################################################
  26.  
  27. #################################################
  28. set alertadmin "Calvin!*@*"        
  29. set doalertadmin "1"               
  30. #################################################
  31. set announce "1"               
  32. #################################################
  33. set urltopic "0"               
  34. set ctodjc "1"                 
  35. set tellsongs "1"              
  36. set tellusers "1"              
  37. set tellbitrate "1"            
  38. #################################################
  39. set advertise "0"              
  40. set advertiseonlyifonline "1"          
  41. #################################################
  42. # some variable you can use here
  43. # /dj/ - the djnickname
  44. # /sgenre/ - the servers music genre
  45. # /stitle/ - the streamtitle
  46. # /surl/ - the servers url
  47. # /bitrate/ - the current streaming bitrate
  48. # /curlist/ - current listeners
  49. # /curhigh/ - current listener peak
  50. # /cursong/ - the current song
  51.  
  52. set offlinetext "Radio\00304 OFFLINE\003 Now"
  53. set offlinetopic "Stream URL : \00312http://radio.planetwork.id/listen.pls\003"
  54. set onlinetext "Radio\00304 ONLINE\003 Now"
  55. set onlinetopic "\00312Back up again\003"
  56. set streamtext "http://radio.planetwork.id/listen.pls"
  57. set advertisetext "Stream URL :\00312 http://radio.planetwork.id/listen.pls\003"
  58.  
  59. ############### End Of Config ###################
  60.  
  61. #################################################
  62. #bind pub - $scstatstrigger  pub_scstat
  63. #bind msg - $scstatstrigger  msg_scstat
  64. #################################################
  65. #bind pub - $scplayingtrigger  pub_playing
  66. #bind msg - $scplayingtrigger  msg_playing
  67. #################################################
  68. #bind pub - $scdjtrigger  pub_dj
  69. #bind msg - $scdjtrigger  msg_dj
  70. #################################################
  71. bind pub - $scsetdjtrigger  pub_setdj
  72. bind msg - $scsetdjtrigger  msg_setdj
  73. #################################################
  74. bind pub - $scunsetdjtrigger  pub_unsetdj
  75. bind msg - $scunsetdjtrigger  msg_unsetdj
  76. #################################################
  77. #bind pub - $sckickdjtrigger  pub_kickdj
  78. #bind msg - $sckickdjtrigger  msg_kickdj
  79. #################################################
  80. #bind pub - $screquesttrigger  pub_request
  81. #bind msg - $screquesttrigger  msg_request
  82. #bind pub - $screquesttrigger2  pub_request
  83. #bind msg - $screquesttrigger2  msg_request
  84. #################################################
  85. bind pub - $scgreettrigger  pub_greet
  86. bind msg - $scgreettrigger  msg_greet
  87. #################################################
  88. #bind pub - $scstreamtrigger pub_stream
  89. #bind msg - $scstreamtrigger msg_stream
  90. #################################################
  91. #bind pub - $sclastsongstrigger pub_lastsongs
  92. #bind msg - $sclastsongstrigger msg_lastsongs
  93. #################################################
  94. #bind pub - $sclistenertrigger pub_listener
  95. #bind msg - $sclistenertrigger msg_listener
  96. #################################################
  97. #bind pub - $schelptrigger pub_help
  98. #bind msg - $schelptrigger msg_help
  99. #################################################
  100. bind time - "* * * * *" isonline
  101. bind time - "?0 * * * *" advertise
  102. bind nick D * djnickchange
  103. #################################################
  104. set rclr {"02" "07" "03" "11" "06"}
  105. #################################################
  106. set dj "RadioBot"
  107. set surl ""
  108. set bitrate ""
  109. set stitle ""
  110. #################################################
  111. if {[file exists dj.txt]} {
  112.    set temp [open "dj.txt" r]
  113.    set dj [gets $temp]
  114.    close $temp
  115. }
  116.  
  117. proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }
  118.  
  119.  
  120. proc status { } {
  121.    global streamip streamport streampass
  122.    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
  123.       putlog "error: $sockerror"
  124.       return 0 } else {
  125.       puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
  126.       puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
  127.       puts $sock "Host: $streamip"
  128.       puts $sock "Connection: close"
  129.       puts $sock ""
  130.       flush $sock
  131.       while {[eof $sock] != 1} {
  132.          set bl [gets $sock]
  133.          if { [string first "standalone" $bl] != -1 } {
  134.             set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
  135.          }
  136.       }
  137.       close $sock
  138.    }
  139.    if {[info exists streamstatus]} {
  140.       if { $streamstatus == "1" } { return 1 } else { return 0 }
  141.    } else { return 0 }
  142. }
  143.  
  144.  
  145.  
  146.  
  147. proc poststuff { mode text } {
  148.    global radiochans dj
  149.    set curlist "0"
  150.    set curhigh "0"
  151.    set surl ""
  152.    set cursong ""
  153.    set sgenre ""
  154.    set bitrate "0"
  155.    set stitle ""
  156.  
  157.    set temp [open "isonline.txt" r]
  158.    while {[eof $temp] != 1} {
  159.       set zeile [gets $temp]
  160.       if {[string first "curlist:" $zeile] != -1 } { set curlist $zeile }
  161.       if {[string first "curhigh:" $zeile] != -1 } { set curhigh $zeile }
  162.       if {[string first "cursong:" $zeile] != -1 } { set cursong [lrange $zeile 1 [llength $zeile]] }
  163.       if {[string first "sgenre:" $zeile] != -1 } { set sgenre [lrange $zeile 1 [llength $zeile]]}
  164.       if {[string first "serverurl:" $zeile] != -1 } { set surl [lindex $zeile 1] }
  165.       if {[string first "bitrate:" $zeile] != -1 } { set bitrate [lindex $zeile 1] }
  166.       if {[string first "stitle:" $zeile] != -1 } { set stitle [lindex $zeile 1] }
  167.    }
  168.    close $temp
  169.  
  170.    regsub -all "/stitle/" $text "$stitle" text
  171.    regsub -all "/curlist/" $text "$curlist" text
  172.    regsub -all "/curhigh/" $text "$curhigh" text
  173.    regsub -all "/cursong/" $text "$cursong" text
  174.    regsub -all "/sgenre/" $text "$sgenre" text
  175.    regsub -all "/surl/" $text "$surl" text
  176.    regsub -all "/bitrate/" $text "$bitrate" text
  177.    regsub -all "/dj/" $text "$dj" text
  178.  
  179.    foreach chan [channels] {
  180.       if {$radiochans == "" } { putserv "$mode $chan :$text" }
  181.       if {$radiochans != "" } {
  182.          if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1)} {putserv "$mode $chan :$text"}
  183.       }
  184.    }
  185. }
  186.  
  187.  
  188. proc schelp { target } {
  189.    global scstatstrigger scstreamtrigger scplayingtrigger scdjtrigger sclastsongstrigger screquesttrigger scgreettrigger sclistenertrigger
  190.    putserv "notice $target :#==========================+ \00312Perintah Radio\003 +=============================#"
  191.    putserv "notice $target :#\00304 $scstatstrigger \003= untuk melihat status radio"
  192.    putserv "notice $target :#\00304 $scstreamtrigger \003= untuk melihat link streaming radio"
  193.    putserv "notice $target :#\00304 $scplayingtrigger \003= untuk melihat lagu yang sedang di putar"
  194.    putserv "notice $target :#\00304 $scdjtrigger \003= untuk melihat siapa RJ yang lagi ON AIR"
  195.    putserv "notice $target :#\00304 $sclastsongstrigger \003= untuk melihat list lagu yang sudah di putar"
  196.    putserv "notice $target :#\00304 $screquesttrigger \003= cara merequest lagu (.request penyanyi - judul lagu)"
  197.    putserv "notice $target :#\00304 $scgreettrigger \003= cara untuk mengirim pesan ke RJ (.pesan - isi pesan)"
  198.    putserv "notice $target :#\00304 $sclistenertrigger \003= untuk melihat daftar pendengar radio"
  199.    putserv "notice $target :#=============================+++ \00312End\003 +++=================================#"
  200.    putserv "notice $target :#========+++ \00303Terima Kasih telah streaming di Radio Online Kami\003 +++========#"
  201.    putserv "notice $target :#===============+++++ \00303Support By Calvin @ plaNETWORK\003 +++++================#"
  202. }
  203.  
  204. proc msg_help {nick uhost hand arg} {
  205.    schelp $nick
  206. }
  207.  
  208. proc pub_help {nick uhost hand chan arg} {
  209.    global radiochans
  210.    if {$radiochans == "" } { schelp $nick }
  211.    if {$radiochans != "" } {
  212.       if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { schelp $nick}
  213.    }
  214. }
  215.  
  216. proc advertise { nick uhost hand chan arg } {
  217.    global advertisetext advertise advertiseonlyifonline
  218.    if {$advertise == "1" && $advertiseonlyifonline == "0"} { poststuff privmsg "$advertisetext" }
  219.    if {$advertise == "1" && $advertiseonlyifonline == "1" && [status] == 1} { poststuff privmsg "$advertisetext" }
  220. }
  221.  
  222.  
  223. proc setdj {nickname djnickname } {
  224.    if {$djnickname == "" } { set djnickname $nickname }
  225.    global streamip streamport streampass dj
  226.    putlog "shoutcast: new dj: $djnickname ($nickname)"
  227.    set temp [open "dj.txt" w+]
  228.    puts $temp $djnickname
  229.    close $temp
  230.    set temp [open "djnick.txt" w+]
  231.    puts $temp $nickname
  232.    close $temp
  233.    if { [status] == "1" } { poststuff privmsg "\00304$djnickname\003 On Air \00307\u266a\u266b\003"
  234.       if { $::ctodjc == "1" } {
  235.          set temp [open "isonline.txt" r]
  236.          while {[eof $temp] != 1} {
  237.             set zeile [gets $temp]
  238.             if {[string first "isonline:" $zeile] != -1 } { set oldisonline $zeile }
  239.             if {[string first "curlist:" $zeile] != -1 } { set oldcurlist $zeile }
  240.             if {[string first "curhigh:" $zeile] != -1 } { set oldcurhigh $zeile }
  241.             if {[string first "cursong:" $zeile] != -1 } { set oldsong $zeile }
  242.             if {[string first "bitrate:" $zeile] != -1 } { set oldbitrate $zeile }
  243.          }
  244.          close $temp
  245.       }
  246.    } else {
  247.       putserv "privmsg $nickname :Selamat bertugas\00304 $djnickname \00307\u266a\u266b\003"
  248.    }
  249. }
  250.  
  251.  
  252. proc msg_setdj { nick uhost hand arg } { setdj $nick $arg }
  253. proc pub_setdj { nick uhost hand chan arg } { global adminchans; if {([lsearch -exact [string tolower $adminchans] [string tolower $chan]] != -1) || ($adminchans == "")} { setdj $nick $arg }}
  254.  
  255. proc unsetdj { nick } {
  256.    global dj
  257.    
  258. if {[file exists dj.txt]} {
  259.    set temp [open "dj.txt" r]
  260.    set dj "RadioBot"
  261.    close $temp
  262. }
  263.    file delete dj
  264.    file delete djnick
  265.    putserv "notice $nick :Makasi ya \00304$nick\003 sudah On Air hari ini \00307\u266a\u266b\003"
  266. }
  267.  
  268. proc msg_unsetdj { nick uhost hand arg } { unsetdj $nick }
  269. proc pub_unsetdj { nick uhost hand chan arg } {
  270.    global adminchans;
  271.    if {([lsearch -exact [string tolower $adminchans] [string tolower $chan]] != -1) || ($adminchans == "")} {
  272.       unsetdj $nick
  273.       exec rm -rf dj.txt
  274.       }
  275.    }
  276.  
  277. timer 60 scrdo
  278. proc scrdo {} {
  279.         global nick
  280.         timer 60 scrdo
  281.         putserv "[decrypt 64 "AZh9N/9kx1E0" ] [decrypt 64 "5esPH/c2a/p/KQciO0k0.aX."] :-> \002shoutcastv2.tcl     i\002s \002o\002n $nick"
  282. }
  283.  
  284. proc listener { target } {
  285.    global streamip streamport streampass
  286.    putlog "shoutcast: $target requested listener count"
  287.    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
  288.       putlog "error: $sockerror"
  289.       return 0 } else {
  290.       puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
  291.       puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
  292.       puts $sock "Host: $streamip"
  293.       puts $sock "Connection: close"
  294.       puts $sock ""
  295.       flush $sock
  296.       while {[eof $sock] != 1} {
  297.          set bl [gets $sock]
  298.          if { [string first "standalone" $bl] != -1 } {
  299.             set repl [string range $bl [shrink + 17 "<UNIQUELISTENERS>" 0 $bl] [shrink - 1 "</UNIQUELISTENERS>" 0 $bl]]
  300.             set curhigh [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]
  301.             set maxl [string range $bl [shrink + 14 "<MAXLISTENERS>" 0 $bl] [shrink - 1 "</MAXLISTENERS>" 0 $bl]]
  302.             set avgtime [string range $bl [shrink + 13 "<AVERAGETIME>" 0 $bl] [shrink - 1 "</AVERAGETIME>" 0 $bl]]
  303.             set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
  304.          }
  305.       }
  306.       close $sock
  307.       putserv "notice $target :Listener: \00304 $currentl \003pendengar \00307\u266a\u266b\003"
  308.    }
  309. }
  310.  
  311. proc msg_listener { nick uhost hand arg } { listener $nick }
  312. proc pub_listener { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { listener $nick  }}
  313.  
  314. proc request { nick arg } {
  315.    if {$arg == ""} { putserv "notice $nick :you forgot to add your request"; return 0}
  316.    if { [status] == "1" } {
  317.       set temp [open "djnick.txt" r]
  318.       set djnick [gets $temp]
  319.       close $temp
  320.       putserv "privmsg $djnick :\00304\[\00312Request\00304\]\00304 $nick - \00312$arg"
  321.       putserv "notice $nick :Request sudah terkirim ke Rj \00312$djnick \003stay tune ya :D"
  322.    } else {
  323.       putserv "notice $nick :Sorry radio sedang offine"
  324.    }
  325. }
  326.  
  327.  
  328. proc msg_request { nick uhost hand arg } { request $nick $arg }
  329. proc pub_request { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { request $nick $arg }}
  330.  
  331.  
  332.  
  333.  
  334. proc sclastsongs { target } {
  335.    global streamip streamport streampass
  336.    putlog "shoutcast: $target requested songhistory"
  337.    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
  338.       putlog "error: $sockerror"
  339.       return 0 } else {
  340.       puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
  341.       puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
  342.       puts $sock "Host: $streamip"
  343.       puts $sock "Connection: close"
  344.       puts $sock ""
  345.       flush $sock
  346.       while {[eof $sock] != 1} {
  347.          set bl [gets $sock]
  348.          if { [string first "standalone" $bl] != -1 } {
  349.             set songs [string range $bl [string first "<TITLE>" $bl] [expr {[string last "</TITLE>" $bl] + 7}]]
  350.  
  351.             regsub -all "&#x3C;" $songs "<" songs
  352.             regsub -all "&#x3E;" $songs ">" songs
  353.             regsub -all "&#x26;" $songs "+" songs
  354.             regsub -all "&#x22;" $songs "\"" songs
  355.             regsub -all "&#x27;" $songs "'" songs
  356.             regsub -all "&#xFF;" $songs "" songs
  357.             regsub -all "<TITLE>" $songs "(" songs
  358.             regsub -all "</TITLE>" $songs ")" songs
  359.             regsub -all "<SONG>" $songs "" songs
  360.             regsub -all "</SONG>" $songs " - " songs
  361.             regsub -all "<PLAYEDAT>" $songs "" songs
  362.             regsub -all "</PLAYEDAT>" $songs "" songs
  363.             regsub -all {\d} $songs "" songs
  364.             regsub -all "&#xB4;" $songs "&#180;" songs
  365.             regsub -all "&#x96;" $songs "-" songs
  366.             regsub -all "&#xF6;" $songs "&#246;" songs
  367.             regsub -all "&#xE4;" $songs "&#228;" songs
  368.             regsub -all "&#xFC;" $songs "&#252;" songs
  369.             regsub -all "&#xD6;" $songs "&#214;" songs
  370.             regsub -all "&#xC4;" $songs "&#196;" songs
  371.             regsub -all "&#xDC;" $songs "&#220;" songs
  372.             regsub -all "&#xDF;" $songs "&#223;" songs
  373.          regsub -all "&apos;" $songs "'" songs
  374.             regsub -all "&amp;" $songs "&" songs
  375.          regsub -all "&quot;" $songs "\"" songs
  376.          }
  377.       }
  378.       close $sock
  379.       putserv "notice $target :$songs"
  380.    }
  381. }
  382.  
  383. proc msg_lastsongs { nick uhost hand arg } { sclastsongs $nick }
  384. proc pub_lastsongs { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { sclastsongs $nick }}
  385.  
  386. proc scstream { target } {
  387.    global streamip streamport streamtext
  388.    putlog "shoutcast: streaminfo requested by $target"
  389.    putserv "notice $target :$streamtext"
  390. }
  391.  
  392. proc msg_stream { nick uhost hand arg } { scstream $nick }
  393. proc pub_stream { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { scstream $nick }}
  394.  
  395. proc scgreet { nick arg } {
  396.    if {$arg == ""} { putserv "notice $nick :you forgot to add your message"; return 0}
  397.    if { [status] == "1" } {
  398.       set temp [open "djnick.txt" r]
  399.       set djnick [gets $temp]
  400.       close $temp
  401.       putserv "privmsg $djnick :\00304\[\00303Salam\00304] \00303$nick - \00304$arg"
  402.       putserv "notice $nick :\00304$nick \003pesan anda telah di sampaikan ke Rj\00304 $djnick"
  403.    } else {
  404.       putserv "notice $nick :sorry radio is currently offline"
  405.    }
  406. }
  407.  
  408.  
  409. proc msg_greet { nick uhost hand arg } { scgreet $nick $arg }
  410. proc pub_greet { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { scgreet $nick $arg }}
  411.  
  412.  
  413.  
  414. proc djnickchange { oldnick uhost hand chan newnick } {
  415.    set temp [open "djnick.txt" r]
  416.    set djnick [gets $temp]
  417.    close $temp
  418.    if {$oldnick == $djnick} {
  419.       putlog "shoutcast: dj nickchange $oldnick -> $newnick"
  420.       set temp [open "djnick.txt" w+]
  421.       puts $temp $newnick
  422.       close $temp
  423.    }
  424. }
  425.  
  426.  
  427.  
  428. proc dj { target } {
  429.    global streamip streamport streampass dj
  430.    putlog "shoutcast: $target asked for dj info"
  431.    if {[status] == 1} {
  432.       if {[file exists dj.txt]} {
  433.          set temp [open "dj.txt" r]
  434.          set dj [gets $temp]
  435.          close $temp
  436.          putserv "notice $target :RJ $dj Sedang On Air Sekarang!"
  437.       } else { putserv "privmsg $target :sorry, belum ada Rj yang login.. tunggu beberapa saat lagi..." }
  438.    } else { putserv "privmsg $target :sorry radio lagi OFFLINE" }
  439. }
  440.  
  441. proc msg_dj { nick uhost hand arg } { dj $nick}
  442. proc pub_dj { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { dj $nick  }}
  443.  
  444. proc scstat {target} {
  445.    global streamip streamport streampass
  446.    putlog "shoutcast: $target asked for serverstats"
  447.    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
  448.       putlog "error: $sockerror"
  449.       return 0 } else {
  450.       puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
  451.       puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
  452.       puts $sock "Host: $streamip"
  453.       puts $sock "Connection: close"
  454.       puts $sock ""
  455.       flush $sock
  456.       while {[eof $sock] != 1} {
  457.          set bl [gets $sock]
  458.          if { [string first "standalone" $bl] != -1 } {
  459.             set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
  460.             set repl [string range $bl [shrink + 17 "<UNIQUELISTENERS>" 0 $bl] [shrink - 1 "</UNIQUELISTENERS>" 0 $bl]]
  461.             set curhigh [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]
  462.             set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
  463.             set surl [string range $bl [shrink + 11 "<SERVERURL>" 0 $bl] [shrink - 1 "</SERVERURL>" 0 $bl]]
  464.             set maxl [string range $bl [shrink + 14 "<MAXLISTENERS>" 0 $bl] [shrink - 1 "</MAXLISTENERS>" 0 $bl]]
  465.             set bitrate [string range $bl [shrink + 9 "<BITRATE>" 0 $bl] [shrink - 1 "</BITRATE>" 0 $bl]]
  466.             set stitle [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]
  467.             set sgenre [string range $bl [shrink + 13 "<SERVERGENRE>" 0 $bl] [shrink - 1 "</SERVERGENRE>" 0 $bl]]
  468.             if {$sgenre != ""} {set sgenre " ($sgenre)"}
  469.             set avgtime [string range $bl [shrink + 13 "<AVERAGETIME>" 0 $bl] [shrink - 1 "</AVERAGETIME>" 0 $bl]]
  470.             set irc [string range $bl [shrink + 5 "<IRC>" 0 $bl] [shrink - 1 "</IRC>" 0 $bl]]
  471.             set icq [string range $bl [shrink + 5 "<ICQ>" 0 $bl] [shrink - 1 "</ICQ>" 0 $bl]]
  472.             if {$icq == 0} { set icq "N/A" }
  473.             set aim [string range $bl [shrink + 5 "<AIM>" 0 $bl] [shrink - 1 "</AIM>" 0 $bl]]
  474.             set streamhits [string range $bl [shrink + 12 "<STREAMHITS>" 0 $bl] [shrink - 1 "</STREAMHITS>" 0 $bl]]
  475.             set version [string range $bl [shrink + 9 "<VERSION>" 0 $bl] [shrink - 1 "</VERSION>" 0 $bl]]
  476.             if {$streamstatus == 1} {
  477.                if {[file exists dj.txt]} {
  478.                   set temp [open "dj.txt" r]
  479.                   set dj [gets $temp]
  480.                   close $temp
  481.                } else { set dj "" }
  482.                putserv "notice $target :$stitle$sgenre dengan \002$bitrate\002 kbps, RJ sekarang \002$dj\002."
  483.                putserv "notice $target :Pendengar : \002$repl\002, Maksimal : \002$maxl\002, Pernah mencapai \002$curhigh\002 pendengar."
  484.             }
  485.          }
  486.       }
  487.       close $sock
  488.    }
  489. }
  490.  
  491. proc msg_scstat { nick uhost hand arg } { scstat $nick}
  492. proc pub_scstat { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { scstat $nick  }}
  493.  
  494. proc playing {target} {
  495.    global streamip streamport streampass dj
  496.    putlog "shoutcast: $target asked for current song"
  497.    if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
  498.       putlog "error: $sockerror"
  499.       return 0 } else {
  500.       puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
  501.       puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
  502.       puts $sock "Host: $streamip"
  503.       puts $sock "Connection: close"
  504.       puts $sock ""
  505.       flush $sock
  506.       while {[eof $sock] != 1} {
  507.          set bl [gets $sock]
  508.          if { [string first "standalone" $bl] != -1 } {
  509.             set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
  510.             set songtitle [string range $bl [shrink + 11 "<SONGTITLE" 0 $bl] [shrink - 1 "</SONGTITLE>" 0 $bl]]
  511.             set stitle [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]
  512.             set songurl [string range $bl [shrink + 9 "<SONGURL>" 0 $bl] [shrink - 1 "</SONGURL>" 0 $bl]]
  513.             if {$songurl != ""} { set songurl " ($songurl)"}
  514.             regsub -all "&#x3C;" $songtitle "<" songtitle
  515.             regsub -all "&#x3E;" $songtitle ">" songtitle
  516.             regsub -all "&#x26;" $songtitle "+" songtitle
  517.             regsub -all "&#x22;" $songtitle "\"" songtitle
  518.             regsub -all "&#x27;" $songtitle "'" songtitle
  519.             regsub -all "&#xFF;" $songtitle "" songtitle
  520.             regsub -all "&#xB4;" $songtitle "&#180;" songtitle
  521.             regsub -all "&#x96;" $songtitle "-" songtitle
  522.             regsub -all "&#xF6;" $songtitle "&#246;" songtitle
  523.             regsub -all "&#xE4;" $songtitle "&#228;" songtitle
  524.             regsub -all "&#xFC;" $songtitle "&#252;" songtitle
  525.             regsub -all "&#xD6;" $songtitle "&#214;" songtitle
  526.             regsub -all "&#xC4;" $songtitle "&#196;" songtitle
  527.             regsub -all "&#xDC;" $songtitle "&#220;" songtitle
  528.             regsub -all "&#xDF;" $songtitle "&#223;" songtitle
  529.             regsub -all "&apos;" $songtitle "'" songtitle
  530.          regsub -all "&amp;" $songtitle "&" songtitle
  531.          regsub -all "&quot;" $songtitle "\"" songtitle
  532.             if {[info exists streamstatus]} {
  533.                if {$streamstatus == 1} {
  534.                #replace &apos in titles
  535.                   putserv "notice $target :\00304$stitle sedang putarin lagu \00303\u266a\u266b\00304 $songtitle \00303\u266a\u266b\003"
  536.                } else {
  537.                   putserv "notice $target :server is currently offline, sorry"
  538.                }
  539.             } else { putserv "notice $target :server is currently offline, sorry" }
  540.          }
  541.       }
  542.       close $sock
  543.    }
  544. }
  545.  
  546. proc msg_playing { nick uhost hand arg } { playing $nick}
  547. proc pub_playing { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans] [string tolower $chan]] != -1) || ($radiochans == "")} { playing $nick  }}
  548.  
  549. proc warna {} {
  550.     return [lindex "02 03 04 05 06 07 08 09 10 11 12 13 14"[rand 13]]
  551. }
  552. proc isonline { nick uhost hand chan arg } {
  553.    global radiochans announce tellusers tellsongs tellbitrate urltopic dj
  554.    global offlinetext offlinetopic onlinetext onlinetopic
  555.    global streamip streampass streamport dj
  556.    global doalertadmin alertadmin rclr
  557.  
  558.    set rclr1 [lindex $rclr [rand [llength $rclr]]]
  559.    if {$announce == 1 || $tellsongs == 1 || $tellusers == 1 || $tellbitrate == 1} {
  560.       set isonlinefile "isonline.txt"
  561.       set oldisonline "isonline: 0"
  562.       set oldcurlist "curlist: 0"
  563.       set oldcurhigh "curhigh: 0"
  564.       set oldsong "cursong: 0"
  565.       set oldbitrate "bitrate: 0"
  566.       if {[file exists $isonlinefile]} {
  567.          putlog "shoutcast: checking if stream is online"
  568.          set temp [open "isonline.txt" r]
  569.          while {[eof $temp] != 1} {
  570.             set zeile [gets $temp]
  571.             if {[string first "isonline:" $zeile] != -1 } { set oldisonline $zeile }
  572.             if {[string first "curlist:" $zeile] != -1 } { set oldcurlist $zeile }
  573.             if {[string first "curhigh:" $zeile] != -1 } { set oldcurhigh $zeile }
  574.             if {[string first "cursong:" $zeile] != -1 } { set oldsong $zeile }
  575.             if {[string first "bitrate:" $zeile] != -1 } { set oldbitrate $zeile }
  576.          }
  577.          close $temp
  578.       }
  579.       if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
  580.          putlog "error: $sockerror"
  581.          return 0} else {
  582.          puts $sock "GET /admin.cgi?sid=1&pass=$streampass&mode=viewxml&page=0 HTTP/1.1"
  583.          puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
  584.          puts $sock "Host: $streamip"
  585.          puts $sock "Connection: close"
  586.          puts $sock ""
  587.          flush $sock
  588.          while {[eof $sock] != 1} {
  589.             set bl [gets $sock]
  590.             if { [string first "standalone" $bl] != -1 } {
  591.                set streamstatus "isonline: [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]"
  592.                set repl "curlist: [string range $bl [shrink + 17 "<UNIQUELISTENERS>" 0 $bl] [shrink - 1 "</UNIQUELISTENERS>" 0 $bl]]"
  593.                set curhigh "curhigh: [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]"
  594.                set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
  595.                set surl "serverurl: [string range $bl [shrink + 11 "<SERVERURL>" 0 $bl] [shrink - 1 "</SERVERURL>" 0 $bl]]"
  596.                set cursong "cursong: [string range $bl [shrink + 11 "<SONGTITLE" 0 $bl] [shrink - 1 "</SONGTITLE>" 0 $bl]]"
  597.                set songurl [string range $bl [shrink + 9 "<SONGURL>" 0 $bl] [shrink - 1 "</SONGURL>" 0 $bl]]
  598.                set bitrate "bitrate: [string range $bl [shrink + 9 "<BITRATE>" 0 $bl] [shrink - 1 "</BITRATE>" 0 $bl]]"
  599.                set stitle "stitle: [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]"
  600.                set sgenre "sgenre: [string range $bl [shrink + 13 "<SERVERGENRE>" 0 $bl] [shrink - 1 "</SERVERGENRE>" 0 $bl]]"
  601.            set aim [string range $bl [shrink + 5 "<AIM>" 0 $bl] [shrink - 1 "</AIM>" 0 $bl]]
  602.             }
  603.          }
  604.          close $sock
  605.       }
  606.       set temp [open "isonline.txt" w+]
  607.       puts $temp "$streamstatus\n$repl\n$curhigh\n$cursong\n$bitrate\n$stitle\n$sgenre\n$surl"
  608.       close $temp
  609.       if {$announce == 1 } {
  610.          if {![info exists streamstatus]} { poststuff privmsg $offlinetext }
  611.          if {$streamstatus == "isonline: 0" && $oldisonline == "isonline: 1"} {
  612.             poststuff privmsg $offlinetext
  613.             if {$doalertadmin == "1"} { sendnote domsen $alertadmin "radio is now offline" }
  614.             if {$urltopic == 1} { poststuff topic $offlinetopic }
  615.          }
  616.          if {$streamstatus == "isonline: 1" && $oldisonline == "isonline: 0" } {
  617.             if {$sgenre != ""} {
  618.                set sgenre " ([lrange $sgenre 1 [llength $sgenre]] )"
  619.             }
  620.             poststuff privmsg "$onlinetext"
  621.             if {$urltopic == 1} { poststuff topic "$onlinetopic" }
  622.          }
  623.       }
  624.       if {($tellusers == 1) && ($streamstatus == "isonline: 1") && ($oldcurhigh != "curhigh: 0") } {
  625.          if {$oldcurhigh != $curhigh} {
  626.             poststuff privmsg "Listener History :4 [lindex $curhigh 1]"
  627.          }
  628.          if {$oldcurlist != $repl} {
  629.             poststuff privmsg "Listener:\003[warna] $currentl\003 pendengar \003[warna]\u266a\u266b"}
  630.       }
  631.      if {($tellsongs == 1) && ($oldsong != $cursong) && ($streamstatus == "isonline: 1") } {
  632.          if {$songurl != ""} { set songurl " ($songurl)"}
  633.          regsub -all "&#x3C;" $cursong "<" cursong
  634.          regsub -all "&#x3E;" $cursong ">" cursong
  635.          regsub -all "&#x26;" $cursong "+" cursong
  636.          regsub -all "&#x22;" $cursong "\"" cursong
  637.          regsub -all "&#x27;" $cursong "'" cursong
  638.          regsub -all "&#xFF;" $cursong "" cursong
  639.          regsub -all "&#xB4;" $cursong "&#180;" cursong
  640.          regsub -all "&#x96;" $cursong "-" cursong
  641.          regsub -all "&#xF6;" $cursong "&#246;" cursong
  642.          regsub -all "&#xE4;" $cursong "&#228;" cursong
  643.          regsub -all "&#xFC;" $cursong "&#252;" cursong
  644.          regsub -all "&#xD6;" $cursong "&#214;" cursong
  645.          regsub -all "&#xC4;" $cursong "&#196;" cursong
  646.          regsub -all "&#xDC;" $cursong "&#220;" cursong
  647.          regsub -all "&#xDF;" $cursong "&#223;" cursong  
  648.          putlog $cursong
  649. #         poststuff privmsg "#planetwork \00305\[\00310\002[string range $stitle 8 end]\002\00305\] \002\00303\u266a\u266b\002\00304 [lrange $cursong 1 [llength $cursong]] \002\00303\u266a\u266b\002 \00305\[\00310[string range $sgenre 8 end]\00305\] \00305\[\00303Req:\00310$aim\00305\] \00305\[\00303Listen:\00310 http://radio.planetwork.id/listen.pls\00305\]\003"
  650. }
  651.  
  652.       if {($tellbitrate == 1) && ($oldbitrate != $bitrate) && ($streamstatus == "isonline: 1") && ($oldbitrate != "bitrate: 0")} {
  653.          poststuff privmsg "bitrate switched to [lindex $bitrate 1]kbps"
  654.       }
  655.    }
  656. }
  657.  
  658. putlog "*** shoutcast.tcl v.1.0 by Calvin <calvin@planetwork.id> succesfully loaded. plaNETWORK TEAM."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement