Skip to content

Commit 8ff0a04

Browse files
authored
Merge pull request #59 from bman46/AddDelayOption
Add option for delay between account syncs
2 parents 493f5c5 + 8e8f279 commit 8ff0a04

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Instagram Reels Bot/Services/Subscriptions.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,14 @@ public async Task GetLatestsPosts()
431431
}
432432
//Update database:
433433
await this.FollowedAccountsContainer.ReplaceOneAsync(x => x.InstagramID == dbfeed.InstagramID, dbfeed, new ReplaceOptions { IsUpsert = true });
434-
// Wait to prevent spamming IG api:
435-
// 10 seconds
436-
await Task.Delay(10000);
434+
435+
// Wait to prevent spamming IG api
436+
// Get value from config:
437+
int time;
438+
_ = int.TryParse(_config["SubscribeCheckDelayTime"], out time);
439+
// Enforce a minimum of 10 seconds.
440+
time = Math.Max(time, 10);
441+
await Task.Delay(time * 1000);
437442
}
438443
}
439444
catch(Exception e)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Create a new file named `config.json`, copy and paste the contents below into it
5252
"AllowSubscriptions": true/false,
5353
"MongoDBUrl": "MongoDB Connection String (Required for subscriptions)",
5454
"DefaultSubscriptionsPerGuildMax": 1,
55-
"HoursToCheckForNewContent": 3
55+
"HoursToCheckForNewContent": 3,
56+
"SubscribeCheckDelayTime": 10
5657
}
5758
```

0 commit comments

Comments
 (0)