Skip to content

Commit

Permalink
Merge pull request #59 from bman46/AddDelayOption
Browse files Browse the repository at this point in the history
Add option for delay between account syncs
  • Loading branch information
bman46 authored Nov 29, 2022
2 parents 493f5c5 + 8e8f279 commit 8ff0a04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Instagram Reels Bot/Services/Subscriptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,14 @@ public async Task GetLatestsPosts()
}
//Update database:
await this.FollowedAccountsContainer.ReplaceOneAsync(x => x.InstagramID == dbfeed.InstagramID, dbfeed, new ReplaceOptions { IsUpsert = true });
// Wait to prevent spamming IG api:
// 10 seconds
await Task.Delay(10000);

// Wait to prevent spamming IG api
// Get value from config:
int time;
_ = int.TryParse(_config["SubscribeCheckDelayTime"], out time);
// Enforce a minimum of 10 seconds.
time = Math.Max(time, 10);
await Task.Delay(time * 1000);
}
}
catch(Exception e)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Create a new file named `config.json`, copy and paste the contents below into it
"AllowSubscriptions": true/false,
"MongoDBUrl": "MongoDB Connection String (Required for subscriptions)",
"DefaultSubscriptionsPerGuildMax": 1,
"HoursToCheckForNewContent": 3
"HoursToCheckForNewContent": 3,
"SubscribeCheckDelayTime": 10
}
```

0 comments on commit 8ff0a04

Please sign in to comment.