add debugging constants

This commit is contained in:
Khinshan Khan
2025-03-08 21:16:37 -05:00
parent 92cee0052c
commit 7d7a6442d8
+9 -7
View File
@@ -33,13 +33,15 @@ var (
const ( const (
// TODO: update value after debugging // TODO: update value after debugging
sendMessageIntervalMin = 10 SendMessageIntervalMin = 5
// TODO: update value after debugging // TODO: update value after debugging
sendMessageIntervalMax = 20 SendMessageIntervalMax = 10
// TODO: update value after debugging // TODO: update value after debugging
sendMessageUnit = time.Second SendMessageUnit = time.Second
// TODO: update value after debugging // TODO: update value after debugging
deleteConspiracyDelay = 5 * time.Second DeleteConspiracyDelay = 3 * time.Second
// TODO: update value after debugging
ConspiracyProbability = 0.4
) )
func main() { func main() {
@@ -117,7 +119,7 @@ func readyHandler(s *discordgo.Session, r *discordgo.Ready) {
// startScheduler handles sending messages at intervals // startScheduler handles sending messages at intervals
func startScheduler(s *discordgo.Session, channelID string) { func startScheduler(s *discordgo.Session, channelID string) {
for { for {
randomDuration := time.Duration(rand.Intn(sendMessageIntervalMin)+(sendMessageIntervalMax-sendMessageIntervalMin)) * sendMessageUnit randomDuration := time.Duration(rand.Intn(SendMessageIntervalMin)+(SendMessageIntervalMax-SendMessageIntervalMin)) * SendMessageUnit
log.Printf("[!] Next message in %v", randomDuration) log.Printf("[!] Next message in %v", randomDuration)
// Wait for the randomized time before sending a message // Wait for the randomized time before sending a message
@@ -126,14 +128,14 @@ func startScheduler(s *discordgo.Session, channelID string) {
praiseIndex++ praiseIndex++
// Chance to send a conspiracy theory // Chance to send a conspiracy theory
if rand.Float32() < 0.4 { if rand.Float32() < ConspiracyProbability {
discordMessage := sendMessage(conspiracies[conspiracyIndex%len(conspiracies)], s, channelID) discordMessage := sendMessage(conspiracies[conspiracyIndex%len(conspiracies)], s, channelID)
conspiracyIndex++ conspiracyIndex++
// Delete conspiracy after 5 minutes // Delete conspiracy after 5 minutes
if discordMessage != nil { if discordMessage != nil {
go func(msgID string) { go func(msgID string) {
time.Sleep(deleteConspiracyDelay) time.Sleep(DeleteConspiracyDelay)
err := s.ChannelMessageDelete(channelID, msgID) err := s.ChannelMessageDelete(channelID, msgID)
if err != nil { if err != nil {
log.Printf("[!] Error deleting conspiracy: %v\n", err) log.Printf("[!] Error deleting conspiracy: %v\n", err)