MCPcopy Index your code
hub / github.com/antirez/botlib / readApiKeyFromFile

Function readApiKeyFromFile

botlib.c:862–875  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

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. */
862void 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
877void resetBotStats(void) {
878 botStats.start_time = time(NULL);

Callers 1

startBotFunction · 0.85

Calls 3

sdsfreeFunction · 0.85
sdsnewFunction · 0.85
sdstrimFunction · 0.85

Tested by

no test coverage detected