ebeneditos / telegram.bot

Develop a Telegram Bot with R
https://ebeneditos.github.io/telegram.bot/
GNU General Public License v3.0
107 stars 24 forks source link

Let chatbot send messages at specific timepoints #15

Closed sakritz closed 3 years ago

sakritz commented 4 years ago

Hi,

I am trying to get my chatbot to send messages at specific timepoints (right now, I'd be happy to sent these timepoint while programming, e.g., make the chatbot send "It's a new hour!" at each full hour; eventually, I'd need randomly chosen timepoints).

Is there a way to do this? If so, could you give me a minimal example?

Thanks! Sarah

krose commented 4 years ago

Hi

I send messages to a group like below. You can use a cron job to run this script:

library(telegram.bot)

telegram_pat <- "<your-token>"
chat_id <- "<telegram-chat-id>"

bot <- Bot(token = telegram_pat)

  bot$sendMessage(
    chat_id = chat_id,
    text = "Your message",
    parse_mode = "Markdown"
  )
GreyMerchant commented 4 years ago

Hello :) I saw this post and wanted to ask a related question. Telegram added a feature a while ago to do a delayed message. Is there some way to send all of them and get them handled appropriately with the intended delay?

ebeneditos commented 3 years ago

Closing as initial issue was solved, @GreyMerchant please feel free to open a new one with your suggestion.