AnGelBot-Portal²

Normale Version: Flood-Protection bei StreamScript von c00l
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Grüß Gott, ich bräuchte Hilfe bei diesem Stream-Script, denn ich möchte eine Flood-Protection einbauen, aber weiss zur Zeit nicht so recht, wie ich das machen soll. Muss man bei jedem Trigger, ne FloodSperre reinbauen oder reicht es, wenn man es nur einmal macht. Könnte mir jemand an einem trigger zeigen, wie ich sowas einbaue, oder wenn es jemanden Spaß macht, sogar bei allen Triggern sowas einbauen Rolling Eyes Wäre um Hilfe sehr dankbar, weil ich beim scripten im allgemeinen ein noob bin^^


Code:
'================================================
'Erstellt mit [ABP]AVS 1.0.8
'AnGelBot Visual Scripting

'Visit us online @ http://www.AnGelBot-Portal.de/
'================================================
'Programmiert von [TgP]c00l4ZiD & [ABP]Sp33d
'================================================

'###############################################################################​########
'# ShoutCast Streamscript v3.5 Beta by [TgP]c00l4ZiD & [ABP]Sp33d                     #
'###############################################################################​########

Const ini_SC = "ShoutCastStream.ini"

Sub Init()
  Script "ShoutCast Streamscript v3.5 Beta by c00l4ZiD & Sp33d"
  Hook "Chan_Msg"
  TimedCommand "SagWas", ReadINIString("Stream", "Werbung", "1", ini_SC)
  GetData
End Sub

Dim ChanFrom, NickFrom, Recieved, Inet_Ticker
Dim Stream_Peak, Stream_Status, Stream_Server
Dim Stream_AvTime, Stream_Title, Stream_Genre

'###############################################################################​########
'# Daten die Editiert werden müssen !                                                  #
'###############################################################################​########

'Bitte URL zum Stream angeben. z.B. http://fun-radio.kicks-ass.org:13090 (ohne / zum schluss)
Const StreamURL = "http://mserv01.mops.net:2166"

'Name eures Streams z.B. Fun-Radio
Const StreamName = "nEt-bEaT"

'Den Channel indem das Script laufen soll z.B. #FuN-Radio
Const EmpfChan = "#nEt-bEaT"

'Den Hostnamen oder IP ohne http:// und port (Const StreamHost = "fun-radio.kicks-ass.org")
Const StreamHost = "mserv01.mops.net"

'Nun den dazugehörigen Port eintragen (Const StreamPort = "13090")
Const StreamPort = "2166"

'###############################################################################​########
'# Ab hier bitte nichts mehr ändern ! Thx !                                            #
'###############################################################################​########

Const StreamPage = "/index.html"

Sub Chan_Msg(Chan, Nick, RegUser, Line)
  If LCase(Param(Line, 1)) = "!setdj" and LCase(Chan) = LCase(EmpfChan) Then
    If Param(Line, 2) = "" Then
      If IsOp(Nick, Chan) Then
        WriteINIString "Stream", "StreamDJ", Nick, ini_SC
        Sendline "NOTICE " & Nick & " : Aktueller DJ (" & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & ") von Dir gesetzt !", 3
        RefreshTopic
      Else
        Sendline "NOTICE " & Nick & " : Du hast keine Berechtigung !", 3
      End If
    Else
      If IsOp(Nick, Chan) Then
        WriteINIString "Stream", "StreamDJ", Param(Line, 2), ini_SC
        Sendline "NOTICE " & Nick & " : Aktueller DJ (" & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & ") von Dir gesetzt !", 3
        RefreshTopic
      Else
        Sendline "NOTICE " & Nick & " : Du hast keine Berechtigung !", 3
      End If
    End If
  End If

  If LCase(Param(Line, 1)) = "!setplaylist" and LCase(Chan) = LCase(EmpfChan) Then
    If IsOp(Nick, Chan) Then
      If GetRest(Line, 2) = "" Then
        Sendline "NOTICE " & Nick & " : Bitte Adresse eingeben !setplaylist <URL>", 3
      Else
        Sendline "NOTICE " & Nick & " : Playlist wurde auf " & GetRest(Line, 2) & " geändert !", 3
        WriteINIString "Stream", "Playlist", GetRest(Line, 2), ini_SC
        RefreshTopic
      End If
    Else
      Sendline "NOTICE " & Nick & " : Du hast keine Berechtigung !", 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!sendung" and LCase(Chan) = LCase(EmpfChan) Then
    If IsOp(Nick, Chan) Then
      If GetRest(Line, 2) = "" Then
        Sendline "NOTICE " & Nick & " : Bitte Sendung eingeben !sendung <Name der Sendung> z.B. !sendung Tekkno rock 0ver", 3
      Else
        Sendline "NOTICE " & Nick & " : Sendung wurde auf " & GetRest(Line, 2) & " geändert !", 3
        WriteINIString "Stream", "Sendung", GetRest(Line, 2), ini_SC
        RefreshTopic
      End If
    Else
      Sendline "NOTICE " & Nick & " : Du hast keine Berechtigung !", 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!wünsche" and LCase(Chan) = LCase(EmpfChan) Then
    If IsOp(Nick, Chan) Then
      If Param(Line, 2) = "on" Then
        Sendline "NOTICE " & Nick & " : Wünsche werden nun via Query an " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " geschickt !", 3
        WriteINIString "Stream", "Wünsche", "1", ini_SC
        RefreshTopic
      End If
      If Param(Line, 2) = "off" Then
        Sendline "NOTICE " & Nick & " : Wünsche werden nun geblockt !", 3
        WriteINIString "Stream", "Wünsche", "0", ini_SC
        RefreshTopic
      End If
    Else
      Sendline "NOTICE " & Nick & " : Du hast keine Berechtigung !", 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!grüsse" and LCase(Chan) = LCase(EmpfChan) Then
    If IsOp(Nick, Chan) Then
      If Param(Line, 2) = "on" Then
        Sendline "NOTICE " & Nick & " : Grüsse werden nun via Query an " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " geschickt !", 3
        WriteINIString "Stream", "Grüsse", "1", ini_SC
      End If
      If Param(Line, 2) = "off" Then
        Sendline "NOTICE " & Nick & " : Grüsse werden nun geblockt !", 3
        WriteINIString "Stream", "Grüsse", "0", ini_SC
      End If
    Else
      Sendline "NOTICE " & Nick & " : Du hast keine Berechtigung !", 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!online" and LCase(Chan) = LCase(EmpfChan) Then
    If IsOp(Nick, Chan) Then
      Sendline "NOTICE " & Nick & " : Stream wird online gesetzt !", 3
      WriteINIString "Stream", "StreamStatus", "1", ini_SC
      RefreshTopic
    Else
      Sendline "NOTICE " & Nick & " : Du bist nicht berechtig diese Operation durchzuführen !", 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!offline" and LCase(Chan) = LCase(EmpfChan) Then
    If IsOp(Nick, Chan) Then
      Sendline "NOTICE " & Nick & " : Stream wird offline gesetzt !", 3
      WriteINIString "Stream", "StreamStatus", "0", ini_SC
      RefreshTopic
    Else
      Sendline "NOTICE " & Nick & " : Du bist nicht berechtig diese Operation durchzuführen !", 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!infos" and LCase(Chan) = LCase(EmpfChan) Then
    Sendline "PRIVMSG " & Nick & " : 1,7-------------------------------------------------------------------", 3
    If ReadINIString("Stream", "StreamStatus", "0", ini_SC) = "0" Then
      Sendline "PRIVMSG " & Nick & " : 4,7         " & StreamName  & " 1,7ist 4,7offline       ", 3
      Sendline "PRIVMSG " & Nick & " : 1,7          Zuletzt legte DJ " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " auf !      ", 3
    Else
      Sendline "PRIVMSG " & Nick & " : 4,7         " & StreamName  & " 0,7ist 9,7online       ", 3
      Sendline "PRIVMSG " & Nick & " : 1,7          Derzeitiger DJ: " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & "      ", 3
    End If
    If ReadINIString( "Stream", "Wünsche", "0", ini_SC) = "0" Then
      Sendline "PRIVMSG " & Nick & " : 1,7          Titel Wünsche werden 4,7nicht akzeptiert 1,7!",3
    Else
      Sendline "PRIVMSG " & Nick & " : 1,7          Titel Wünsche werden 9,7akzeptiert 1,7!",3
    End If
    Sendline "PRIVMSG " & Nick & " : 1,7-------------------------------------------------------------------", 3
    Sendline "PRIVMSG " & Nick & " : 1,7        StreamFile @ 1,7" & StreamURL & "/listen.pls          ", 3
    Sendline "PRIVMSG " & Nick & " : 1,7        StreamInfo @ 1,7" & StreamURL & "/index.html          ", 3

    Sendline "PRIVMSG " & Nick & " : 1,7        Played     @ 1,7" & StreamURL & "/played.html         ", 3
    Sendline "PRIVMSG " & Nick & " : 1,7-------------------------------------------------------------------", 3
    Sendline "PRIVMSG " & Nick & " : 4,7        !wunsch =  für Wünsche   1,7*****  4,7!gruss = für Grüsse        ", 3
    Sendline "PRIVMSG " & Nick & " : 1,7-------------------------------------------------------------------", 3
  End If

  If LCase(Param(Line, 1)) = "!gruss" and LCase(Chan) = LCase(EmpfChan) Then
    If Param(Line, 2) = "" or LCase(Param(Line, 2)) = "help" Then
      Sendline "NOTICE " & Nick & " : Benutzung: !gruss <dein gruss an wen>", 3
    Else
      If ReadINIString( "Stream", "Grüsse", "0", ini_SC) = "0" Then
        Sendline "NOTICE " & Nick & " : Grüsse werden zur Zeit nicht akzeptiert :(", 3
      Else
        Sendline "NOTICE " & Nick & " : Dein Gruss wurde weitergeleitet ! :)", 3
        SendLine "PRIVMSG " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " : 1,7Gruss von " & Nick & ": " & GetRest(Line, 2), 3
      End If
    End If
  End If

  If LCase(Param(Line, 1)) = "!wunsch" and LCase(Chan) = LCase(EmpfChan) Then
    If Param(Line, 2) = "" or LCase(Param(Line, 2)) = "help" Then
      Sendline "NOTICE " & Nick & " : Benutzung: !wunsch <dein titelwunsch>", 3
    Else
      If ReadINIString( "Stream", "Wünsche", "0", ini_SC) = "0" Then
        Sendline "NOTICE " & Nick & " : Wünsche werden zur Zeit nicht akzeptiert :(", 3
      Else
        Sendline "NOTICE " & Nick & " : Dein Wunsch wurde weitergeleitet ! :)", 3
        SendLine "PRIVMSG " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " : 1,7Wunsch von " & Nick & ": " & GetRest(Line, 2), 3
      End If
    End If
  End If

  If LCase(Param(Line, 1)) = "!status" and LCase(Chan) = LCase(EmpfChan) Then
    If ReadINIString("Stream", "StreamStatus", "0", ini_SC) = "0" Then
      SendLine "PRIVMSG " & EmpfChan & " :1,7 «8•1» 4" & StreamName & "1,7 ist zur Zeit 4offline 1,7! «8•1»1,7 Stay tuned ! «8•1» Keine STATUS Daten verfügbar 1,7! «8•1» 1,7" , 2
    Else
      If Stream_Peak <> vbNullString Then
        SendLine "PRIVMSG " & Chan & " :1,7 «8•1» Last peak was " & Stream_Peak & "1,7 «8•1» 4", 3
      End If
      If Stream_Status <> vbNullString Then
        SendLine "PRIVMSG " & Chan & " :1,7 «8•1» " & Stream_Status & "1,7 «8•1» 4", 3
      End If
      If Stream_AvTime <> vbNullString Then
        SendLine "PRIVMSG " & Chan & " :1,7 «8•1» Average listen time: " & Stream_AvTime & "1,7 «8•1» 4", 3
      End If
      If Stream_Genre <> vbNullString Then
        SendLine "PRIVMSG " & Chan & " :1,7 «8•1» Current genre: " & Stream_Genre & "1,7 «8•1» 4", 3
      End If
      If Stream_Title <> vbNullString Then
        SendLine "PRIVMSG " & Chan & " :1,7 «8•1» Current title: " & Stream_Title & "1,7 «8•1» 4", 3
      Else
        SendLine "PRIVMSG " & EmpfChan & " :1,7 «8•1» Es konnte keine Verbindung zum StreamServer hergestellt werden ! Bitte später noch einmal probieren ! «8•1» 1,7" , 2
      End If
    End If
  End If

  If LCase(Param(Line, 1)) = "!listener" and LCase(Chan) = LCase(EmpfChan) Then
    If ReadINIString("Stream", "StreamStatus", "0", ini_SC) = "0" Then
      SendLine "PRIVMSG " & EmpfChan & " :1,7 «8•1» 4" & StreamName & "1,7 ist zur Zeit 4offline 1,7! «8•1»1,7 Stay tuned ! «8•1» Keine LISTENER Daten verfügbar 1,7! «7•8» 1,7 " , 2
    Else
      If Stream_Status <> vbNullString Then
        SendLine "PRIVMSG " & Chan & " :1,7 «8•1» " & Stream_Status & "1,7 «8•1» 4", 3
      Else
        SendLine "PRIVMSG " & EmpfChan & " :1,7 «8•1» Es konnte keine Verbindung zum StreamServer hergestellt werden ! Bitte später noch einmal probieren ! «8•1» 1,7" , 2
      End If
    End If
  End If

  If LCase(Param(Line, 1)) = "!dj" and LCase(Chan) = LCase(EmpfChan) Then
    If ReadINIString("Stream", "StreamStatus", "0", ini_SC) = "0" Then
      Sendline "PRIVMSG " & Chan & " :1,7 «8•1» Stream ist 4,7offline 1,7! «8•1» Daher kein DJ OnAir ! «8•1»", 3
    Else
      Sendline "PRIVMSG " & Chan & " :1,7 «8•1» DJ OnAir: " & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " «8•1» Sendung: " & ReadINIString( "Stream", "Sendung", "0", ini_SC) & " «8•1» " , 3
    End If
  End If

  If LCase(Param(Line, 1)) = "!stream" and LCase(Chan) = LCase(EmpfChan) Then
    Sendline "PRIVMSG " & Chan & " :1,7 «8•1» Listen " & StreamName & " @ " & StreamURL & "/listen.pls «8•1»", 3
  End If

  If LCase(Param(Line, 1)) = "!playlist" and LCase(Chan) = LCase(EmpfChan) Then
    Sendline "PRIVMSG " & Chan & " :1,7 «8•1» Playlist zur aktuellen Sendung: " & ReadINIString( "Stream", "Playlist", "0", ini_SC) & " «8•1»", 3
End If

End Sub

Sub SockEvent(vSock, SEvent, SData)
  Select Case SEvent
    Case SE_ConnectFailed
      SpreadFlagMessage 0, "+m", "5*** ShoutCast: Connection to " & StreamHost & " failed"
      TimedCommand "GetData", 30
    Case SE_Connected
      SpreadFlagMessage 0, "+m", "5*** ShoutCast: Connection to " & StreamHost & " established"
      SockWrite vSock, "GET " & StreamPage & " HTTP/1.0" & vbCrLf & _
      "Accept: text/html"  & vbCrLf & _
      "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; AnGeL-Bot)" & vbCrLf & vbCrLf
    Case SE_Read
      Recieved = Recieved & SData
    Case SE_Closed
      SpreadFlagMessage 0, "+m", "5*** ShoutCast: Connection closed by server"
      If InStr(1, Recieved, "<font class=default><b><a") > 0 Then
        Dummy = "<font class=default><b>"
        iPos = InStr(1, Recieved, Dummy) - 1
        Recieved = Right(Recieved, Len(Recieved) - iPos - Len(Dummy))
        Stream_Server = Left(Recieved, InStr(1, Recieved, "<") - 1)

        iPos = InStr(1, Recieved, Dummy) - 1
        Recieved = Right(Recieved, Len(Recieved) - iPos - Len(Dummy))
        Stream_Status = Replace(Left(Recieved, InStr(1, Recieved, "</b>") - 1), "<B>", "")

        iPos = InStr(1, Recieved, Dummy) - 1
        Recieved = Right(Recieved, Len(Recieved) - iPos - Len(Dummy))
        Stream_Peak = Left(Recieved, InStr(1, Recieved, "<") - 1)

        iPos = InStr(1, Recieved, Dummy) - 1
        Recieved = Right(Recieved, Len(Recieved) - iPos - Len(Dummy))
        Stream_AvTime = Replace(Left(Recieved, InStr(1, Recieved, "<") - 1), "&nbsp;", " ")

        iPos = InStr(1, Recieved, Dummy) - 1
        Recieved = Right(Recieved, Len(Recieved) - iPos - Len(Dummy))
        Stream_Title = Left(Recieved, InStr(1, Recieved, "</b></td>") - 1)

        iPos = InStr(1, Recieved, Dummy) - 1
        Recieved = Right(Recieved, Len(Recieved) - iPos - Len(Dummy))
        Stream_Genre = Left(Recieved, InStr(1, Recieved, "<") - 1)
      Else
        SpreadFlagMessage 0, "+m", "5*** ShoutCast: HTML page is not complete"
      End If
      Recieved = ""
      TimedCommand "GetData", 30
  End Select
End Sub

Sub GetData()
  vSock = SockConnect(StreamHost, StreamPort, "SockEvent")
  If vSock = 0 Then SpreadFlagMessage 0, "+m", "5*** ShoutCast: Couldn't create socket"
End Sub

Sub RefreshTopic()
  If ReadINIString("Stream", "StreamStatus", "0", ini_SC) = "0" Then
    SendLine "TOPIC " & EmpfChan & " :1,7 «8•1» Herzlich Willkommen ! 1,7 «8•1» 4,7" & StreamName & "1,7 ist zur Zeit 4,7offline 1,7 «8•1»! Infos unter 1,7!infos 1,7 «8•1»!", 3
  Else
    If ReadINIString("Stream", "Wünsche", "0", ini_SC) = "0" Then
      SendLine "TOPIC " & EmpfChan & " :1,7 «8•1» 4" & StreamName & "1,7 ist 9,7online 1,7 «8•1» 1,7" & StreamURL & "/listen.pls «8•1»1,7 Wünsche: 4,7off 1,7 «8•1» DJ: 4,7" & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " «8•1» Infos @ 4!infos 1,7 «8•1»", 3
    Else
      SendLine "TOPIC " & EmpfChan & " :1,7 «8•1» 4" & StreamName & "1,7 ist 9,7online 1,7 «8•1» 1,7" & StreamURL & "/listen.pls «8•1»1,7 Wünsche: 9,7on 1,7 «8•1» DJ: 4,7" & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & " «8•1» Infos @ 4!infos 1,7 «8•1»", 3
    End If
  End If
End Sub

Sub SagWas()
  If ReadINIString("Stream", "StreamStatus", "0", ini_SC) = "0" Then
    WriteINIString "Stream", "Werbung", "7200", ini_SC
    SendLine "PRIVMSG " & EmpfChan & " :1,7 «8•1» 4" & StreamName & "1,7 ist zur Zeit 4offline 1,7! «8•1»1,7 Stay tuned ! «8•1» Infos unter 4!infos 1,7! «8•1» 1,7" , 2
  Else
    WriteINIString "Stream", "Werbung", "1800", ini_SC
    Sendline "PRIVMSG " & EmpfChan & " :1,7 «8•1» 4" & StreamName & "1,7 1,7ist 9online 1,7mit 9" & ReadINIString( "Stream", "StreamDJ", "0", ini_SC) & "1,7«8•1» 1,7Infos unter 4!infos 1,7! 1,7! «8•1» 1,7Listen @ " & StreamURL & "/listen.pls «8•1»1,7 " , 2
  End If

  TimedCommand "SagWas", ReadINIString("Stream", "Werbung", "1", ini_SC)
End Sub
Es gibt ganz viele beispiele für floodprotection hier im forum musste mal nach "Flood" oder "Floodprotection" suchen . . .
Die Suchfunktion habe ich auch schon benutzt und hab auch schon ein paar Sachen ausprobiert, aber es will einfach net. Stell mich da atm irgendwie voll an -.- Ich biite doch um eine kleine Hilfe :(
Referenz-URLs