Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Globals.GlobalResources
- Imports System.IO
- Public Class Class1
- Implements Globals.Plgn
- Private commandsDir As String = My.Application.Info.DirectoryPath & "\Plugins\CustomReplies"
- Private di As New IO.DirectoryInfo(commandsDir)
- Public Sub Config() Implements Globals.Plgn.Config
- Process.Start(commandsDir)
- End Sub
- Public ReadOnly Property Name As String Implements Globals.Plgn.Name
- Get
- Return "CustomReplies - TizzyT"
- End Get
- End Property
- Public Function ProcessMessage(InputMessage As Message) As Boolean Implements Globals.Plgn.ProcessMessage
- If InputMessage.Type = MessageType.PRIVMSG And InputMessage.Raw.StartsWith(":") Then
- Dim diar1 As IO.FileInfo() = di.GetFiles("*.txt")
- Dim dra As IO.FileInfo
- For Each dra In diar1
- Dim Command As String = dra.Name.Substring(0, dra.Name.Length - 6).Trim
- If InputMessage.Message.StartsWith(Command) Then
- Dim param As String = InputMessage.Message.Remove(0, Command.Length + 2).Trim
- Dim line As String
- Using sr As New StreamReader(dra.FullName)
- line = sr.ReadToEnd()
- End Using
- line = line.Replace("<PARAM>", param)
- line = line.Replace(vbCrLf, " ")
- line = line.Replace(vbCr, " ")
- line = line.Replace(vbLf, " ")
- If line.Contains("<RND>") Then
- Dim RND As New Random
- Dim Parts() As String = line.Split(New String() {"<RND>"}, StringSplitOptions.None)
- line = ""
- For i = 0 To Parts.Length - 2
- Dim range As String = Parts(i + 1).Split(">")(0)
- Dim low As String = range.Split(",")(0)
- Dim high As String = range.Split(",")(1)
- Parts(i) &= RND.Next(CInt(low), CInt(high + 1))
- Parts(i + 1) = Parts(i + 1).Replace(low & "," & high & ">", "")
- line &= Parts(i)
- Next
- line &= Parts(Parts.Length - 1)
- End If
- AddToSend("PRIVMSG " & GetCurrentChan() & " :" & ParseMessage(InputMessage, line))
- End If
- Next
- End If
- End Function
- Public Sub New()
- If Not System.IO.Directory.Exists(commandsDir) Then
- System.IO.Directory.CreateDirectory(commandsDir)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment