-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0.EntryPoint.vb
79 lines (66 loc) · 2.42 KB
/
0.EntryPoint.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Public Module EntryPoint
Public Interface IChatPlugin
Function GetResponse(ByVal message As String) As String
End Interface
Public Class Chatbot
Private plugins As List(Of IChatPlugin)
Public Sub New()
plugins = New List(Of IChatPlugin)()
End Sub
Public Sub RegisterPlugin(ByVal plugin As IChatPlugin)
plugins.Add(plugin)
End Sub
Public Function GetResponse(ByVal message As String) As String
'RespondVia Plug-ins
For Each plugin In plugins
Dim response = plugin.GetResponse(message)
Next
Return "I'm sorry, I don't have a response for that."
End Function
End Class
Public Sub main(args As String())
' Create an instance of the ChatInterface
Dim chatbot As New Chatbot()
' TestRun(chatbot)
' Simulate user interaction with the chatbot
While True
Console.WriteLine("User: ")
Dim Userinput As String = Console.ReadLine()
' Exit the loop if the user enters "quit"
If Userinput.ToLower() = "quit" Then
Exit While
End If
' Get the chatbot's response
Dim response As String = chatbot.GetResponse(Userinput)
' Display the chatbot's response
Console.WriteLine("Chatbot: " + response)
Console.WriteLine()
End While
End Sub
''' <summary>
''' tester
''' </summary>
''' <param name="bot"></param>
Public Sub TestRun(ByRef bot As Chatbot)
' User inputs(Auto Run)
Dim userInputs As List(Of String) = New List(Of String)()
userInputs.Add("Hello!")
userInputs.Add("How are you?")
userInputs.Add("What's the weather like today?")
userInputs.Add("What is the meaning of life?")
userInputs.Add("Goodbye!")
' Chat loop
For Each userInput In userInputs
Dim response As String = bot.GetResponse(userInput)
Console.WriteLine("User: " & userInput)
Console.WriteLine("ChatBot: " & response)
Console.WriteLine()
Next
End Sub
Public Sub GetPlugins(ByRef Bot As Chatbot)
'--------------------------------
'RegisterPlugins for use with bot
'--------------------------------
' Bot.RegisterPlugin(New MainPlugin())
End Sub
End Module