Skip to content

Instantly share code, notes, and snippets.

@meicookies
Last active July 13, 2021 19:31
Show Gist options
  • Select an option

  • Save meicookies/f477afd1981e0049f8a9178ccb316e3e to your computer and use it in GitHub Desktop.

Select an option

Save meicookies/f477afd1981e0049f8a9178ccb316e3e to your computer and use it in GitHub Desktop.
ChatBot A.I
#!/usr/bin/ruby
require 'open-uri'
require 'json'
$_g = "\e[92m"
$_y = "\e[93m"
$_b = "\e[94m"
$_n = "\e[0m"
def chat(nama, nama_bot)
system "clear"
while true
print "#{$_y}>#{nama}#{$_n}: #{$_g}"
pesan = gets.chomp
api = ["https://fdciabdul.tech/api/ayla/?pesan=", "#{pesan}"].join()
hasil = JSON.parse(URI.open(api).read)
puts "#{$_y}>#{nama_bot}#{$_n}: #{$_g}#{hasil["jawab"]}"
end
end
system "clear"
puts "#{$_b}\n\tChat Bot A.I\n#{$_n}"
print "[+] nama kamu: "
name = gets.chomp
print "[+] nama botnya: "
bot_name = gets.chomp
chat(name, bot_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment