cl-telegram-bot icon indicating copy to clipboard operation
cl-telegram-bot copied to clipboard

Private chat limitation

Open vindarel opened this issue 3 years ago • 6 comments

Hello,

Currently make-chat ensures we create a private chat:

Only private chats are supported for now.

So we can't use the bot on a public group or on a private channel. As far as my tests went, we can only interact directly with it as 1to1 (which is cool).

Do you know what's required to bypass this limitation? (I didn't check the API docs yet)

thanks

vindarel avatar Oct 28 '21 14:10 vindarel

As I recall, make-chat creates a chat.

Did you try to add a bot into an existing group chat? I think this should work.

svetlyak40wt avatar Oct 28 '21 16:10 svetlyak40wt

yes I tried to add the bot into a public group and into a channel. I get the error.

(defun make-chat (data)
  (unless (string-equal (getf data :|type|)
                        "private")
    (error "Only private chats are supported for now."))  ;;; <------------------------- won't pass
  
  (make-instance 'private-chat
                 :id (getf data :|id|)
                 :username (getf data :|username|)
                 :first-name (getf data :|first_name|)
                 :last-name (getf data :|last_name|)
                 :raw-data data))

I didn't try by removing the error creation.

vindarel avatar Oct 28 '21 17:10 vindarel

I deleted it and tried, then:

An HTTP request to "https://api.telegram.org/bot2051825788:AAEQqIEqUtc49MMJDOg-EgK-KVziXq3ol6w/sendMessage" returned 403 forbidden.

{"ok":false,"error_code":403,"description":"Forbidden: bot was kicked from the group chat"}
   [Condition of type DEXADOR.ERROR:HTTP-REQUEST-FORBIDDEN]

and this or the error happen everytime I start the bot. I might need to properly remove it from the group and channel, but I think it is…

vindarel avatar Oct 28 '21 17:10 vindarel

oh cool, by accepting and continuing I found the continue-processing restart to continue accepting Telegram updates, now it works again (in private 1-1 conversation). +1

vindarel avatar Oct 28 '21 17:10 vindarel

I deleted the error, now I can add the bot into a new group. It… works.

Commands work. A detail though. When the bot prints the start message, if we click on a command, then the command is complemented with an explicit mention of the bot, like so:

/cmd@my_bot

so to catch this we have to dispatch on the on-message method (thank you to the default help text).

Testing more.

vindarel avatar Oct 28 '21 18:10 vindarel

Good. Feel free to create a pull-request to add groups support.

svetlyak40wt avatar Oct 28 '21 19:10 svetlyak40wt