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

Send message at time, react on own message examples #46

Open
nemoforum opened this issue Mar 8, 2024 · 1 comment
Open

Send message at time, react on own message examples #46

nemoforum opened this issue Mar 8, 2024 · 1 comment

Comments

@nemoforum
Copy link

Hello!
Thank you for the great framework.
Could you please add an examples:

  • how to send a message at time
  • how to react on own message
    Thank you!
@Kariton
Copy link
Contributor

Kariton commented Apr 25, 2024

how to send a message at time

import datetime
from apscheduler.triggers.date import DateTrigger
from signalbot import Command

class ScheduledMessage(Command):
    def __init__(self):
      trigger = DateTrigger(run_date=datetime.datetime.strptime("01.01.2025 00:00:01", "%d.%m.%Y %H:%M:%S"))
      message = "Happy new year!"
      recipient = "+123456789"

      self.bot.scheduler.add_job(self.bot.send(recipient, message), trigger=trigger)

this is a short untested snipped based of some code from my scheduling function.
but this is way more complicated to simply provide the whole file and its a big mess. :D

hope this gives you some better idea.
maybe i find the time to update my code and add a example to this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants