This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Tcl that Annonce Current Song playing

Old posts that have not been replied to for several years.
Z
ZahoOL
Voice
Posts: 7
Joined: Fri May 23, 2003 1:30 am

Tcl that Annonce Current Song playing

Post by ZahoOL »

hello ,

I am looking for a tcl that returns the Current song in a channel . (all the scripts works with triggers)

Possible script that can be modified is

shoutcast1.03
radio.tcl


Cheers,

Adam
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

I Wrote this script some time ago as i could not find a decent shoutcast script
I haven't tried it in a long time and it was written for version 1.6.15 Eggdrop. I also dont know if this will work on Windrop or not as i never tried it.

Hope this is what you are looking for.

Code: Select all

# ------------------------------------------------------------------------ #
# Shoutcast BotScript v1.0                                                 #
# By ^DooM^                                                                #
# ------------------------------------------------------------------------ #
# Designed to operate with Eggdrop 1.6.15                                  #
# ------------------------------------------------------------------------ #
set shoutcast(vershort)             "1.0"
set shoutcast(verlong)              "010000"

# ------------------------------------------------------------------------
# Configuration settings!
# ------------------------------------------------------------------------
# Access flag specifiers
set shoutcast(perm_operator)         "D"
set shoutcast(perm_anyone)           "-"

# Command Character (Prepends the command itself, i.e. '!'addserver
set shoutcast(command_char)          "!"

# Help trigger
set shoutcast(help_trigger)          "$shoutcast(command_char)help"

# The details for the interface servers
set shoutcast(interface_page)        "/admin.cgi?mode=viewxml"
set shoutcast(kickdj_page)           "/admin.cgi?mode=kicksrc"
set shoutcast(admin_page)            "/admin.cgi"
set shoutcast(listen_page)           "/listen.pls"
set shoutcast(interface_user_agent)  "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"

# Channel to display in
set shoutcast(broadcast_channel)     "#yourchannel"

# Not designed to be filled out by you... Yes that means you!
set sc_servercount  0

# Server Lists (Host, Name, Port, Password etc)
set sc_servers($sc_servercount,Host) "shoutcast.shoutcast.com"
set sc_servers($sc_servercount,Name) "shoutcast.shoutcast.com"
set sc_servers($sc_servercount,Port) "8080"
set sc_servers($sc_servercount,Pass) "password"
incr sc_servercount

# Add as many as you want.
#set sc_servers($sc_servercount,Host) "192.168.0.100"
#set sc_servers($sc_servercount,Name) "shoutcast2.shoutcast.com"
#set sc_servers($sc_servercount,Port) "8000"
#set sc_servers($sc_servercount,Pass) "password"
#incr sc_servercount

# Which is the primary server (retrieves playing stats etc from)
set shoutcast(primary_server)        0

# Number of milliseconds to wait for page request timeout
set shoutcast(page_timeout)          4000

# ------------------------------------------------------------------------
# Eggdrop Bindings (Pubs and Msgs are bound separately to ensure full
# support on most eggdrops, and to workaround several painful bugs).
# ------------------------------------------------------------------------
bind pub $shoutcast(perm_anyone)   [string trim $shoutcast(command_char)]stream         sc_stream
bind pub $shoutcast(perm_anyone)   [string trim $shoutcast(command_char)]playing        sc_playing
bind pub $shoutcast(perm_anyone)   [string trim $shoutcast(command_char)]users          sc_userstats
bind pub $shoutcast(perm_anyone)   [string trim $shoutcast(command_char)]help           sc_help

bind pub $shoutcast(perm_operator) [string trim $shoutcast(command_char)]sckickdj       sc_kickdj
bind pub $shoutcast(perm_operator) [string trim $shoutcast(command_char)]scwho          sc_who

bind time - "* * * * *" sc_update

# --------------------------------
# Global Variables - DO NOT TOUCH!
# --------------------------------
set sc_sock               0
set sc_packet_count       0
set sc_page_dump_complete 0
set sc_buffer             ""
set sc_laststatus         0
set sc_lasttitle          ""
set sc_lastsong           ""
set sc_lastbitrate        0

# Setup global array data
for {set i 0} {$i < $sc_servercount} {incr i} {
    set sc_responses($i,lastlistenercount) 0
}

proc sc_help { nick uhost handle channel args } {

    set strCommand "help"
    set args [string map -nocase {"\\" "\\\\"} $args]
    set args [lindex $args 0]
    set strHelp [sc_get_usage [lindex $args 0] [sc_isop $nick]]
    sc_output $nick $channel $strHelp
    return
}

proc sc_update { minute hour day month year } {

    global shoutcast botnick sc_responses sc_servers  sc_servercount
    global sc_lastsong sc_lastbitrate sc_laststatus sc_lasttitle

    set strCommand "update"
    set outArgs ""
    if { [sc_execute_command [clock seconds] $strCommand "" "" $shoutcast(broadcast_channel) $outArgs] == 0 } {
        putlog "Unable to execute update command."
        return
    }

    set iServer     $shoutcast(primary_server)
    set strTopic    ""
    set updateTopic 0
    if { $sc_responses($iServer,streamstatus) == 1 } {        
        
        if { $sc_responses($iServer,songtitle) != $sc_lastsong } {
            set sc_lastsong $sc_responses($iServer,songtitle)
            set strStream "Now Playing: $sc_responses($iServer,songtitle)"
            sc_output "" $shoutcast(broadcast_channel) $strStream
        }

        
        if { $sc_laststatus != 1 || $sc_lasttitle != $sc_responses($iServer,servertitle) || $sc_lastbitrate != $sc_responses($iServer,bitrate) } {
            set    strTopic "$sc_responses($iServer,servertitle) Online @ $sc_responses($iServer,bitrate)kbps - "
            append strTopic "http://$sc_servers($iServer,Name):$sc_servers($iServer,Port)$shoutcast(listen_page)"
            set updateTopic 1
        }
        set sc_laststatus  1
        set sc_lastbitrate $sc_responses($iServer,bitrate)
        set sc_lasttitle   $sc_responses($iServer,servertitle)
    } else {
        if { $sc_laststatus != 0 } {
            set strTopic "Shoutcast: Offline"
            set updateTopic 1
        }
        set sc_laststatus  0
        set sc_lastbitrate 0
    } 
    if { $updateTopic == 1 } { 
        putserv "PRIVMSG $shoutcast(broadcast_channel) :$strTopic" 
        }
    for { set i 0 } { $i < $sc_servercount } { incr i } {
       if { $sc_responses($i,streamstatus) == 1 } {     
            if { $sc_responses($i,currentlisteners) != $sc_responses($i,lastlistenercount) } {
                set sc_responses($i,lastlistenercount) $sc_responses($i,currentlisteners)
                set strStream "$sc_servers($i,Name) - $sc_responses($i,currentlisteners) of $sc_responses($i,maxlisteners) connected (peaking at $sc_responses($i,peaklisteners))"
                if { $sc_responses($i,currentlisteners) > 0 } {
                    append strStream ", utilising "
                    set iBandwidth [expr [expr $sc_responses($i,currentlisteners) * $sc_responses($i,bitrate)] / 8]
                    append strStream "$iBandwidth k/sec, for an average of [duration $sc_responses($i,averagetime)]."
                }
                sc_output "" $shoutcast(broadcast_channel) $strStream
            }
        }
    }
    return
}

proc sc_stream { nick uhost handle channel args } {

    global shoutcast botnick sc_servers sc_responses sc_servercount
    set strCommand "stream"
    set args [string map -nocase {"\\" "\\\\"} $args]
    set args [lindex $args 0]
    set outArgs ""
    if { [sc_execute_command [clock seconds] $strCommand $nick $uhost $channel $outArgs] == 0 } {
        sc_output $nick $channel "Unable to execute command."
        return
    }
    for { set i 0 } { $i < $sc_servercount } { incr i } {
        set strStream "[expr $i + 1]) http://$sc_servers($i,Name):$sc_servers($i,Port)$shoutcast(listen_page) - "
        if { $sc_responses($i,streamstatus) == 0 } {
            append strStream "Offline"
            sc_output $nick $channel $strStream
            continue
        } else {
            append strStream "Online @ $sc_responses($i,bitrate)kbps - "
        }
        set iSlotsFree [expr $sc_responses($i,maxlisteners) - $sc_responses($i,currentlisteners)]
        if { $iSlotsFree == 0 } {
            append strStream "Server full."
            sc_output $nick $channel $strStream
            continue
        } else {
            set strAppend ""
            if { $iSlotsFree > 1 } { set strAppend "s" }
            append strStream "$iSlotsFree slot$strAppend remaining."
        }
        sc_output $nick $channel $strStream
    }
    return
}

proc sc_playing { nick uhost handle channel args } {

    global shoutcast botnick sc_servers sc_responses sc_servercount
    set strCommand "playing"
    set args [string map -nocase {"\\" "\\\\"} $args]
    set args [lindex $args 0]
    set outArgs ""
    if { [sc_execute_command [clock seconds] $strCommand $nick $uhost $channel $outArgs] == 0 } {
        sc_output $nick $channel "Unable to execute command."
        return
    }
    set iServer $shoutcast(primary_server)
    set strStream "Primary server is currently offline."
    if { $sc_responses($iServer,streamstatus) == 1 } {
        set strStream "Currently Playing: $sc_responses($iServer,songtitle)"
    }
    sc_output $nick $channel $strStream
}

proc sc_userstats { nick uhost handle channel args } {

    global shoutcast botnick sc_servers sc_responses sc_servercount
    set strCommand "users"
    set args [string map -nocase {"\\" "\\\\"} $args]
    set args [lindex $args 0]
    set outArgs ""
    if { [sc_execute_command [clock seconds] $strCommand $nick $uhost $channel $outArgs] == 0 } {
        sc_output $nick $channel "Unable to execute command."
        return
    }
    set iServersFound 0
    for { set i 0 } { $i < $sc_servercount } { incr i } {
        if { $sc_responses($i,streamstatus) == 0 } { continue }
        set strStream "$sc_servers($i,Name) - $sc_responses($i,currentlisteners) of $sc_responses($i,maxlisteners) connected (peaking at $sc_responses($i,peaklisteners)), utilising "
        set iBandwidth [expr [expr $sc_responses($i,currentlisteners) * $sc_responses($i,bitrate)] / 8]
        append strStream "$iBandwidth k/sec, for an average of [duration $sc_responses($i,averagetime)]."
        sc_output $nick $channel $strStream
        incr iServersFound
    }
    if { $iServersFound == 0 } { sc_output $nick $channel "No active servers to list." }
    return
}

proc sc_kickdj { nick uhost handle channel args } {

    global shoutcast botnick sc_servers
    set strCommand "sckickdj"
    set args [string map -nocase {"\\" "\\\\"} $args]
    set args [lindex $args 0]
    set outArgs ""
    if { [sc_execute_command [clock seconds] $strCommand $nick $uhost $channel $outArgs] == 0 } {
        sc_output $nick $channel "Unable to execute command."
        return
    }
    sc_output $nick $channel "DJ kicked from primary server."
}

proc sc_who { nick uhost handle channel args } {

    global shoutcast botnick sc_servers sc_responses sc_servercount
    set strCommand "scwho"
    set args [string map -nocase {"\\" "\\\\"} $args]
    set args [lindex $args 0]
    set outArgs ""
    if { [sc_execute_command [clock seconds] $strCommand $nick $uhost $channel $outArgs] == 0 } {
        sc_output $nick $channel "Unable to execute command."
        return
    }
    set iServersFound 0
    for { set i 0 } { $i < $sc_servercount } { incr i } {
        if { $sc_responses($i,streamstatus) == 0 } { continue }
        set    strStream "http://$sc_servers($i,Name):$sc_servers($i,Port)$shoutcast(admin_page)\n"
        append strStream "[string repeat "-" [expr [string length $strStream] - 1]][string repeat " " $i]\n"
        if { $sc_responses($i,listenerhosts) == "" } {
            append strStream "No listeners currently connected."
        } else {
            set counter 1
            foreach listener $sc_responses($i,listenerhosts) {
                append strStream "$counter) [sc_nickfromhost $listener][string repeat " " $i][string repeat " " $counter]\n"
                incr counter
            }        	
        }
        append strStream "[string repeat " " [expr $i + 1]]\n"
        sc_output $nick $channel $strStream
        incr iServersFound
    }
    if { $iServersFound == 0 } { sc_output $nick $channel "No active servers to list." }
    return
}

# ************************************************************************
#  Script utility functions.
# ************************************************************************
proc sc_get_usage { command ischannelop } {

    global shoutcast botnick
    set command [string tolower $command]
    set strMessage ""
    if { $ischannelop && $command == "scwho" } { 
        append strMessage "Usage for $shoutcast(command_char)scwho follows.\n"
        append strMessage "------------------------------------------------------------------\n"
        append strMessage "Retrieves the list of people (nicks / hosts) currently listening\n"
        append strMessage "------------------------------------------------------------------  "
        
    } elseif { $command == "sckickdj" } { 
            
        append strMessage "Usage for $shoutcast(command_char)sckickdj follows.\n"
        append strMessage "------------------------------------------------------------------\n"
        append strMessage "Kicks the source from the server!\n"
        append strMessage "------------------------------------------------------------------  "

    } elseif { $command == "stream" } { 
            
        append strMessage "Usage for $shoutcast(command_char)stream follows.\n"
        append strMessage "------------------------------------------------------------------\n"
        append strMessage "Lists current streams.\n"
        append strMessage "------------------------------------------------------------------  "
    
    } elseif { $command == "playing" } { 
            
        append strMessage "Usage for $shoutcast(command_char)playing follows.\n"
        append strMessage "------------------------------------------------------------------\n"
        append strMessage "Shows current song.\n"
        append strMessage "------------------------------------------------------------------  "
    
    } elseif { $command == "users" } { 
            
        append strMessage "Usage for $shoutcast(command_char)users follows.\n"
        append strMessage "------------------------------------------------------------------\n"
        append strMessage "Shows user stats for all streams.\n"
        append strMessage "------------------------------------------------------------------  "

    } elseif { $ischannelop } {
            
        append strMessage "Available operator commands follow.\n"
        append strMessage "For help on specific Commands type !help <Command>.\n"
        append strMessage "-------------------------------------------------------------\n"
        append strMessage " !scwho          "
        append strMessage " !sckickdj       "
        append strMessage " !stream         "
        append strMessage " !users          "
        append strMessage " !playing        \n"
        append strMessage "------------------------------------------------------------- "

    } else {
            
        append strMessage "Available user commands follow.\n"
        append strMessage "For help on specific Commands type !help <Command>.\n"
        append strMessage "-------------------------------------------------------------\n"
        append strMessage " !stream        "
        append strMessage " !users         "
        append strMessage " !playing       \n"
        append strMessage "------------------------------------------------------------- "
        
    }

    return [string trim $strMessage "\n"]
}

proc sc_execute_command { timestamp command nick uhost channel args } {

    global shoutcast sc_servers
    set args [lindex $args 0]
    switch -- $command {
        "stream" { 
            sc_get_stats 0
        }
        "users" { 
            sc_get_stats 0
        }
        "scwho" { 
            sc_get_stats 0
        }
        "update" {
            sc_get_stats 0
        }
        "playing" {
            sc_get_stats 1
        }
        "sckickdj" {
            set strHost $sc_servers($shoutcast(primary_server),Host);
            set strPort $sc_servers($shoutcast(primary_server),Port);
            set strPass $sc_servers($shoutcast(primary_server),Pass);
            set strPageData [sc_get_page $strHost $strPort "$shoutcast(kickdj_page)&pass=$strPass"]
            if { $strPageData == "" } { return 0 }
        }
        default {
            return 1
        }

    }
    return 1
}

proc sc_get_stats { primary_only } {

    global shoutcast sc_servers sc_responses sc_servercount
    for { set i 0 } { $i < $sc_servercount } { incr i } {
        if { $primary_only == 1 && $i != $shoutcast(primary_server) } { continue }
        set strHost $sc_servers($i,Host);
        set strPort $sc_servers($i,Port);
        set strPass $sc_servers($i,Pass);
        set strPageData [sc_get_page $strHost $strPort "$shoutcast(interface_page)&pass=$strPass"]
        if { $strPageData == "" } { 
            set sc_responses($i,streamstatus)        0
            set sc_responses($i,currentlisteners)    0
            set sc_responses($i,maxlisteners)        0
            set sc_responses($i,peaklisteners)       0
            set sc_responses($i,averagetime)         0
            set sc_responses($i,servergenre)         ""
            set sc_responses($i,serverurl)           "http://$sc_servers($i,Name):$sc_servers($i,Port)$shoutcast(listen_page)"
            set sc_responses($i,servertitle)         ""
            set sc_responses($i,songtitle)           ""
            set sc_responses($i,bitrate)             ""
            set sc_responses($i,version)             ""
            set sc_responses($i,listenerhosts)       ""
            set sc_responses($i,lastlistenercount)   0

            # Bail
            continue
            
        }
        sc_parse_xml $strPageData $i sc_responses
    }
}

proc sc_parse_xml { pagedata serverNumber outArray } {

    upvar $outArray serverData
    regexp "<STREAMSTATUS>(.*?)</STREAMSTATUS>" $pagedata data value
    set serverData($serverNumber,streamstatus) $value
    regexp "<CURRENTLISTENERS>(.*?)</CURRENTLISTENERS>" $pagedata data value
    set serverData($serverNumber,currentlisteners) $value
    regexp "<MAXLISTENERS>(.*?)</MAXLISTENERS>" $pagedata data value
    set serverData($serverNumber,maxlisteners) $value
    regexp "<PEAKLISTENERS>(.*?)</PEAKLISTENERS>" $pagedata data value
    set serverData($serverNumber,peaklisteners) $value
    regexp "<SERVERGENRE>(.*?)</SERVERGENRE>" $pagedata data value
    set serverData($serverNumber,servergenre) $value
    regexp "<SERVERURL>(.*?)</SERVERURL>" $pagedata data value
    set serverData($serverNumber,serverurl) $value
    regexp "<SERVERTITLE>(.*?)</SERVERTITLE>" $pagedata data value
    set serverData($serverNumber,servertitle) $value
    regexp "<SONGTITLE>(.*?)</SONGTITLE>" $pagedata data value

    # Repair the song title (i.e. remove all XML elements)
    # Specify remap template
    set charRemap {
        "<" "<"
        ">" ">"
        "&" "&"
        """ "\\"
        "'" "'"
        "ÿ" ""
    }

    set value [string map -nocase $charRemap $value]
    set serverData($serverNumber,songtitle) $value
    regexp "<BITRATE>(.*?)</BITRATE>" $pagedata data value
    set serverData($serverNumber,bitrate) $value
    regexp "<VERSION>(.*?)</VERSION>" $pagedata data value
    set serverData($serverNumber,version) $value
    set serverData($serverNumber,averagetime)   0
    set serverData($serverNumber,listenerhosts) ""
    set lstListener                             ""
    set connectCount                            0
    if { [regexp "<LISTENERS>(.*?)</LISTENERS>" $pagedata data value] } {
        set listenerdata $value
        regsub -all "</LISTENER>" $listenerdata "</LISTENER>\n" listenerdata
        set listenerdata [split $listenerdata \n]
        foreach strListener $listenerdata {

            if { [regexp "<HOSTNAME>(.*?)</HOSTNAME>" $strListener data value] } { lappend lstListener $value }
            if { [regexp "<CONNECTTIME>(.*?)</CONNECTTIME>" $strListener data value] } { 
                incr serverData($serverNumber,averagetime) $value
                incr connectCount
            }
        }
        if { $connectCount > 0 } { set serverData($serverNumber,averagetime) [expr $serverData($serverNumber,averagetime) / $connectCount] }
    }
    set serverData($serverNumber,listenerhosts) $lstListener
}

proc sc_output { nick channel msg } {

    global shoutcast
    set strPrepend "PRIVMSG $channel :"
    set line_array [split $msg "\n"]
    foreach line $line_array { putserv "$strPrepend$line" }
}

# ------------------------------------------------------------------------
# Desc : Retrieve any data from any arbitrary page on any server / port.
# Note : Yes I know TCL 8 has an http API, but I don't want to rely
#        on it being available. It's also not quite as flexible as we need.
# ------------------------------------------------------------------------
proc sc_get_page { host port page } {

    global shoutcast sc_packet_count sc_page_dump_complete sc_sock sc_buffer errorInfo
    set sc_page_dump_complete 0
    set sc_packet_count 0
    set sc_buffer ""
    set urldump_Task [ after $shoutcast(page_timeout) { set sc_page_dump_complete 1; putlog "*** Page data retrieval timed out!" } ]
    if [catch {socket -async $host $port} sc_sock] {
        putlog "Shoutcast Error : $errorInfo"
        after cancel $urldump_Task
        return ""
    }
    fconfigure $sc_sock -blocking 0
    fileevent $sc_sock readable "sc_read_page $sc_sock"
    puts $sc_sock "GET $page HTTP/1.0\nHost: $host\nContent-type: text/plain\nUser-Agent: $shoutcast(interface_user_agent)\n\n"
    if [catch {flush $sc_sock} x] {
        putlog "Shoutcast Error : $errorInfo"
        close $sc_sock
        after cancel $urldump_Task
        return ""
    }
    vwait sc_page_dump_complete
    after cancel $urldump_Task
    catch {close $sc_sock}
    set sc_packet_count 0
    set line_array      [split $sc_buffer "\n"]
    set header_closed   0
    set sc_buffer       ""
    set i               0
    foreach line $line_array {
        if { $header_closed == 0 } {
            switch $i {
                0 {
                    set tokens [split $line " "]
                    set server_code [lindex $tokens 1]
                    putlog "Server responded with $server_code [lrange $tokens 2 end]"
                    if { $server_code != 200 && $server_code != 302 } { return "" }
                }
            }
            if { $line == "" } { set header_closed 1 }
        } else {
            append sc_buffer "$line\n"
        }
        incr i
    }
    regsub -all "\r" $sc_buffer "" sc_buffer
    return [string trim $sc_buffer "\n"]
}

proc sc_read_page socket {

    global sc_packet_count sc_page_dump_complete sc_buffer
    if [eof $socket] { 
        close $socket;
        set sc_packet_count 0
        after idle set sc_page_dump_complete 1
        return;
    }
    gets $socket data
    append sc_buffer "$data\n"
    incr sc_packet_count
}

proc urlencode { text } { 
  
    regsub -all {\%} $text "%25" text 
    set i [string length $text] 
    while {([regexp -nocase {[^a-z0-9%]} $text toh])&&!($i < 0 )} { 
        scan "$toh" %c dec 
        regsub -all "\\${toh}" $text "%[format %X $dec]" text 
        incr i -1 
    } 
    if {$i < 0} {putlog "Infinite loop something is very wrong: $text"} 
    return $text 
} 

proc sc_nickfromhost { host } { 
    
    global shoutcast

    set FoundUsers 0
    set NickList   ""
    set DuplicateList ""
    foreach chan [channels] {
        if { ![botonchan $chan] } { continue }
        foreach user [chanlist $chan] {
            if { [string match "* $user *" $DuplicateList] == 1} { continue }
            set uhost "[getchanhost $user $chan]"
            if { [string match -nocase "*@$host" $uhost] } { 
                append DuplicateList " $user "
                if { $FoundUsers == 0 } { 
                    append NickList $user 
                } else {
                	append NickList ", $user"
                }
                incr FoundUsers
            }
        }
    }
    if { $FoundUsers == 0 } { return "*!*@$host" }
    set CharPos [string last , $NickList]
    if { $CharPos == -1} { return $NickList }
    set NickList "[string range $NickList 0 [expr $CharPos - 1]] or [string range $NickList [expr $CharPos + 2] 99999999]"
    return $NickList
}

proc sc_isop { nick } { 
    
    global shoutcast

    foreach chan [channels] {
        if { ![botonchan $chan] } { continue }
        if { [onchan $nick $chan] } {  
            if { [isop $nick $chan] } { return 1 }
        }
    }
    return 0
}

putlog "** Shoutcast Stats Initialising $shoutcast(vershort) By ^DooM^"
Feel free to play around and modify it to your needs. :wink:
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Z
ZahoOL
Voice
Posts: 7
Joined: Fri May 23, 2003 1:30 am

Post by ZahoOL »

^DooM^ u a Star.
Thanks a lot dude !!!
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Oh jebus, you wrote that code all of yourself? You must be having alot of free time on your hand. :P
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

I wrote it whilst I was, shall we say between jobs about 8 months ago trying to occupy my tiny mind lol :wink:
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Z
ZahoOL
Voice
Posts: 7
Joined: Fri May 23, 2003 1:30 am

Post by ZahoOL »

This PHP Script (have to leave it open on a browser, refresh 60 secs) bans users ripping , if there any way to have a bot do the job and annonce it on a channel?
<meta http-equiv="refresh" content="60">
<?php
// Ban rippers
// Martin Holk Rasmussen, mhr@tiscali.dk
//
// Requires PHP4 or higher. Tested with PHP4.3.2 and SHOUTcast Server Version 1.9.2/Linux
// Use and modify as you like

// Server configuration
$server = 'server.address.net';
$portnumber = '8000';
$username = 'admin';
$password = 'password';

// Send e-mail when some one has been banned. Leave blank to disable.
$recipient = 'you@email.com';

// Array of user agents to look for.
// Check is case insensitive and partial, so don't put "winamp" as this will ban all listeners using Winamp
$knownrippers = array ("Streamripper", "FreeAmp", "UnknownPlayer", "Pathfinder", "sr-POSIX/1.32","
<html>
<head><title>Ban rippers</title></head>
<body>
<?php
// Get xml stats
$fp = @fsckopen ($server, $portnumber, $errno, $errstr, 30);
if (!$fp) {
print "Could not connect to $server port $portnumber: $errstr ($errno)<br>\n";
}
else {
fputs ($fp, "GET /admin.cgi?mode=viewxml HTTP/1.1\r\nHost: $server:$portnumber\r\nUser-Agent: Mozilla/4.0\r\nAuthorization: Basic ".base64_encode ("$username:$password")."\r\n\r\n");
while (!feof($fp)) {
$xml .= fgets ($fp,128);
}
fclose ($fp);

if (!preg_match ("/<LISTENERS>(.+)<\/LISTENERS>/", $xml, $regs)) {
print "Could not find information. Possible incorrect username or password.";
exit;
}

$blocks = split ("</LISTENER>", $regs[1]);
array_pop ($blocks);
// Loop through each listener
foreach ($blocks as $block) {
preg_match ("/<USERAGENT>(.+)<\/USERAGENT>/", $block, $regs);
$useragent = $regs[1];
preg_match ("/<POINTER>(.+)<\/POINTER>/", $block, $regs);
$pointer = $regs[1];
preg_match ("/<HOSTNAME>(.+)<\/HOSTNAME>/", $block, $regs);
$hostname = $regs[1];

print "Known ripper found: ";

$ripperfound = false;
foreach ($knownrippers as $lookfor) {
if (stristr ($useragent, $lookfor)) {
$ripperfound = $lookfor;
}
}
// Ripper found. Ban listener.
if ($ripperfound) {
print "$ripperfound for pointer $pointer. Banning ";

$fp = @fsockopen ($server, $portnumber, $errno, $errstr, 30);
if (!$fp) {
print "failed<br>\n";
}
else {
fputs ($fp, "GET /admin.cgi?mode=bandst&bandst=$pointer&banmsk=255 HTTP/1.1\r\nHost: $server:$portnumber\r\nUser-Agent: Mozilla/4.0\r\nAuthorization: Basic ".base64_encode ("$username:$password")."\r\n\r\n");
fclose ($fp);
print "successful!";
if ($recipient) {
mail($recipient, "Listener banned", "$hostname\n$useragent", "From: $recipient");
}
}
}
else {
print "No ($useragent)";
}
print "<br>\n";
}
}
?>
</body>
</html>
Last edited by ZahoOL on Mon Jan 31, 2005 6:35 am, edited 1 time in total.
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

That ban rippers script is easy to get round. It would be a total waste of time to code it to TCL in my opinion :roll:. I personally dont have the time to make such a script either. I suggest you read the TCL manual and start to learn for yourself howto code, if you want that script bad enough.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
g
gnagis
Voice
Posts: 19
Joined: Fri May 28, 2004 5:48 am

error

Post by gnagis »

Hey ^DooM^ i have tryed to ge your script working on my eggdrop. but i get timed out all the time.... and also ther is 2 things i dont know what to input...

[16:25] Server responded with 200 OK
[16:25] *** Page data retrieval timed out!
this is what i get all the time :S

Code: Select all

# Not designed to be filled out by you... Yes that means you!
set sc_servercount  0

# Server Lists (Host, Name, Port, Password etc)
set sc_servers($sc_servercount,Host) "194.236.19.24"
set sc_servers($sc_servercount,Name) "roxa.nu"
set sc_servers($sc_servercount,Port) "8000"
set sc_servers($sc_servercount,Pass) "REMOVED"
incr sc_servercount

# Add as many as you want.
set sc_servers($sc_servercount,Host) "83.227.64.210"
set sc_servers($sc_servercount,Name) "radio.lan2k.org"
set sc_servers($sc_servercount,Port) "8000"
set sc_servers($sc_servercount,Pass) "REMOVED"
incr sc_servercount

# Which is the primary server (retrieves playing stats etc from)
set shoutcast(primary_server)        0
what do with "set shoutcast" and set "sc_servercount" ??
.......
or can it be anything else that is wrong?? ((the password is correct that i know... if its not meaning to encode it?))
got root?
g
gnagis
Voice
Posts: 19
Joined: Fri May 28, 2004 5:48 am

Post by gnagis »

lol it was nothing... server 2 was down ^_^ i dident notice that :D
got root?
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Re: error

Post by ^DooM^ »

gnagis wrote:Hey ^DooM^ i have tryed to ge your script working on my eggdrop. but i get timed out all the time.... and also ther is 2 things i dont know what to input...

[16:25] Server responded with 200 OK
[16:25] *** Page data retrieval timed out!
this is what i get all the time :S

Code: Select all

# Not designed to be filled out by you... Yes that means you!
set sc_servercount  0

# Server Lists (Host, Name, Port, Password etc)
set sc_servers($sc_servercount,Host) "194.236.19.24"
set sc_servers($sc_servercount,Name) "roxa.nu"
set sc_servers($sc_servercount,Port) "8000"
set sc_servers($sc_servercount,Pass) "REMOVED"
incr sc_servercount

# Add as many as you want.
set sc_servers($sc_servercount,Host) "83.227.64.210"
set sc_servers($sc_servercount,Name) "radio.lan2k.org"
set sc_servers($sc_servercount,Port) "8000"
set sc_servers($sc_servercount,Pass) "REMOVED"
incr sc_servercount

# Which is the primary server (retrieves playing stats etc from)
set shoutcast(primary_server)        0
what do with "set shoutcast" and set "sc_servercount
set shoutcast(primary_server) is used by you to specify which server you want the main details to be pulled from IE not a relay site usually 0 will be fine

sc_servercount is not for you to change as the note states. All this is for is to reset the array back to 0 if there are more than one server it is looking at. it starts at 0 (0 being your first server in the array) then moves onto 1 (1 being the second server in the array that you have added) and so on depending on how many servers you have added.

Hope this clears up any questions you have :)
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
g
gnagis
Voice
Posts: 19
Joined: Fri May 28, 2004 5:48 am

disable

Post by gnagis »

okay.... is ther a way to set it only to tell the song every 6 song or so.. not every song change... its spamming like hell ^_^
got root?
g
gnagis
Voice
Posts: 19
Joined: Fri May 28, 2004 5:48 am

on more thing..

Post by gnagis »

also the

!scwho
and
!sckickdj
dosent seem to work... 1 of the servers is OFFLINE... is that why?
got root?
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

Theres not an easy way to impliment every 6th song display. I wrote this script for my own personal use rather than for public use. I haven't released this script into the tcl archive as I dont have a lot of time to support it anymore . As for your kickdj problem if the primary server is down then the kick and who wont work properly the other servers that you can add should only be used for relay servers of the main server not completely different servers. It will work and display but you wont be able to use the admin commands on secondary servers, I never implemented that functionality as I didn't need it at the time.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
g
gnagis
Voice
Posts: 19
Joined: Fri May 28, 2004 5:48 am

--

Post by gnagis »

okay... but it is SERVER 1 that is online... and the relay is offline...
but still that kicksource and other one dosent do anything :S

also... how can i disable it totaly to say when it changes song then?
or is that also hard to do?

thanx anyway for helping me with this :)
got root?
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

To remove the bot from displaying the current song find this proc.

Code: Select all

proc sc_playing { nick uhost handle channel args } {
and hash out this line

Code: Select all

# sc_output $nick $channel $strStream
As for the kick commands make sure you are using the Admin password not the stream password.
Also Have you given yourself the +D flag on the bot? if you dont have this flag you cant use those 2 functions. You can change the flag to whatever you want in the settings at the top of the script.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Locked