-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell_commands.rb
47 lines (36 loc) · 1.04 KB
/
shell_commands.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
#!/usr/bin/env
module Commands
def send id = @cfg["bot_owner"], say = nil
id = @bot.pm_channel(id).id if @bot.pm_channel(id) rescue id
@bot.send_message(id, say || @bot.pick_quote())
end
def purge id = @cfg["bot_owner"], quant = 50, condition = nil
channel = @bot.pm_channel(id) rescue nil
return unless channel
history = event.channel.history(quant).select do |m|
unless condition
m.author.id == @bot.profile.id
else
eval(condition.join(' '))
end
end
if history.length < 2 or history.length > 100
puts "Can only delete between 2 and 100 messages!"
return
end
channel.delete_messages(history, false)
end
def read id = @cfg["bot_owner"], quant = 10
channel = @bot.pm_channel(id) if @bot.pm_channel(id) rescue nil
channel ||= @bot.channel(id)
channel.history(quant).reverse_each do |m|
next if m.content == ""
next if m.content =~ /^\s+$/m
puts "\r#{m.author.name}: #{m.content}"
end
end
def push commit = "Version bump"
system("./push.sh \"#{commit}\"")
end
alias_method :ping, :send
end