Comments (2)
Example code which could be put into a loop to run every 5 minutes ( or any interval ) similar to the ScamGuard.PeriodicBackup
from datetime import datetime, timedelta
.....
unactivatedServers = self.Database.GetAllDeactivatedServers()
for server in unactivatedServers:
currentTime = datetime.utcnow()
rangeStart = server.created_at + timedelta(days=1, minutes=4)
rangeEnd = server.created_at + timedelta(days=1, minutes=9, seconds=1)
if ((currentTime > rangeStart) & (currentTime < rangeEnd)):
# run discord message function
With this code, the "notification" would be sent out 1 day after the server entry has been made into the database.
The chosen timedelta is an offset 5 minute interval with an additional 1 second as a safety check. This is for it not occur at the same time frequency as the actual task loop in order to ensure no check will occur outside of the range on accident due to slow execution nor inside of it twice, as the likelyhood of the interval matching the extra 1 second grace interval should be small.
Additional messages can be sent by duplicating the code inside the for loop (to reduce iterations) and changing the timedelta interval day period (or any period)
Note: This code is using the created_at timestamp from my code in #45, and not the updated_at timestamp to ensure the notifications are only sent out on the initial entry of the database, and not due to subsequent changes which have occurred to the server for any of the variety of reasons the entry would be updated.
Another longer term alternative which may allow for more configurability would be to create a notifications
table and record attempted communications there.
from antiscambot.
Closing this issue, we're going to add slash commands instead, as this will be easier to use than having the bot directly message an user.
from antiscambot.
Related Issues (20)
- Combine PrepareBan/Unban into a shared function
- Add thread link information to ban data HOT 5
- Change the ban reasons
- Submit bot verification documentation HOT 1
- Update scamcheck with new permissions
- Setup dependency updates/freezing HOT 1
- Docs: SEO tags are not getting properly liquified
- Update documentation on commands HOT 4
- Sub-instance activation permissions issue HOT 1
- Allow for assignment of a channel that the bot can post into for discord servers HOT 1
- Allow activation from a server HOT 2
- Remote reports need to reupload the image to discord
- Bot code restructuring suggestion HOT 3
- Add a settings command
- Post a message on join HOT 3
- Allow for turning off remote reports for a server HOT 1
- Allow bot to send notification messages
- Setup Modal should check to see if the bot has ban permissions
- New Server Schema
- Create a cloudflare worker for handling Web Reports
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antiscambot.