filipre / signalbot

Micro framework to create your own signal bots.
MIT License
111 stars 23 forks source link

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

Open nemoforum opened 7 months ago

nemoforum commented 7 months ago

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

Kariton commented 6 months ago

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.