People,
I bought a licence for a (Java) chatbot some years ago and wrote a little Ruby script (see below) to listen to the appropriate port and process incoming chats. Now I want to create something a little more sophisticated that could would replace the functionality of the Ruby script but also be expanded into something that could deal with other inputs and outputs.
Since I want to start learning Rust, I wanted to get some feedback about how to proceed with my Chatbot to Avatar project that involves writing this "Executive Function System" in Rust - which I think should be trivial (? - at least to begin with?) - here is a sketch from a while ago which I think is still valid but so much has happened with AI and Natural Language chat bots etc that more could be added to this diag:
http://pricom.com.au/OpenSourceStructure.svg
If I write this ExFuSys thing in Rust it would need to (in the first case):
- be started as a daemon?
- have a module that listens on the chatbot port and processes chats
I invisage the ExFuSys core could be doing a lot more in the future (much like the frontal lobe of a human brain) so it seems like a good idea to write this in Rust?
Feedback appreciated!
Phil.
#!/usr/bin/ruby
require 'socket'
require 'json'
lhost = Socket.gethostname
session = "SESSION_"
session = session + `echo $LOGNAME`.chomp
session = session + "_#{lhost}"
session = session + ".pricom.com.au"
session_init = "@" + session
host = ARGV.shift
if host == nil
host = "localhost"
end
port = ARGV.shift
if port == nil
port = 9192
end
dfname = nil
if dfname == nil
dfname = 'Unknown Unknown'
end
dname = dfname.split[0]
while true
print "> "
input = gets.chomp
# puts input
if (input == "quit") then
break
end
xmit = {
:commands => {
:users_name => "Philip",
:users_fullname => "Philip Rhoades",
:name => "Phil"
},
:topic_slug => "phirhodev",
:session_id => session_init,
:message => input
}
# Send it and get the client response
s = TCPSocket.open( host, port )
s.puts xmit.to_json
while true
response = s.gets.chomp
if response == "@@END_OF_REPLY"
break
end
puts response
end
s.close
end