# gem install --user-install specific_install # gem specific_install --user-install https://github.com/phaul/cinch.git require 'cinch' require 'nlpcloud' require 'urban_dict' require 'pry' $nlpcloud_token = "7f82dd1d65f6019b06511923b2fb0275e0795c2c" # https://docs.nlpcloud.com/#chatbot-and-conversational-ai client = NLPCloud::Client.new('finetuned-gpt-neox-20b', $nlpcloud_token, gpu: true, lang: 'en') bot = Cinch::Bot.new do configure do |c| c.nick = "RapBot4000" c.server = "irc.libera.chat" c.channels = ["#ruby"] end # Handle incoming messages from users on :message do |m| response = client.chatbot(m.message) slang_response = translate_to_slang(response['response']) m.reply slang_response end end bot.start # -- slang = { "hello" => "yo", "goodbye" => "peace out", "cool" => "dope", "awesome" => "sick", "really" => "hella", "you" => "u" } def translate_to_slang(input) # Split the input sentence into individual words words = input.split # Loop through each word in the input sentence words.each_with_index do |word, index| # Look up the slang term for the word in the Urban Dictionary term = UrbanDict.define(word) # If a slang term was found, replace the original word with the slang term if term words[index] = term.word end # Replace each word with its slang equivalent, if it exists slang[word.downcase] || word end # Join the modified words back into a sentence return words.join(" ") end