Check if a file named 'apikey.txt' exists, if so load the Telegram bot * API key from there. If the function is able to read the API key from * the file, as a side effect the global SDS string Bot.apikey is populated. */
| 860 | * API key from there. If the function is able to read the API key from |
| 861 | * the file, as a side effect the global SDS string Bot.apikey is populated. */ |
| 862 | void readApiKeyFromFile(void) { |
| 863 | FILE *fp = fopen("apikey.txt","r"); |
| 864 | if (fp == NULL) return; |
| 865 | char buf[1024]; |
| 866 | if (fgets(buf,sizeof(buf),fp) == NULL) { |
| 867 | fclose(fp); |
| 868 | return; |
| 869 | } |
| 870 | buf[sizeof(buf)-1] = '\0'; |
| 871 | fclose(fp); |
| 872 | sdsfree(Bot.apikey); |
| 873 | Bot.apikey = sdsnew(buf); |
| 874 | Bot.apikey = sdstrim(Bot.apikey," \t\r\n"); |
| 875 | } |
| 876 | |
| 877 | void resetBotStats(void) { |
| 878 | botStats.start_time = time(NULL); |