Created
August 27, 2021 07:56
-
-
Save drusepth/7b525f1bdd8a49437f3d51ec20b9b3c5 to your computer and use it in GitHub Desktop.
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 'cinch' | |
require 'net/http' | |
require 'uri' | |
bot = Cinch::Bot.new do | |
configure do |c| | |
c.nick = "TK" | |
c.realname = "TK" | |
c.server = "irc.amazdong.com" | |
c.channels = [ "#test" ] | |
end | |
# Learn from all messages | |
on :message, /(.*)/ do |m, message| | |
return if message.include? '#noquo' | |
puts "[Bigram] Logging: #{message}" | |
uri = URI.parse("http://indent-retort.herokuapp.com/bigram/parse?message=#{message}") | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Get.new(uri.request_uri) | |
response = http.request(request) | |
puts "[Bigram] Response #{response.code}: #{response.body}" | |
end | |
# Respond to messages when mentioned | |
on :message, /TK/ do |m, message| | |
uri = URI.parse("http://indent-retort.herokuapp.com/markov/create") | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Get.new(uri.request_uri) | |
response = http.request(request) | |
m.reply response.body | |
end | |
end | |
# Start bot | |
bot.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment