Skip to content

Instantly share code, notes, and snippets.

@panchiga
Created October 28, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panchiga/5f1768f59707f09b0afa098415655617 to your computer and use it in GitHub Desktop.
Save panchiga/5f1768f59707f09b0afa098415655617 to your computer and use it in GitHub Desktop.
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