membership

This block will be executed when the chatbot has been added or removed from a group or channel from Telegram.

membership(event=Enum(:new, :drop), &block)

Platforms

PlatformSupported

Messenger

WhatsApp

Telegram

Usage

class MainContext < Conversation

  def blocks

    membership :new do |chat|
      @reply.text "You've added me to #{chat[:title]}"
      @reply_group.text "Hello, I'm glad to be part of this #{chat[:type]}"
    end

    membership :drop do |chat|
      @reply.text "You've removed me from #{chat[:title]}"
      logger.debug_json chat, :red
    end

  end
  
end

In this block @reply_group can be called, this is a notification instance for the group or channel. @reply as always responds to the user, in this case the admin of the group/channel who added or removed the chatbot.

Last updated