Module: TelegramBotEngine::SubscriberCommands
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/telegram_bot_engine/subscriber_commands.rb
Instance Method Summary collapse
-
#help! ⇒ Object
/help - list all available commands.
-
#start! ⇒ Object
/start - create subscription if authorized.
-
#stop! ⇒ Object
/stop - deactivate subscription.
Instance Method Details
#help! ⇒ Object
/help - list all available commands
40 41 42 |
# File 'lib/telegram_bot_engine/subscriber_commands.rb', line 40 def help!(*) respond_with :message, text: "📋 *Available Commands*\n\n#{available_commands_text}", parse_mode: "Markdown" end |
#start! ⇒ Object
/start - create subscription if authorized
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/telegram_bot_engine/subscriber_commands.rb', line 13 def start!(*) subscription = TelegramBotEngine::Subscription.find_or_initialize_by( chat_id: chat["id"] ) subscription.assign_attributes( user_id: from["id"], username: from["username"], first_name: from["first_name"], active: true ) subscription.save! welcome = TelegramBotEngine.config. % { username: from["first_name"] || from["username"], commands: available_commands_text } respond_with :message, text: welcome end |
#stop! ⇒ Object
/stop - deactivate subscription
33 34 35 36 37 |
# File 'lib/telegram_bot_engine/subscriber_commands.rb', line 33 def stop!(*) subscription = TelegramBotEngine::Subscription.find_by(chat_id: chat["id"]) subscription&.update(active: false) respond_with :message, text: "You've been unsubscribed. Send /start to resubscribe." end |