Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
814 stars 343 forks source link

How can I send message to users without user interaction? #134

Closed mhonarvar18 closed 6 years ago

mhonarvar18 commented 6 years ago

hi everybody. I wanna send a message automatically to users and group chats without user interaction can you help me?

eMaurits commented 6 years ago

The bot has to be in the group in order to be able to send a message. You will also need the chatid of the group. After that you can just send a message to the specific chatid.

I suggest you make a start function which saves the chatid in a database. after that you can do whatever you want.

mhonarvar18 commented 6 years ago

@eMaurits thanks for your attention. but the point is here. how can I send message to user of bot, every day?? is telegram run my bot's code every day by himself??!

eMaurits commented 6 years ago

Ah, you didnt specify that in your first question.. Telegram does not run your code for you. It will send a notification to a url everytime someone sends a message in a chat where your bot is. If you want to send a message each day you will have to create something like a cron job where it runs your code on your server each day.

mhonarvar18 commented 6 years ago

@eMaurits Cron is a very good suggest. Thank you so much. :))