-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.rb
76 lines (69 loc) · 3 KB
/
bot.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require 'yaml'
require 'json'
require 'redis'
require 'discordrb'
config = YAML.load_file('config.yml')
bot = Discordrb::Commands::CommandBot.new token: config['discord']['token'], client_id: config['discord']['client_id'], prefix: config['discord']['prefix']
redis = Redis.new host: config['redis']['db_host'], port: config['redis']['db_port']
bot.ready do
bot.game = config['discord']['playing']
end
bot.command :mute do |event|
status = redis.get event.channel.id
if status != 'mute'
redis.set event.channel.id, 'mute'
event.send_message "#{event.channel.name}(id: #{event.channel.id})を無視するようになりました"
else
event.send_message 'このチャンネルは既にミュートされています'
end
end
bot.command :unmute do |event|
status = redis.get event.channel.id
if status == 'mute'
redis.del event.channel.id
event.send_message "#{event.channel.name}(id: #{event.channel.id})でのわかる監視を開始しました"
else
event.send_message 'このチャンネルはミュートされていません'
end
end
bot.message do |event|
author_id = event.author.id
status = redis.get event.channel.id
if author_id == !config['discord']['client_id'] || status == 'mute'
elsif event.content =~ /.*わかる.*/
wakaru = [
'https://media.makotia.me/wakaritetsuya/wakaru/2CEL3AYmv8e5.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/3uCgq1Cgj1fX.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/6i13A1lNDbl6.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/9XQoPgNL22UT.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/9ysrgyhaDF42.png',
'https://media.makotia.me/wakaritetsuya/wakaru/b1VCm39ptA2X.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/HZd7BNTExtLm.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/JokPZNWleJ4W.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/lqzpoh3TtO6F.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/myn3tvaQ8G6r.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/PBvjYl2QFAJS.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/RcSwa3cDTjfg.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/tuvFpye24VwT.jpg',
'https://media.makotia.me/wakaritetsuya/wakaru/UA7Xg9W1VAqN.jpg'
]
event.send_message(wakaru.shuffle.shuffle.shuffle.sample)
elsif event.content =~ /.*わからない.*/
wakaranai = [
'https://media.makotia.me/wakaritetsuya/wakaranai/paFNbrjg9Pq5.jpg',
'https://media.makotia.me/wakaritetsuya/wakaranai/QI0r7HfzK1bu.jpg'
]
event.send_message(wakaranai.shuffle.shuffle.shuffle.sample)
elsif event.content =~ /.*せやな.*/
seyana = [
'https://media.makotia.me/wakaritetsuya/seyana/bog5sheiyooB.png'
]
event.send_message(seyana.shuffle.shuffle.shuffle.sample)
end
end
bot.reaction_add do |event|
if event.message.author.id.to_i == config['discord']['client_id'].to_i && (event.emoji.name == "🤛" || event.emoji.name == "🤜")
event.message.delete
end
end
bot.run