![]() ![]() ![]() See the contributing and development guide for details on working on this project. It's unlikely I'll change things much (because time, work, etc), but I'm interested in hearing your thoughts. This architecture isn't perfect, and I'm open to criticism and suggestions. This re-publishes failed tasks (stored in Redis) and attempts to set reminders for them. These are utility functions used only once: when verifying the webhook for Twitter (during setup). Settings are stored in redis, with the user's Twitter handle forming part of the key. HTTP handler that the form submits to when you update your settings on the website (set a timezone or enable/disable push notifications). This function fetches your profile info from the Twitter API and creates a session for you on the website. The URL Twitter redirects you to after you complete the sign in process. It retrieves the necessary tokens and passes on to Twitter API to start the sign in process. When you click "Sign in With Twitter" on the website, you're redirected to the URL of this function. Maybe I wasn't sure if I could make path parameters optional. Why are getHomePage and getPage separate, you ask? I honestly do not remember. In a chat or channel simply mention the bot to set a reminder for everyone to see: Remind 'Server maintenance' on Mar 31 at 8pm Remind myself 'check this again' on Monday at 9am Time zones are also supported, e.g. Then it iterates over them and dispatches any tweets or push notifications. Assuming the time is, 11:23, it will check for a Redis key, which should hold all the reminders for that time. This function runs once every minute (this means reminders can only have minute precision) and checks for any reminders scheduled for the current time. This stops other users from setting up reminders because it is waiting for the previous time.sleep() to end. My issue is that I am using time.sleep() to handle the delay. Its helping millions of people write content, solve coding problems, and create games. I have a discord bot I am working on for practice that reminds the users with a dm after a certain amount of time. SO when a user replies cancel to a Tweet, we look up the ID of the tweet they're replying to, fetch their original reminder Tweet from there, and then delete th reminder from that Tweet from the datetime-key containing it in Redis. Find a ChatGPT alternative for your next AI chatbot adventure. If it finds any requests, it sets a reminder by storing the relevant data (tweet, author, etc) in Redis, with the Redis key being the timestamp (ISO8601-can't remmber why I went with that instead of the UNIX timestamp, but possibly human-readability).Ĭancellations (reply "cancel" to the bot's reply) work by storing a Redis entry with the reminder request tweet ID as value and the ID of the bot's response as key. This function iterates through all the mentions and looks for any possible reminder requests (or reminder cancellations). Whenever anyone mentions the bot (or likes or retweets a tweet by the bot), Twitter hits this URL with a payload containing details of the events. This function serves as the webhook registered to Twitter's Accout Activity API. The bot uses a number of AWS Lambda functions that work in tandem: handleAccountActivity Chrono for parsing dates/times from text.Firebase Messaging for push notifications. ![]() AWS Lambda with the Serverless Framework.Better yet, sign in on and set your timezone. Note that the bot will assume all absolute times are in UTC, so if you want to specify an absolute time, you need to specify a timezone if you're not in UTC/GMT. Of course, that's not all you can do! You can set reminders for your own tweets (New Year's Resolutions, anyone? □), too, for instance. But you likely won't remember by that time. I am just confused at why this thing isn't working at all and I am out of options.In three years, humans will have established a colony on Uranus.Īnd of course, naturally, you want to check back in three years to see if he was right. There where no error messages either, which meant syntax was "ok" yet after inspecting the code and nearly being driven crazy by it, I have officially given up at seeing what is causing the issue here.īefore anyone asks if I had missed the "pip install aiocron" thing, no that is not it, I did that right before using it. When runnin, the discord bot would run as normal with commands working perfect, but it just would not send the reminder messages. I ended up creating the below code: import * * * *') #Testing to see if it will alert me every minute Now, after much deliberation, I found aiocron, which is basically Linux's crontab feature realised in Python. Typing remind me or set reminder in the search bar is supposed to bring up the reminder screen. I am currently working on a Discord bot that reminds me and a couple of others using the command that a certain event will occur at a certain time 5 minutes before the event takes place ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |