Create a gist now

Instantly share code, notes, and snippets.

require 'slack-ruby-client'
require './func_google'
require './func_mecab'
TOKEN = ENV["SLACK_TOKEN"]
R18_LIST = File.foreach('wordlist.txt').map do |word|
word.chomp
end
R18_LIST.freeze
#卑猥フィルタ
def r18_word? text
R18_LIST.each do |word|
if text.include?(word)
return true
end
end
return false
end
Slack.configure do |config|
config.token = TOKEN
end
client = Slack::RealTime::Client.new
client.on :hello do
puts '...'
end
client.on :message do |data|
if !data['text'][/しよう(。|\.)*/].nil?
if r18_word?(data['text'])
sleep(3)
client.message channel: data['channel'], text: '"そして古見さんは石になった。"'
else
client.message channel: data['channel'], text: 'フンス!'
end
else
client.message channel: data['channel'], text:'...'
end
end
client.start!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment