Last active
July 13, 2021 19:31
-
-
Save meicookies/f477afd1981e0049f8a9178ccb316e3e to your computer and use it in GitHub Desktop.
ChatBot A.I
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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