Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Channel_post #37

Closed
littleyoda opened this issue Feb 11, 2017 · 8 comments
Closed

Support for Channel_post #37

littleyoda opened this issue Feb 11, 2017 · 8 comments
Labels
Milestone

Comments

@littleyoda
Copy link

littleyoda commented Feb 11, 2017

Support for Channel_post would be great.

see https://core.telegram.org/bots/api-changelog#november-21-2016

An Example of the result-String:

{
   "ok":true,
   "result":[
      {
         "update_id":895636948,
         "channel_post":{
            "message_id":161,
            "chat":{
               "id":-10012345678,
               "title":"Title Example",
               "type":"channel"
            },
            "date":1486841742,
            "text":"Example Text"
         }
      }
   ]
}
@littleyoda
Copy link
Author

littleyoda commented Feb 11, 2017

And a second example ("/bottest test test")

{
   "ok":true,
   "result":[
      {
         "update_id":895636959,
         "channel_post":{
            "message_id":275,
            "chat":{
               "id":-10012345654,
               "title":"title test",
               "type":"channel"
            },
            "date":1486843652,
            "text":"/bottest test test",
            "entities":[
               {
                  "type":"bot_command",
                  "offset":0,
                  "length":8
               }
            ]
         }
      }
   ]
}

@mblwb
Copy link

mblwb commented Feb 12, 2017

just use @channel_name as chat_id.

@littleyoda
Copy link
Author

This works only for sending emails to channel that are public.

But in this case you still don't get any messages back, because getUpdates searches for messages only in the section results/messages and not in the section results/channel_post.

@witnessmenow
Copy link
Owner

Hey @littleyoda thanks for raising the issue.

Adding the example response here is very helpful so thanks for that too!

Yeah this is something we could handle for sure, at the moment bot only cares about messages but this needs to be extended handle other types from getUpdates such as this one.

I've never seen the entities object before, I'll have to take a bigger look into it

If created a new branch over the next few days supporting this could download it and try it out?

@littleyoda
Copy link
Author

littleyoda commented Feb 12, 2017

If you want to reproduce this kind of messages:

  • Create a channel
  • Add the Bot to this channel
  • Make the Bot Administrator of this channel
  • Change the privacy modus of this bot to disable via /setprivacy
  • Send a Message

Of course, I will be happy to test every new source code.

@witnessmenow
Copy link
Owner

witnessmenow commented Feb 12, 2017

I did some work towards this there. It requires a good bit of code clean up but is working for me

It's on this branch

I added a "type" that you can check to see is it a channel post so you can handle it differently if required. I also added "chat_title" if that is useful.

Example usage below

      if(bot.messages[i].type == "channel_post"){

      bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].chat_title + " " + bot.messages[i].text, "");

    } else {

      bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, ""); 

    }

@littleyoda
Copy link
Author

Just tested and it works fine.

Perfect. Thanks

@witnessmenow
Copy link
Owner

Available in the V1.1.0 RC branch

https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/tree/V1.1.0

@witnessmenow witnessmenow mentioned this issue Oct 17, 2017
@witnessmenow witnessmenow added this to the V1.1.0 milestone Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants