├── .gitattributes ├── .travis.yml ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── .bot.swp.gz ├── bot └── bot~ ├── config ├── database.yml ├── locales.yml └── secrets.yml ├── db └── migrate │ └── 001_create_users.rb ├── lib ├── .message_responder.rb.swp.gz ├── .message_sender.rb.swp.gz ├── .reply_markup_formatter.rb.swp.gz ├── app_configurator.rb ├── database_connector.rb ├── message_responder.rb ├── message_sender.rb └── reply_markup_formatter.rb ├── models └── user.rb ├── ruby └── runner.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-language=Ruby 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.2 4 | - jruby 5 | - rbx-2 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing To Evil Insult Generator 2 | 3 | 👍🎉 First off, thanks for taking the time to contribute! 🎉👍 4 | 5 | The following is a set of guidelines for contributing to [Evil Insult Generator](https://evilinsult.com/), which are hosted on [GitHub](https://github.com/EvilInsultGenerator/). 6 | These are just guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. 7 | 8 | ## What should I know before I get started? 9 | 10 | ### Code of Conduct 11 | 12 | This project adheres to the [Contributor Covenant code of conduct](https://contributor-covenant.org/version/1/4/). 13 | By participating, you are expected to uphold this code. Please report unacceptable behavior to [marvin@evilinsult.com](mailto:marvin@evilinsult.com). 14 | 15 | ### Contact 16 | 17 | If you have any questions or are unsure about something just drop a line to [marvin@evilinsult.com](mailto:marvin@evilinsult.com). 18 | 19 | ### Design Decisions 20 | 21 | If you plan to make a significant decision in how to maintain the project and what it can or cannot support please send an email beforehand. 22 | 23 | ## How Can I Contribute? 24 | 25 | ### Reporting Bugs 26 | 27 | This section guides you through submitting a bug report for [Evil Insult Generator](https://evilinsult.com/) software. Following these guidelines helps maintainers and the community understand your report 📝, reproduce the behavior 📱💻🎮, and find related reports 🔎. 28 | 29 | Before creating bug reports, please check this list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible. 30 | 31 | ### Suggesting Enhancements 32 | 33 | This section guides you through submitting an enhancement suggestion for [Evil Insult Generator](https://evilinsult.com/), including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion 📝 and find related suggestions 🔎. 34 | 35 | Before creating enhancement suggestions, please check this list as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please include as many details as possible. 36 | 37 | ### Pull Requests 38 | 39 | + Include screenshots and animated GIFs in your pull request whenever possible. 40 | + Create a [branch](https://guides.github.com/introduction/flow/) for your edit 41 | 42 | ### Git Commit Messages 43 | 44 | + Use the present tense ("Add feature" not "Added feature") 45 | + Use the imperative mood ("Move cursor to..." not "Moves cursor to...") 46 | + Limit the first line to 72 characters or less 47 | + Reference issues and pull requests liberally 48 | + When only changing documentation, include [ci skip] in the commit description 49 | + Consider starting the commit message with an applicable emoji: 50 | 51 | 🎨 :art: when improving the format/structure of the code 52 | 🐎 :racehorse: when improving performance 53 | 🚱 :non-potable_water: when plugging memory leaks 54 | 📝 :memo: when writing docs 55 | 🐧 :penguin: when fixing something on Linux 56 | 🍎 :apple: when fixing something on macOS 57 | 🏁 :checkered_flag: when fixing something on Windows 58 | 🐛 :bug: when fixing a bug 59 | 🔥 :fire: when removing code or files 60 | 💚 :green_heart: when fixing the CI build 61 | ✅ :white_check_mark: when adding tests 62 | 🔒 :lock: when dealing with security 63 | ⬆️ :arrow_up: when upgrading dependencies 64 | ⬇️ :arrow_down: when downgrading dependencies 65 | 👕 :shirt: when removing linter warnings 66 | 67 | 68 | __Thank you so much! 😘__ 69 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'telegram-bot-ruby', '~> 0.2.6' 4 | gem 'activerecord', '~> 4.2', '>= 4.2.5' 5 | gem 'i18n', '~> 0.7.0' 6 | gem 'json' 7 | gem 'pg' 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Evil Insult Generator Ruby Telegram Bot 2 | 3 | Evil Insult Generator's goal is to offer the most evil insults. Please help us to reach this honorable purpose by submitting insults via mail. 4 | 5 | ![Evil Insult Generator Icon](https://cloud.githubusercontent.com/assets/22981912/19600664/5521d010-97a6-11e6-9f67-fec931b199d7.png) 6 | 7 | ### Installation 8 | 9 | Clone this repository to your local machine 10 | `git clone https://github.com/EvilInsultGenerator/telegram-bot-ruby.git` 11 | For the first you need to install gems required to start a bot: 12 | `bundle install` 13 | Then you need to create `secrets.yml` where your bot unique tokens will be stored and `database.yml` where database credentials will be stored. 14 | ```ruby 15 | #config/database.yml 16 | adapter: postgresql 17 | database: *your_DB_name* 18 | encoding: unicode 19 | pool: 5 20 | timeout: 5000 21 | ``` 22 | ```ruby 23 | #config/secrets.yml 24 | telegram_bot_token: *your_bot_token* 25 | botan_token: *your_botan_token* 26 | ``` 27 | Then you need to fill your Telegram bot unique token to the `secrets.yml` file and your database credentials to `database.yml`. 28 | 29 | After this you need to create and migrate your database: 30 | `rake db:create db:migrate` 31 | Great! 32 | Now you can easily start your bot just by running this command: 33 | `bin/bot` 34 | 35 | Some more specific info you can also find [here](https://github.com/atipugin/telegram-bot-ruby). 36 | 37 | __Try out [@EIG_bot](https://telegram.me/EIG_bot).__ 38 | 39 | ### Contact 40 | 41 | We love to get in touch with you. Feel welcome to email your questions and feedback to [marvin@evilinsult.com](mailto:marvin@evilinsult.com). 42 | 43 | ### License 44 | > This is free and unencumbered software released into the public domain. 45 | > 46 | > Anyone is free to copy, modify, publish, use, compile, sell, or 47 | > distribute this software, either in source code form or as a compiled 48 | > binary, for any purpose, commercial or non-commercial, and by any 49 | > means. 50 | > 51 | > In jurisdictions that recognize copyright laws, the author or authors 52 | > of this software dedicate any and all copyright interest in the 53 | > software to the public domain. We make this dedication for the benefit 54 | > of the public at large and to the detriment of our heirs and 55 | > successors. We intend this dedication to be an overt act of 56 | > relinquishment in perpetuity of all present and future rights to this 57 | > software under copyright law. 58 | > 59 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 60 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 61 | > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 62 | > IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 63 | > OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 64 | > ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 65 | > OTHER DEALINGS IN THE SOFTWARE. 66 | > 67 | > For more information, please refer to 68 | 69 | ### Screenshots 70 | ![Evil Insult Generator Ruby Telegram Bot Screenshot](https://cloud.githubusercontent.com/assets/23016876/19629005/3edce1c0-996b-11e6-8beb-d19453826a1c.png) 71 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler/setup' 3 | 4 | require 'pg' 5 | require 'active_record' 6 | require 'yaml' 7 | 8 | namespace :db do 9 | 10 | desc 'Migrate the database' 11 | task :migrate do 12 | connection_details = YAML::load(File.open('config/database.yml')) 13 | ActiveRecord::Base.establish_connection(connection_details) 14 | ActiveRecord::Migrator.migrate('db/migrate/') 15 | end 16 | 17 | desc 'Create the database' 18 | task :create do 19 | connection_details = YAML::load(File.open('config/database.yml')) 20 | admin_connection = connection_details.merge({'database'=> 'postgres', 21 | 'schema_search_path'=> 'public'}) 22 | ActiveRecord::Base.establish_connection(admin_connection) 23 | ActiveRecord::Base.connection.create_database(connection_details.fetch('database')) 24 | end 25 | 26 | desc 'Drop the database' 27 | task :drop do 28 | connection_details = YAML::load(File.open('config/database.yml')) 29 | admin_connection = connection_details.merge({'database'=> 'postgres', 30 | 'schema_search_path'=> 'public'}) 31 | ActiveRecord::Base.establish_connection(admin_connection) 32 | ActiveRecord::Base.connection.drop_database(connection_details.fetch('database')) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /bin/.bot.swp.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvilInsultGenerator/telegram-bot-ruby/aaaed8c44c37f7cfc50e67f13ead1016002cf39b/bin/.bot.swp.gz -------------------------------------------------------------------------------- /bin/bot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'telegram/bot' 4 | require 'telegram/bot/botan' 5 | require './lib/message_responder' 6 | require './lib/app_configurator' 7 | 8 | config = AppConfigurator.new 9 | config.configure 10 | 11 | token = config.get_token 12 | logger = config.get_logger 13 | botan_token=config.get_botan_token 14 | 15 | logger.debug 'Starting telegram bot' 16 | 17 | Telegram::Bot::Client.run(token) do |bot| 18 | bot.listen do |message| 19 | bot.enable_botan!(botan_token) 20 | options = {bot: bot, message: message} 21 | content = 22 | if message.respond_to?(:text) 23 | message.text 24 | elsif message.respond_to?(:query) 25 | message.query 26 | else 27 | message.data 28 | end 29 | logger.debug "@#{message.from.username}: #{content}" 30 | begin 31 | MessageResponder.new(options).respond 32 | rescue Telegram::Bot::Exceptions::ResponseError 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /bin/bot~: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'telegram/bot' 4 | require 'telegram/bot/botan' 5 | require './lib/message_responder' 6 | require './lib/app_configurator' 7 | 8 | config = AppConfigurator.new 9 | config.configure 10 | 11 | token = config.get_token 12 | logger = config.get_logger 13 | botan_token=config.get_botan_token 14 | 15 | logger.debug 'Starting telegram bot' 16 | 17 | Telegram::Bot::Client.run(token) do |bot| 18 | bot.listen do |message| 19 | bot.enable_botan!(botan_token) 20 | options = {bot: bot, message: message} 21 | content = message.respond_to?(:text) ? message.text : message.data 22 | logger.debug "@#{message.from.username}: #{content}" 23 | MessageResponder.new(options).respond 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | adapter: postgresql 2 | database: insultbot 3 | encoding: unicode 4 | pool: 5 5 | timeout: 5000 6 | -------------------------------------------------------------------------------- /config/locales.yml: -------------------------------------------------------------------------------- 1 | en: 2 | greeting_message: "Welcome To The Evil Insult Generator Telegram Bot!" 3 | farewell_message: "Bye! I'll miss you :(" 4 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | telegram_bot_token: 195084YOURTELEGRAMBOTTOKENHEREEtrdjNA 2 | botan_token: gTBrYOURBOTANTOKENHERECgA2C 3 | -------------------------------------------------------------------------------- /db/migrate/001_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration 2 | def change 3 | create_table :users, force: true do |t| 4 | t.integer :uid 5 | t.text :lang 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/.message_responder.rb.swp.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvilInsultGenerator/telegram-bot-ruby/aaaed8c44c37f7cfc50e67f13ead1016002cf39b/lib/.message_responder.rb.swp.gz -------------------------------------------------------------------------------- /lib/.message_sender.rb.swp.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvilInsultGenerator/telegram-bot-ruby/aaaed8c44c37f7cfc50e67f13ead1016002cf39b/lib/.message_sender.rb.swp.gz -------------------------------------------------------------------------------- /lib/.reply_markup_formatter.rb.swp.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvilInsultGenerator/telegram-bot-ruby/aaaed8c44c37f7cfc50e67f13ead1016002cf39b/lib/.reply_markup_formatter.rb.swp.gz -------------------------------------------------------------------------------- /lib/app_configurator.rb: -------------------------------------------------------------------------------- 1 | require 'logger' 2 | 3 | require './lib/database_connector' 4 | 5 | class AppConfigurator 6 | def configure 7 | setup_i18n 8 | setup_database 9 | end 10 | 11 | def get_token 12 | YAML::load(IO.read('config/secrets.yml'))['telegram_bot_token'] 13 | end 14 | 15 | def get_botan_token 16 | YAML::load(IO.read('config/secrets.yml'))['botan_token'] 17 | end 18 | 19 | def get_logger 20 | Logger.new(STDOUT, Logger::DEBUG) 21 | end 22 | 23 | private 24 | 25 | def setup_i18n 26 | I18n.load_path = Dir['config/locales.yml'] 27 | I18n.locale = :en 28 | I18n.backend.load_translations 29 | end 30 | 31 | def setup_database 32 | DatabaseConnector.establish_connection 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/database_connector.rb: -------------------------------------------------------------------------------- 1 | require 'active_record' 2 | require 'logger' 3 | 4 | class DatabaseConnector 5 | class << self 6 | def establish_connection 7 | ActiveRecord::Base.logger = Logger.new(active_record_logger_path) 8 | 9 | configuration = YAML::load(IO.read(database_config_path)) 10 | 11 | ActiveRecord::Base.establish_connection(configuration) 12 | end 13 | 14 | private 15 | 16 | def active_record_logger_path 17 | 'debug.log' 18 | end 19 | 20 | def database_config_path 21 | 'config/database.yml' 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/message_responder.rb: -------------------------------------------------------------------------------- 1 | require './models/user' 2 | require './lib/message_sender' 3 | require 'httpclient' 4 | 5 | class MessageResponder 6 | attr_reader :message 7 | attr_reader :bot 8 | attr_reader :user 9 | attr_reader :mode 10 | 11 | def initialize(options) 12 | @bot = options[:bot] 13 | @message = options[:message] 14 | @user = User.find_or_create_by(uid: message.from.id) 15 | end 16 | 17 | def respond 18 | case message 19 | when Telegram::Bot::Types::InlineQuery 20 | # Here you can handle your inline commands 21 | execute_commands 22 | when Telegram::Bot::Types::CallbackQuery 23 | # Here you can handle your callbacks from inline buttons 24 | bot.track('switch_lang', message.from.id, choosen_lang: message.data) 25 | change_lang 26 | when Telegram::Bot::Types::Message 27 | execute_commands 28 | end 29 | end 30 | 31 | private 32 | 33 | def execute_commands 34 | if message.respond_to?(:text) 35 | content,@mode=[message.text,'inchat'] 36 | elsif message.respond_to?(:query) 37 | content,@mode=[message.query,'inline'] 38 | end 39 | case content 40 | when '/start' 41 | answer_with_greeting_message if mode=='inchat' 42 | when '/stop' 43 | answer_with_farewell_message if mode=='inchat' 44 | when /Generate insult/i 45 | bot.track('gen_insult', message.from.id, mode:@mode) 46 | generate_insult 47 | when /(language|lang)/i 48 | bot.track('Request_to_switch_lang', message.from.id, mode:@mode) 49 | show_language 50 | when /homepage/i 51 | show_homepage if mode=='inchat' 52 | else 53 | if @mode=='inline' 54 | bot.track('gen_insult', message.from.id, mode:@mode) 55 | generate_insult 56 | else 57 | MessageSender.new(bot: bot, 58 | chat: message.from, 59 | text: "Sorry, I do not understand \u2639").send 60 | end 61 | end 62 | end 63 | 64 | def answer_with_greeting_message 65 | text = I18n.t('greeting_message') 66 | answers=[ 67 | 'Generate Insult', 68 | ['Language','Homepage'] 69 | ] 70 | MessageSender.new(bot: bot, 71 | chat: message.from, 72 | answers:answers, 73 | text: "#{text} \u{1F479}").send 74 | 75 | end 76 | 77 | def answer_with_farewell_message 78 | text = I18n.t('farewell_message') 79 | 80 | MessageSender.new(bot: bot, chat: message.from, text: text).send 81 | end 82 | 83 | def lang 84 | @user.lang ||='en' 85 | end 86 | 87 | def change_lang 88 | @user.lang=message.data 89 | @user.save 90 | text = "Language changed to #{lang}" #I18n.t('farewell_message') 91 | MessageSender.new(bot: bot, chat: message.from, text: text).send 92 | end 93 | 94 | def generate_insult 95 | clnt = HTTPClient.new 96 | uri = URI.parse("http://evilinsult.com/generate_insult.php?lang=#{lang}") 97 | response = clnt.get_content(uri) 98 | text=response 99 | if @mode=='inchat' 100 | MessageSender.new(bot: bot, chat: message.from, text: text).send 101 | else 102 | answers= 103 | [ 104 | Telegram::Bot::Types::InlineQueryResultArticle.new( 105 | id: rand(100), 106 | title: 'Insult', 107 | input_message_content: 108 | Telegram::Bot::Types::InputTextMessageContent.new( 109 | message_text:text, 110 | disable_web_page_preview: true 111 | ), 112 | thumb_url:'http://a5.mzstatic.com/us/r30/Purple3/v4/94/77/85/947785f3-5056-a1c5-dbf2-d6688b215403/icon175x175.png', 113 | description: text 114 | ) 115 | ] 116 | MessageSender.new(bot: bot, 117 | query_id: message.id, 118 | answers:answers, 119 | inline_mode:true).send 120 | end 121 | rescue 122 | 123 | end 124 | 125 | def show_language 126 | text="Your current language is: #{lang}\nChoose the language:" 127 | languages=['en','zh','es','hi','ar','pt','bn','ru','ja','jv','sw','de','ko','fr','te','mr','tr','ta','vi','ur','el','it','cs','la'] 128 | languages.map!{|answer| 129 | Telegram::Bot::Types::InlineKeyboardButton.new( 130 | text:answer, 131 | callback_data: answer 132 | ) 133 | } 134 | if @mode=='inchat' 135 | MessageSender.new(bot: bot, 136 | chat: message.from, 137 | answers:languages, inline:true, 138 | text: text).send 139 | else 140 | answers= 141 | [ 142 | Telegram::Bot::Types::InlineQueryResultArticle.new( 143 | id: rand(100), 144 | title: 'Insult', 145 | input_message_content: 146 | Telegram::Bot::Types::InputTextMessageContent.new( 147 | message_text:text, 148 | disable_web_page_preview: true 149 | ), 150 | reply_markup: 151 | Telegram::Bot::Types::InlineKeyboardMarkup.new( 152 | inline_keyboard: languages.each_slice(4).to_a 153 | ), 154 | thumb_url:'https://cdn4.iconfinder.com/data/icons/logos-4/24/Translate-128.png', 155 | description: text 156 | ) 157 | ] 158 | MessageSender.new(bot: bot, 159 | query_id: message.id, 160 | answers:answers, 161 | inline_mode:true).send 162 | end 163 | end 164 | 165 | def show_homepage 166 | text="http://evilinsult.com/" 167 | MessageSender.new(bot: bot, chat: message.from,text: text).send 168 | end 169 | end 170 | -------------------------------------------------------------------------------- /lib/message_sender.rb: -------------------------------------------------------------------------------- 1 | require './lib/reply_markup_formatter' 2 | require './lib/app_configurator' 3 | 4 | class MessageSender 5 | attr_reader :bot 6 | attr_reader :text 7 | attr_reader :chat 8 | attr_reader :answers 9 | attr_reader :logger 10 | attr_reader :inline 11 | attr_reader :query_id 12 | attr_reader :inline_mode 13 | 14 | def initialize(options) 15 | @bot = options[:bot] 16 | @text = options[:text] 17 | @chat = options[:chat] 18 | @answers = options[:answers] 19 | @inline = options[:inline] 20 | @inline_mode = options[:inline_mode] 21 | @query_id = options[:query_id] 22 | @logger = AppConfigurator.new.get_logger 23 | end 24 | 25 | def send 26 | if reply_markup&&inline_mode 27 | bot.api.answer_inline_query(inline_query_id: query_id.to_s, results: answers,cache_time:0) 28 | elsif reply_markup 29 | bot.api.send_message(chat_id: chat.id, text: text, reply_markup: reply_markup) 30 | else 31 | bot.api.send_message(chat_id: chat.id, text: text) 32 | end 33 | 34 | # logger.debug "sending '#{text}' to #{chat.username}" 35 | end 36 | 37 | 38 | private 39 | def reply_markup 40 | if answers&&inline 41 | ReplyMarkupFormatter.new(answers).get_inline_markup 42 | elsif answers 43 | ReplyMarkupFormatter.new(answers).get_markup 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/reply_markup_formatter.rb: -------------------------------------------------------------------------------- 1 | class ReplyMarkupFormatter 2 | attr_reader :array 3 | 4 | def initialize(array) 5 | @array = array 6 | end 7 | 8 | def get_markup 9 | Telegram::Bot::Types::ReplyKeyboardMarkup 10 | .new(keyboard: array,resize_keyboard:true) 11 | #.each_slice(1).to_a, one_time_keyboard: true) 12 | end 13 | 14 | def get_inline_markup 15 | Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: array.each_slice(4).to_a) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /models/user.rb: -------------------------------------------------------------------------------- 1 | require 'active_record' 2 | 3 | class User < ActiveRecord::Base 4 | end 5 | -------------------------------------------------------------------------------- /ruby: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvilInsultGenerator/telegram-bot-ruby/aaaed8c44c37f7cfc50e67f13ead1016002cf39b/ruby -------------------------------------------------------------------------------- /runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while sleep 60 3 | do 4 | if pgrep -f bin/bot >/dev/null 5 | then 6 | echo "works" >/dev/null 2>&1 7 | else 8 | ruby /home/ubuntu/marvinlozano/bin/bot>>/home/ubuntu/marvinlozano/bot.log 2>&1 &! 9 | fi 10 | done 11 | 12 | --------------------------------------------------------------------------------