diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index 91b98ad..1e0db5e 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -1,215 +1,228 @@ class MessageController < ActionController::API def message_process - ENV['DOMAIN'] = 'https://asd.ferdinando.me' - message = params[:message] - return if message.nil? || message[:chat].nil? || message[:text].nil? - unless message[:text].nil? - text = message[:text] - else - text = message[:caption] - end - if text.split('@').count == 2 - if text.split('@')[1] == ENV['BOT_USERNAME'] - text = text.split('@')[0] - end - end - type = message[:chat][:type] - id = message[:chat][:id] - username = message[:chat][:username] - update_id = params[:update_id] - fromid = message[:from][:id] - fromusername = message[:from][:username] - - unless Group.find_by(chat_id: id) && (type == 'group' || type == 'supergroup') - @group = Group.create(chat_id: id, username: username, title: message[:chat][:title]) if id < 0 - else - @group = Group.find_by(chat_id: id) - title = message[:chat][:title] - if @group.title.nil? || @group.title != title - @group.update_attribute(:title, title) + begin + ENV['DOMAIN'] = 'https://asd.ferdinando.me' + message = params[:message] + return if message.nil? || message[:chat].nil? || message[:text].nil? + unless message[:text].nil? + text = message[:text] + else + text = message[:caption] end - - if @group.username != message[:chat][:username] - @group.update_attribute(:username, message[:chat][:username]) - end - end + if text.split('@').count == 2 + if text.split('@')[1] == ENV['BOT_USERNAME'] + text = text.split('@')[0] + end + end + type = message[:chat][:type] + id = message[:chat][:id] + username = message[:chat][:username] + update_id = params[:update_id] + fromid = message[:from][:id] + fromusername = message[:from][:username] - unless @group.nil? - unless @group.welcomesent - Telegram.bot.send_message(chat_id: @group.chat_id, text: "Bella zio! Sono il bot asdoso creato da Ferdinando Traversa (ferdinando.me) da idea di Valerio Bozzolan, asd! Digita /grafico per ricevere il link ad un grafico, anche in privato per averne uno personale, asd o /classifica per scoprire cose interessanti. L'impostazione automaticaè che io invii il conto degli ASD alla fine della serata, così però ti perdi cose belle e non è più così funny. Per modificare questa impostazione, basta digitare /nightsend ed invierò il messaggio di conteggio appena invii un asd. Se vuoi che il bot non parli, ma veda e senta, usa /silent. Ti prego! Non togliere il bot, lascialo per fini statistici.") - @group.update_attribute(:welcomesent, true) + unless Group.find_by(chat_id: id) && (type == 'group' || type == 'supergroup') + @group = Group.create(chat_id: id, username: username, title: message[:chat][:title]) if id < 0 + else + @group = Group.find_by(chat_id: id) + title = message[:chat][:title] + if @group.title.nil? || @group.title != title + @group.update_attribute(:title, title) + end + + if @group.username != message[:chat][:username] + @group.update_attribute(:username, message[:chat][:username]) + end end - end - unless Sender.find_by(chat_id: fromid) - first_name = message[:from][:first_name] - last_name = message[:from][:last_name] - totalname = "#{first_name} #{last_name}" - @sender = Sender.create(chat_id: fromid, username: fromusername, name: totalname) - else - @sender = Sender.find_by(chat_id: fromid) - first_name = message[:from][:first_name] - last_name = message[:from][:last_name] - totalname = "#{first_name} #{last_name}" - if @sender.name.nil? || @sender.name != totalname - @sender.update_attribute(:name, totalname) + unless @group.nil? + unless @group.welcomesent + Telegram.bot.send_message(chat_id: @group.chat_id, text: "Bella zio! Sono il bot asdoso creato da Ferdinando Traversa (ferdinando.me) da idea di Valerio Bozzolan, asd! Digita /grafico per ricevere il link ad un grafico, anche in privato per averne uno personale, asd o /classifica per scoprire cose interessanti. L'impostazione automaticaè che io invii il conto degli ASD alla fine della serata, così però ti perdi cose belle e non è più così funny. Per modificare questa impostazione, basta digitare /nightsend ed invierò il messaggio di conteggio appena invii un asd. Se vuoi che il bot non parli, ma veda e senta, usa /silent. Ti prego! Non togliere il bot, lascialo per fini statistici.") + @group.update_attribute(:welcomesent, true) + end + + @admins = Telegram.bot.get_chat_administrators(chat_id: @group.chat_id) + @admins['result'].each do |result| + if result['user']['username'].downcase == ENV['BOT_USERNAME'].downcase + @group.update_attribute(:admin, true) + else + @group.update_attribute(:admin, false) + end + end end - - if @sender.username != message[:from][:username] - @sender.update_attribute(:username, message[:from][:username]) + + unless Sender.find_by(chat_id: fromid) + first_name = message[:from][:first_name] + last_name = message[:from][:last_name] + totalname = "#{first_name} #{last_name}" + @sender = Sender.create(chat_id: fromid, username: fromusername, name: totalname) + else + @sender = Sender.find_by(chat_id: fromid) + first_name = message[:from][:first_name] + last_name = message[:from][:last_name] + totalname = "#{first_name} #{last_name}" + if @sender.name.nil? || @sender.name != totalname + @sender.update_attribute(:name, totalname) + end + + if @sender.username != message[:from][:username] + @sender.update_attribute(:username, message[:from][:username]) + end + end - end - - if type == 'group' || type == 'supergroup' - if text =~ /asd/i - multiplevalue = text.scan(/asd/i).count - defmultiplevalue = multiplevalue - 1 - precedenteconto = @group.asds.totalcount - @asd = Asd.create(group: @group, sender: @sender, text: text, update_id: update_id, multiple_times: defmultiplevalue) - - unless Asd.find_by(sender: @sender) - unless @group.classifica - Telegram.bot.send_message(chat_id: @group.chat_id, text: "Ciao amico, questo gruppo ha la classifica privata. È la prima volta che ti vedo e quindi imposto la classifica privata anche per te, non sarai visto in classifica! Se vai invece fiero della tua asdosità, manda il comando /fuoriclassifica in privato e riattiverò la tua presenza in classifica. Puoi anche dare /classifica per vedere questa classifica di cui tutti parlano o /grafico per il tuo grafico personal personal.") - @sender.update_attribute(classifica: false) + if type == 'group' || type == 'supergroup' + if text =~ /asd/i + multiplevalue = text.scan(/asd/i).count + defmultiplevalue = multiplevalue - 1 + precedenteconto = @group.asds.totalcount + @asd = Asd.create(group: @group, sender: @sender, text: text, update_id: update_id, multiple_times: defmultiplevalue) + + unless Asd.find_by(sender: @sender) + unless @group.classifica + Telegram.bot.send_message(chat_id: @group.chat_id, text: "Ciao amico, questo gruppo ha la classifica privata. È la prima volta che ti vedo e quindi imposto la classifica privata anche per te, non sarai visto in classifica! Se vai invece fiero della tua asdosità, manda il comando /fuoriclassifica in privato e riattiverò la tua presenza in classifica. Puoi anche dare /classifica per vedere questa classifica di cui tutti parlano o /grafico per il tuo grafico personal personal.") + @sender.update_attribute(classifica: false) + end end - end - asdcount = @group.asds.count - case @group.asds.totalcount - when 100 - addtext = 'IL CENTESIMO ASD, ASD! COMPLIMENTS CONGRATULATIONS AUF WIDERSHEN' - SpecialEvent.create(text: addtext, group: @group, asd: @asd) - when 1000 - addtext = '1000 asd, wow! Questo gruppo, così asdoso, asd' - SpecialEvent.create(text: addtext, group: @group, asd: @asd) - when 10000 - addtext = '10000è un record mondiale, asd' - SpecialEvent.create(text: addtext, group: @group, asd: @asd) - when 100000 - addtext = '100000, sei il campione degli asd.' - SpecialEvent.create(text: addtext, group: @group, asd: @asd) + asdcount = @group.asds.count + case @group.asds.totalcount + when 100 + addtext = 'IL CENTESIMO ASD, ASD! COMPLIMENTS CONGRATULATIONS AUF WIDERSHEN' + SpecialEvent.create(text: addtext, group: @group, asd: @asd) + when 1000 + addtext = '1000 asd, wow! Questo gruppo, così asdoso, asd' + SpecialEvent.create(text: addtext, group: @group, asd: @asd) + when 10000 + addtext = '10000è un record mondiale, asd' + SpecialEvent.create(text: addtext, group: @group, asd: @asd) + when 100000 + addtext = '100000, sei il campione degli asd.' + SpecialEvent.create(text: addtext, group: @group, asd: @asd) + end + if SpecialEvent.find_by(asd: @asd) && !@group.silent + Telegram.bot.send_photo(chat_id: @group.chat_id, photo: 'http://www.lanciano.it/faccine/asdone.gif', caption: "Così asdoso, asd. #{SpecialEvent.find_by(asd: @asd).text}") + SpecialEvent.find_by(asd: @asd).destroy + end + + unless @group.nightsend || @group.silent + position = Group.all.sort_by{|group| group.asds.totalcount}.pluck(:id).reverse.find_index(@group.id) + 1 + altdef = " (+#{defmultiplevalue})" if defmultiplevalue > 0 + altdef = "" if defmultiplevalue == 0 + Telegram.bot.send_message(chat_id: @group.chat_id, text: "Il contasd conta ben #{precedenteconto + 1}#{altdef}, asd. Sei il #{position}º gruppo per ASD inviati.") end - if SpecialEvent.find_by(asd: @asd) && !@group.silent - Telegram.bot.send_photo(chat_id: @group.chat_id, photo: 'http://www.lanciano.it/faccine/asdone.gif', caption: "Così asdoso, asd. #{SpecialEvent.find_by(asd: @asd).text}") - SpecialEvent.find_by(asd: @asd).destroy + unless @asd.created_at.nil? + if @asd.created_at.strftime('%H:%M') == '00:00' + Telegram.bot.send_message(chat_id: @group.chat_id, text: "Asd di mezzanotte %F0%9F%8C%9A") end - - unless @group.nightsend || @group.silent - position = Group.all.sort_by{|group| group.asds.totalcount}.pluck(:id).reverse.find_index(@group.id) + 1 - altdef = " (+#{defmultiplevalue})" if defmultiplevalue > 0 - altdef = "" if defmultiplevalue == 0 - Telegram.bot.send_message(chat_id: @group.chat_id, text: "Il contasd conta ben #{precedenteconto + 1}#{altdef}, asd. Sei il #{position}º gruppo per ASD inviati.") - end -unless @asd.created_at.nil? - if @asd.created_at.strftime('%H:%M') == '00:00' - Telegram.bot.send_message(chat_id: @group.chat_id, text: "Asd di mezzanotte %F0%9F%8C%9A") + end + end -end - + end + + if text == '/start' && (type == 'group' || type == 'supergroup') + unless Group.find_by(chat_id: id) + @group = Group.create(chat_id: id, username: username) if id < 0 + else + @group = Group.find_by(chat_id: id) end - end - - if text == '/start' && (type == 'group' || type == 'supergroup') - unless Group.find_by(chat_id: id) - @group = Group.create(chat_id: id, username: username) if id < 0 - else - @group = Group.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: @group.chat_id, text: "Bella zio! Sono il bot asdoso creato da Ferdinando Traversa (ferdinando.me) da idea di Valerio Bozzolan, asd! Digita /grafico per ricevere il link ad un grafico, anche in privato per averne uno personale, asd o /classifica per scoprire cose interessanti. L'impostazione automaticaè che io invii il conto degli ASD alla fine della serata, così però ti perdi cose belle e non è più così funny. Per modificare questa impostazione, basta digitare /nightsend ed invierò il messaggio di conteggio appena invii un asd. Se vuoi che il bot non parli, ma veda e senta, usa /silent. Ti prego! Non togliere il bot, lascialo per fini statistici.") + @group.update_attribute(:welcomesent, true) end - Telegram.bot.send_message(chat_id: @group.chat_id, text: "Bella zio! Sono il bot asdoso creato da Ferdinando Traversa (ferdinando.me) da idea di Valerio Bozzolan, asd! Digita /grafico per ricevere il link ad un grafico, anche in privato per averne uno personale, asd o /classifica per scoprire cose interessanti. L'impostazione automaticaè che io invii il conto degli ASD alla fine della serata, così però ti perdi cose belle e non è più così funny. Per modificare questa impostazione, basta digitare /nightsend ed invierò il messaggio di conteggio appena invii un asd. Se vuoi che il bot non parli, ma veda e senta, usa /silent. Ti prego! Non togliere il bot, lascialo per fini statistici.") - @group.update_attribute(:welcomesent, true) - end - if text == '/classifica' - Telegram.bot.send_message(chat_id: id, text: "Vai su #{ENV['DOMAIN']}/classifica per vedere la classifica.") - end - - if text == '/start' && type == 'private' - Telegram.bot.send_message(chat_id: id, text: "Bella zio! Sono il bot asdoso creato da Ferdinando Traversa (ferdinando.me @ferdi2005) da idea di Valerio Bozzolan, asd! Aggiungimi ad un bel gruppo e conterò gli asd, altrimenti digita /grafico per il tuo grafico personal personal.") - end + if text == '/classifica' + Telegram.bot.send_message(chat_id: id, text: "Vai su #{ENV['DOMAIN']}/classifica per vedere la classifica.") + end + + if text == '/start' && type == 'private' + Telegram.bot.send_message(chat_id: id, text: "Bella zio! Sono il bot asdoso creato da Ferdinando Traversa (ferdinando.me @ferdi2005) da idea di Valerio Bozzolan, asd! Aggiungimi ad un bel gruppo e conterò gli asd, altrimenti digita /grafico per il tuo grafico personal personal.") + end - if text == '/grafico' && type == 'private' - unless Sender.find_by(chat_id: fromid) - Telegram.bot.send_message(chat_id: id, text: 'Non ho ancora un grafico per te, sei nuovo per me, non ti conosco. Iscriviti in qualche gruppo con questo bot e manda asd a ripetizione, poi torna da me.') - else - @sender = Sender.find_by(chat_id: fromid) - position = Sender.all.sort_by{|sender| sender.asds.totalcount}.pluck(:id).reverse.find_index(@sender.id) + 1 if Sender.count > 0 - Telegram.bot.send_message(chat_id: id, text: "Guarda il tuo grafico personalizzato per il gruppo su #{ENV['DOMAIN']}/grafico?s=#{@sender.chat_id} Inoltre sappi che sei il #{position}º inviatore di asd nel mondo!") + if text == '/grafico' && type == 'private' + unless Sender.find_by(chat_id: fromid) + Telegram.bot.send_message(chat_id: id, text: 'Non ho ancora un grafico per te, sei nuovo per me, non ti conosco. Iscriviti in qualche gruppo con questo bot e manda asd a ripetizione, poi torna da me.') + else + @sender = Sender.find_by(chat_id: fromid) + position = Sender.all.sort_by{|sender| sender.asds.totalcount}.pluck(:id).reverse.find_index(@sender.id) + 1 if Sender.count > 0 + Telegram.bot.send_message(chat_id: id, text: "Guarda il tuo grafico personalizzato per il gruppo su #{ENV['DOMAIN']}/grafico?s=#{@sender.chat_id} Inoltre sappi che sei il #{position}º inviatore di asd nel mondo!") + end end - end - - if text == '/grafico' && (type == 'group' || type == 'supergroup') - unless Group.find_by(chat_id: id) - Telegram.bot.send_message(chat_id: id, text: 'Non ho ancora un grafico per te, sei nuovo per me, non ti conosco. Invia qualche asd e prova questo comando.') - else - @group = Group.find_by(chat_id: id) - Telegram.bot.send_message(chat_id: id, text: "Guarda il tuo grafico personalizzato per il gruppo su #{ENV['DOMAIN']}/grafico?g=#{@group.chat_id}") + + if text == '/grafico' && (type == 'group' || type == 'supergroup') + unless Group.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: id, text: 'Non ho ancora un grafico per te, sei nuovo per me, non ti conosco. Invia qualche asd e prova questo comando.') + else + @group = Group.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: id, text: "Guarda il tuo grafico personalizzato per il gruppo su #{ENV['DOMAIN']}/grafico?g=#{@group.chat_id}") + end end - end - if text == '/nightsend' && (type == 'group' || type == 'supergroup') - unless Group.find_by(chat_id: id) - Telegram.bot.send_message(chat_id: id, text: "Non conosco questo gruppo.") - else - @group = Group.find_by(chat_id: id) - if @group.nightsend - Telegram.bot.send_message(chat_id: id, text: "Ok, l'impostazione predefinitaè che l'invio del conto degli asd avvenga a mezzanotte, ma con questo comando la modifico. Procedo, ora avrai un messaggio ogni asd, asd.") - @group.update_attribute(:nightsend, false) + if text == '/nightsend' && (type == 'group' || type == 'supergroup') + unless Group.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: id, text: "Non conosco questo gruppo.") else - Telegram.bot.send_message(chat_id: id, text: "Sei una persona triste, asd. Vuoi che il conteggio venga inviato a mezzanotte. Bozzolan dice sì, Ferdi dice no. Tu dici sì, allora conteggio a mezzanotte sia, asd") - @group.update_attribute(:nightsend, true) + @group = Group.find_by(chat_id: id) + if @group.nightsend + Telegram.bot.send_message(chat_id: id, text: "Ok, l'impostazione predefinitaè che l'invio del conto degli asd avvenga a mezzanotte, ma con questo comando la modifico. Procedo, ora avrai un messaggio ogni asd, asd.") + @group.update_attribute(:nightsend, false) + else + Telegram.bot.send_message(chat_id: id, text: "Sei una persona triste, asd. Vuoi che il conteggio venga inviato a mezzanotte. Bozzolan dice sì, Ferdi dice no. Tu dici sì, allora conteggio a mezzanotte sia, asd") + @group.update_attribute(:nightsend, true) + end end end - end - if text == '/silent' && (type == 'group' || type == 'supergroup') - unless Group.find_by(chat_id: id) - Telegram.bot.send_message(chat_id: id, text: "Non conosco questo gruppo.") - else - @group = Group.find_by(chat_id: id) - if @group.silent - Telegram.bot.send_message(chat_id: id, text: "Oh grazie, sei tornato nella luce, pensavo di dover rimanere muto per sempre! Ora, il tuo gruppo ha l'invio del conto notturno degli asd impostato a #{@group.nightsend ? 'attivo' : 'disattivo'}. Se vuoi che invii il conto degli asd la notte attivalo, altrimenti se vuoi un messaggio ogni asd disattivalo. Lo fai col comando /nightsend") - @group.update_attribute(:silent, false) + if text == '/silent' && (type == 'group' || type == 'supergroup') + unless Group.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: id, text: "Non conosco questo gruppo.") else - Telegram.bot.send_message(chat_id: id, text: "Se vuoi che me ne rimanga zitto zitto nelle tenebre allora usa questo comando, per far che ritorni a parlare digitalo di nuovo.") - @group.update_attribute(:silent, true) + @group = Group.find_by(chat_id: id) + if @group.silent + Telegram.bot.send_message(chat_id: id, text: "Oh grazie, sei tornato nella luce, pensavo di dover rimanere muto per sempre! Ora, il tuo gruppo ha l'invio del conto notturno degli asd impostato a #{@group.nightsend ? 'attivo' : 'disattivo'}. Se vuoi che invii il conto degli asd la notte attivalo, altrimenti se vuoi un messaggio ogni asd disattivalo. Lo fai col comando /nightsend") + @group.update_attribute(:silent, false) + else + Telegram.bot.send_message(chat_id: id, text: "Se vuoi che me ne rimanga zitto zitto nelle tenebre allora usa questo comando, per far che ritorni a parlare digitalo di nuovo.") + @group.update_attribute(:silent, true) + end end end - end - if text == '/fuoriclassifica' && (type == 'group' || type == 'supergroup') - unless Group.find_by(chat_id: id) - Telegram.bot.send_message(chat_id: id, text: "Non conosco questo gruppo.") - else - @group = Group.find_by(chat_id: id) - if @group.classifica - Telegram.bot.send_message(chat_id: id, text: "Siete delle persone tristi e/o poco competitive? Amate la privasi anche se Google sa tutto di voi, anche come vi siete vestiti ieri, asd? Allora questo è il comando per voi. Da oggi siete fuori dalla classifica, per scelta. Datelo di nuovo per riattivare (sicuramente avete sbagliato, vero?)") - @group.update_attribute(:classifica, false) + if text == '/fuoriclassifica' && (type == 'group' || type == 'supergroup') + unless Group.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: id, text: "Non conosco questo gruppo.") else - Telegram.bot.send_message(chat_id: id, text: "Bravo! Hai fatto la scelta giusta, fai ritornare il tuo gruppo nella classifica pubblica con questo semplice comandino") - @group.update_attribute(:classifica, true) + @group = Group.find_by(chat_id: id) + if @group.classifica + Telegram.bot.send_message(chat_id: id, text: "Siete delle persone tristi e/o poco competitive? Amate la privasi anche se Google sa tutto di voi, anche come vi siete vestiti ieri, asd? Allora questo è il comando per voi. Da oggi siete fuori dalla classifica, per scelta. Datelo di nuovo per riattivare (sicuramente avete sbagliato, vero?)") + @group.update_attribute(:classifica, false) + else + Telegram.bot.send_message(chat_id: id, text: "Bravo! Hai fatto la scelta giusta, fai ritornare il tuo gruppo nella classifica pubblica con questo semplice comandino") + @group.update_attribute(:classifica, true) + end end end - end - if text == '/fuoriclassifica' && type == 'private' - unless Sender.find_by(chat_id: id) - Telegram.bot.send_message(chat_id: id, text: "Non ti conosco, asd.") - else - @group = Sender.find_by(chat_id: id) - if @group.classifica - Telegram.bot.send_message(chat_id: id, text: "Sei una persona triste o poco competitiva? Questo è il comando giusto per te. Da oggi non apparirai più nella classifica pubblica.") - @group.update_attribute(:classifica, false) + if text == '/fuoriclassifica' && type == 'private' + unless Sender.find_by(chat_id: id) + Telegram.bot.send_message(chat_id: id, text: "Non ti conosco, asd.") else - Telegram.bot.send_message(chat_id: id, text: "Bravo! Hai fatto la scelta giusta, ritorna nella classifica pubblica con questo semplice comandino") - @group.update_attribute(:classifica, true) + @group = Sender.find_by(chat_id: id) + if @group.classifica + Telegram.bot.send_message(chat_id: id, text: "Sei una persona triste o poco competitiva? Questo è il comando giusto per te. Da oggi non apparirai più nella classifica pubblica.") + @group.update_attribute(:classifica, false) + else + Telegram.bot.send_message(chat_id: id, text: "Bravo! Hai fatto la scelta giusta, ritorna nella classifica pubblica con questo semplice comandino") + @group.update_attribute(:classifica, true) + end end end - end - comandi = ["/fuoriclassifica", "/classifica", "/start", "/grafico", "/nightsend"] - if !text.in?(comandi) && type == 'private' - Telegram.bot.send_message(chat_id: id, text: "Cos…? asd") + comandi = ["/fuoriclassifica", "/classifica", "/start", "/grafico", "/nightsend"] + if !text.in?(comandi) && type == 'private' + Telegram.bot.send_message(chat_id: id, text: "Cos…? asd") + end + render nothing: true + rescue => e + Telegram.bot.send_message(chat_id: 82247861, text: "#{e}") end - render nothing: true - end + end end diff --git a/db/migrate/20190908140055_add_admin_to_groups.rb b/db/migrate/20190908140055_add_admin_to_groups.rb new file mode 100644 index 0000000..1a99d5d --- /dev/null +++ b/db/migrate/20190908140055_add_admin_to_groups.rb @@ -0,0 +1,6 @@ +class AddAdminToGroups < ActiveRecord::Migration[5.2] + def change + add_column :groups, :admin, :boolean + add_column :groups, :deletenotasd, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 10b5bae..61a49c0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,76 +1,78 @@ # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_08_14_132440) do +ActiveRecord::Schema.define(version: 2019_09_08_140055) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "asds", force: :cascade do |t| t.bigint "group_id" t.bigint "sender_id" t.integer "update_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "text" t.boolean "nightsend" t.integer "multiple_times" t.index ["group_id"], name: "index_asds_on_group_id" t.index ["sender_id"], name: "index_asds_on_sender_id" end create_table "crono_jobs", force: :cascade do |t| t.string "job_id", null: false t.text "log" t.datetime "last_performed_at" t.boolean "healthy" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["job_id"], name: "index_crono_jobs_on_job_id", unique: true end create_table "groups", force: :cascade do |t| t.bigint "chat_id" t.string "username" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "welcomesent", default: false t.boolean "nightsend" t.string "title" t.boolean "classifica", default: true t.boolean "silent", default: false + t.boolean "admin" + t.boolean "deletenotasd" end create_table "senders", force: :cascade do |t| t.integer "chat_id" t.string "username" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "name" t.boolean "classifica", default: true end create_table "special_events", force: :cascade do |t| t.bigint "group_id" t.string "text" t.bigint "asd_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["asd_id"], name: "index_special_events_on_asd_id" t.index ["group_id"], name: "index_special_events_on_group_id" end add_foreign_key "asds", "groups" add_foreign_key "asds", "senders" add_foreign_key "special_events", "asds" add_foreign_key "special_events", "groups" end