AnGelBot-Portal²

Normale Version: Topic Script mit individuellen Sections
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Seiten: 1 2
Code:
'***Individual-Section-Topic-Script by amir***
'
' » Channel-Commands:
'   » .t~set <topic with %sections%>
'     » Setzt ein Topic, alles zwischen zwei % wird zu einer Section!
'   » .t~update [<section> <content>]
'     » Aktualisiert eine Section mit angegebenem Inhalt
'     » Wird keine Section angegeben, liest er erneut alles aus und aktualisiert das Topic
'   » .t~sections
'     » Zeigt alle vorhandenen Sections an
'   » .t~cfg <lock/update/set> <1/0>
'     » .t~cfg lock <1/0>
'       » (Ent)Lockt das Topic. Ist das Topic gelockt, so kann das Topic nur vom Bot geändert werden.
'       » Wird das Topic dennoch geändert, ändert der Bot es zurück (Q ausgenommen)
'     » .t~cfg update <1/0>
'       » Legt fest ob das Topic beim Update einer Section mitgeändert werden soll oder nicht.
'       » Bei 0 wird das Topic erst via ".t~update" aktualisiert
'     » .t~cfg set <1/0>
'       » Legt fest ob das Topic beim Topic update gesetzt werden soll [-> mit leeren %sections%]
'       » Bei 0 wird das Topic erst via ".t~update" aktualisiert
'  » Query-Commands
'    » Benutzung der Commands wie im Channel, es muss aber als zweiter Paragraph der Channel angegeben werden!
'    » .t~<set/update/sections/cfg> <#chan> [<topic>/<section> <content>/<lock/update/set>] [<1/0>]
'  » Benutzung
'    » Setzt zuerst das Topic (.t~set <bla>) wie ihr es euch vorstellt, eine Section müsst ihr dabei %section% nennen!
'    » Füllt jetzt eure Sections mit Inhalten (.t~update <section> <inhalt>)
'
'***/Individual-Section-Topic-Script by amir***

Const tINI = "topic.ini" 'Name der Benutzen INI-Datei
Const tPrefix = ".t~" 'Anfang aller Trigger (darf keine Leerzeichen enthalten, es muss alles klein sein!)

Sub Init()
  Script "Topicscript V1.0d by amir"
  Hook "Chan_Msg"
  Hook "Priv_Msg"
  Hook "Topic"
End Sub

Dim cTopic, cSec, sectionCount, sectionContent, Lines

Sub Chan_Msg(Chan, Nick, RegUser, Line)
If Left(LCase(Param(Line, 1)), Len(tPrefix)) = tPrefix Then
  If MatchFlags(GetUserChanFlags(RegUser, Chan), "+m") Then
    Select Case Mid(LCase(Param(Line, 1)), (Len(tPrefix) + 1))
      Case "set"
        If Param(Line, 2) <> "" Then
          sectionCount = 0
          WriteINIString Chan, "Topic", GetRest(Line,2), tINI
          If ReadINIString(Chan, "tSections", "", tINI) <> "" Then
            For i = 0 To ReadINIString(Chan, "tSections", "", tINI)
              DeleteINIString Chan, ReadINIString(Chan, "tSection" & i, "", tINI), tINI
              DeleteINIString Chan, "tSection" & i, tINI
            Next
          End If
          For i = 1 To ParamCount(Line)
            If Left(Param(Line, i), 1) = "%" AND Right(Param(Line, i), 1) = "%" Then
              WriteINIString Chan, "tSection" & sectionCount, Mid(Param(Line, i), 2, Len(Param(Line, i)) - 2), tINI
              WriteINIString Chan, "tSections", sectionCount, tINI
              sectionCount = sectionCount + 1
            ElseIf Instr(1, Param(Line, i), "%") > 0 Then
              WriteINIString Chan, "tSection" & sectionCount, Mid(Param(Line, i), Instr(1, Param(Line, i), "%") + 1, Instr(Instr(1, Param(Line, i), "%") + 1, Param(Line, i), "%") - (Instr(1, Param(Line, i), "%") + 1)), tINI
              WriteINIString Chan, "tSections", sectionCount, tINI
              sectionCount = sectionCount + 1
            End If
          Next
          If ReadINIString(Chan, "Set", 1, tINI) = 1 Then
            SendLine "TOPIC " & Chan & " :" & GetRest(Line,2), 2
          Else
            SendLine "Notice " & Nick & " :Saved topic to: " & GetRest(Line,2), 2
          End If
        Else
          Sendline "Notice " & Nick & " :.t~set <new topic with %sections%>", 2
        End If
      Case "update"
        If Instr(1, Line, "&&") => 1 Then
          Lines = Split(GetRest(Line,2), "&&")
          WaitWithSend
          For i = LBound(Lines) To UBound(Lines)
            UpdateTopic Chan, Nick, ".t~update " & LTrim(Lines(i))
          Next
          SendNow
        Else
          UpdateTopic Chan, Nick, Line
        End If
      Case "sections"
        sections = ""
        sCount = ReadINIString(Chan, "tSections", 0, tINI)
        If sCount = 0 Then
          Sendline "Notice " & Nick & " :There are no sections. Create them by setting a new topic with %sections%", 2
          Exit Sub
        End If
        For i = 0 To sCount
          cSec = ReadINIString(Chan, "tSection" & i, "", tINI)
          sections = sections & " ‹¬ " & cSec & ""
        Next
        Sendline "Notice " & Nick & " :Topicsections: " & sections & " ‹¬ ", 2
      Case "cfg"
        Select Case LCase(Param(Line,2))
          Case "update"
            Select Case LCase(Param(Line,3))
              Case "0", "no", "off"
                Sendline "Notice " & Nick & " :I won't change the topic now when typing .t~update <section>. Use .t~update to update the whole topic.",2
                WriteINIString Chan, "Update", "0", tINI
              Case "1", "yes", "on"
                Sendline "Notice " & Nick & " :Now updating topic for each section!",2
                WriteINIString Chan, "Update", "1", tINI
              Case ""
                Sendline "Notice " & Nick & " :.t~cfg update <1/0>",2
            End Select
          Case "lock"
            Select Case LCase(Param(Line,3))
              Case "on", "1", "no"
                WriteINIString Chan, "LockTopic", "1", tINI
                Sendline "Notice " & Nick & " :Topic is now locked! You have to use ME in order to change the topic!",2
              Case "off", "0", "yes"
                WriteINIString Chan, "LockTopic", "0", tINI
                Sendline "Notice " & Nick & " :Topic is no longer locked!",2
              Case ""
                Sendline "Notice " & Nick & " :.t~cfg lock <1/0>",2
            End Select
          Case "set"
            Select Case LCase(Param(Line,3))
              Case "0", "yes"
                Sendline "Notice " & Nick & " :I won't change the topic now when typing .t~set <topic>. Use .t~update to update the topic.",2
                WriteINIString Chan, "Set", "0", tINI
              Case "1", "no"
                Sendline "Notice " & Nick & " :Now updating topic when using .t~set <topic>!",2
                WriteINIString Chan, "Set", "1", tINI
              Case ""
                Sendline "Notice " & Nick & " :.t~cfg set <1/0>",2
            End Select
        End Select
    End Select
  End If
End If
End Sub

Sub Priv_Msg(Nick, RegUser, Line)
If Left(Param(Line,2), "1") = "#" And Left(LCase(Param(Line, 1)), 3) = ".t~" And IsOn(MyNick, Param(Line,2)) Then
  Chan_Msg Param(Line,2), Nick, RegUser, (Param(Line,1) & " " & GetRest(Line,3))
ElseIf Left(LCase(Param(Line, 1)), 3) = ".t~" And ParamCount(Line) < 2 Then
  Sendline "Privmsg " & Nick & " :.t~set #chan <topic w/ %sections%> ‹¬ .t~update #chan [<section> <content>] ‹¬ .t~sections #chan", 2
ElseIf Left(Param(Line,2), "1") = "#" And Left(LCase(Param(Line, 1)), 3) = ".t~" And Not IsOn(MyNick, Param(Line,2)) Then
  Sendline "Privmsg " & Nick & " :I'm not on that channel.", 2
End If
End Sub

Sub Topic(Chan, Nick, RegUser, Flags, Line)
If Nick = MyNick Or Len(Nick) = 1 Then Exit Sub
If Readinistring(Chan, "LockTopic", 0, tINI) = 1 Then
  cTopic = ReadINIString(Chan, "Topic", "", tINI)
  For j = 0 To ReadINIString(Chan, "tSections", "", tINI)
    cSec = ReadINIString(Chan, "tSection" & j, "", tINI)
    secContent = Readinistring(Chan, cSec, "", tINI)
    If secContent <> "" Then
      cTopic = Replace(cTopic, "%" & cSec & "%", secContent)
    End If
  Next
  SendLine "TOPIC " & Chan & " :" & cTopic, 2
End If
End Sub

Sub UpdateTopic(Chan, Nick, Line)
If ParamCount(Line) > 2 Then
  For i = 0 To ReadINIString(Chan, "tSections", 0, tINI)
    If Readinistring(Chan, "tSection" & i, "", tINI) = Param(Line,2) Then
      Writeinistring Chan, Readinistring(Chan, "tSection" & i, "", tINI), GetRest(Line,3), tINI
    End If
  Next
  cTopic = ReadINIString(Chan, "Topic", "no topic", tINI)
  For j = 0 To ReadINIString(Chan, "tSections", "", tINI)
    cSec = ReadINIString(Chan, "tSection" & j, "", tINI)
    secContent = Readinistring(Chan, cSec, "", tINI)
    If secContent <> "" Then
      cTopic = Replace(cTopic, "%" & cSec & "%", secContent)
    End If
  Next
  If ReadINIString(Chan, "Update", 0, tINI) = 1 Then
    SendLine "TOPIC " & Chan & " :" & cTopic, 2
  Else
    Sendline "Notice " & Nick & " :Saved topic to: " & cTopic, 2
  End If
ElseIf ParamCount(Line) = 2 Then
  Sendline "Notice " & Nick & " :I need to now the content of the section!", 2
ElseIf ParamCount(Line) < 2 Then
  cTopic = ReadINIString(Chan, "Topic", "no topic", tINI)
  For j = 0 To ReadINIString(Chan, "tSections", "", tINI)
    cSec = ReadINIString(Chan, "tSection" & j, "", tINI)
    secContent = Readinistring(Chan, cSec, "", tINI)
    If secContent <> "" Then
      cTopic = Replace(cTopic, "%" & cSec & "%", secContent)
    End If
  Next
  SendLine "TOPIC " & Chan & " :" & cTopic, 2
End If
End Sub

Funktion:
* Setzen des Topics mit individuellen %sections% die dann via Trigger geändert werden können
Erklärung der Befehle:
* steht oben im Script

Würde mich über Erweiterungswünsche und/oder gefundene Bugs freuen, ich werds dann anpassen Smile
das Topic per Q setzen - mein Vorschlag
das könntest du auch für dich ganz einfach ändern, es sind ja nur 2 sendlines in der Sub UpdateTopic
ich bin da einfach zu blöde für...
Code:
SendLine "TOPIC " & Chan & " :" & cTopic, 2
mit
Code:
SendLine "Privmsg Q :settopic " & Chan & " " & cTopic, 2
ersetzen... glaub ich...
Ja ok, aber da müsste doch noch etwas rein damit der Bot das Topich auch nur dann über Q setzt wenn Q da ist. Oder nicht?
ja, stimmt Razz
dann nimm diese Sub UpdateTopic:
Code:
Sub UpdateTopic(Chan, Nick, Line)
If ParamCount(Line) > 2 Then
  For i = 0 To ReadINIString(Chan, "tSections", "", tINI)
    If Readinistring(Chan, "tSection" & i, "", tINI) = Param(Line,2) Then
      Writeinistring Chan, Readinistring(Chan, "tSection" & i, "", tINI), GetRest(Line,3), tINI
    End If
  Next
  cTopic = ReadINIString(Chan, "Topic", "", tINI)
  For j = 0 To ReadINIString(Chan, "tSections", "", tINI)
    cSec = ReadINIString(Chan, "tSection" & j, "", tINI)
    secContent = Readinistring(Chan, cSec, "", tINI)
    If secContent <> "" Then
      cTopic = Replace(cTopic, "%" & cSec & "%", secContent)
    End If
  Next
  If ReadINIString(Chan, "Update", "", tINI) = 1 Then
    If IsOn("Q", Chan) Then
      SendLine "Privmsg Q :settopic " & Chan & " " & cTopic, 2
    Else
      SendLine "TOPIC " & Chan & " :" & cTopic, 2
    End If
  Else
    Sendline "Notice " & Nick & " :Saved topic to: " & cTopic, 2
  End If
ElseIf ParamCount(Line) = 2 Then
  Sendline "Notice " & Nick & " :I need to now the content of the section!", 2
ElseIf ParamCount(Line) < 2 Then
  cTopic = ReadINIString(Chan, "Topic", "", tINI)
  For j = 0 To ReadINIString(Chan, "tSections", "", tINI)
    cSec = ReadINIString(Chan, "tSection" & j, "", tINI)
    secContent = Readinistring(Chan, cSec, "", tINI)
    If secContent <> "" Then
      cTopic = Replace(cTopic, "%" & cSec & "%", secContent)
    End If
  Next
  If IsOn("Q", Chan) Then
    SendLine "Privmsg Q :settopic " & Chan & " " & cTopic, 2
  Else
    SendLine "TOPIC " & Chan & " :" & cTopic, 2
  End If
End If
End Sub
bei mia funzt des net..
was muss ich da jetzt genau in den channel schreiben?
mein bot-trigger is !
wenn ich "!t set bla" mach, wird der topic "set bla"
wenn ich "!t~set bla" mach passiert garnix
genauso mit ".t~set bla" und ".t set bla"

????
DEIN trigger ist vollkommen uninteressant...
mach erst: .t~set welcome to %chan% - news: %news%
dann: .t~update chan #sajuko!
und: .t~update news none
ok jetzt reagiert der bot zumindest :D
aber...

erstmal melde ich ihm er soll das topic setzen
(@``PhoEniX`): .t~set Welcome ² #BloodyPhoEniX - Partners: %partners%- News: %news%
und seine antwort
-][-BLooD-BoT-][- Saved topic to: Welcome ² #BloodyPhoEniX - Partners: %partners%- News: %news%
ja, denn mach ich
(@``PhoEniX`): .t~update partners #Nordic-FM #Schleswig #SpawN
Und denn kommt das hier in der party-line
Error : 13 (Typen unverträglich: '[string: ""]')
Position: Line 174, Column 2
Excerpt : If ReadINIString(Chan, "Update", "", tINI) = 1 Then
Command : Chan_msg "#BloodyPhoEniX", "``PhoEniX`", "BloodyPhoEniX", ".t~update partners #Nordic-FM #Schleswig #SpawN"


p.s. hier nochma des ganze script (kann sein, dass ich was falsch kopiert hab oder oO)
Seiten: 1 2
Referenz-URLs