Added check for limit
This commit is contained in:
parent
c3d7a33be3
commit
756e71cf5a
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project (mastobotmon
|
||||
VERSION 0.2.1
|
||||
VERSION 0.2.2
|
||||
LANGUAGES CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
|
|
@ -45,6 +45,7 @@ Same as [mastodon-cpp](https://github.com/tastytea/mastodon-cpp/blob/master/READ
|
|||
| Code | Explanation |
|
||||
| --------: |:------------------------------|
|
||||
| 1 | Couldn't read / create config |
|
||||
| 2 | Reached limit of API calls |
|
||||
|
||||
If you use a debug build, you get more verbose error messages.
|
||||
|
||||
|
@ -84,7 +85,7 @@ Mentions are written to `data_dir/mentions_account.csv`. The format is: acct;cre
|
|||
* [x] Allow to add accounts later
|
||||
* [x] Write mentions to file
|
||||
* Version 0.3.0
|
||||
* [ ] Respect X-RateLimit header
|
||||
* [x] Respect X-RateLimit header
|
||||
* [ ] Write statistics to file
|
||||
* Version 0.4.0
|
||||
* [ ] Daemon mode
|
||||
|
|
|
@ -104,6 +104,12 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
std::string answer;
|
||||
uint16_t ret = acc.get(Mastodon::API::v1::accounts_verify_credentials, answer);
|
||||
if (std::stoi(acc.get_header("X-RateLimit-Remaining")) < 2)
|
||||
{
|
||||
cerr << "ERROR: Reached limit of API calls.\n";
|
||||
cerr << "Counter will reset at " << acc.get_header("X-RateLimit-Reset") << '\n';
|
||||
return 2;
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
Json::Value json;
|
||||
|
|
Loading…
Reference in New Issue