Created
October 28, 2016 18:09
-
-
Save panchiga/5f1768f59707f09b0afa098415655617 to your computer and use it in GitHub Desktop.
This file contains 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
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