Sha256: 3da5adb4e4b1b575966b89d8a939b0756b0af9f20dd7343716954bc00b5d7e05
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
class SlackSmartBot def delete_announcement(user, message_id) save_stats(__method__) if has_access?(__method__, user) if Thread.current[:typem] == :on_call channel = Thread.current[:dchannel] else channel = Thread.current[:dest] end if File.exists?("#{config.path}/announcements/#{channel}.csv") and !@announcements.key?(channel) t = CSV.table("#{config.path}/announcements/#{channel}.csv", headers: ['message_id', 'user_deleted', 'user_created', 'date', 'time', 'type', 'message']) @announcements[channel] = t end found = false message = '' if @announcements.key?(channel) and @announcements[channel][:message_id].include?(message_id.to_i) CSV.open("#{config.path}/announcements/#{channel}.csv", "w") do |csv| @announcements[channel].each do |row| if row[:message_id].to_i == message_id.to_i message = row[:message] row[:user_deleted] = user.name end csv << row end end respond "The announcement has been deleted: #{message}" else respond "Sorry but I didn't find the message id #{message_id}. Call `see announcements` to see the ids." end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-smart-bot-1.10.0 | lib/slack/smart-bot/commands/general/delete_announcement.rb |