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

Function botGetUsername

botlib.c:402–415  ·  view source on GitHub ↗

Return the bot username. */

Source from the content-addressed store, hash-verified

400
401/* Return the bot username. */
402char *botGetUsername(void) {
403 int res;
404
405 if (Bot.username) return Bot.username;
406 sds body = makeGETBotRequest("getMe",&res,NULL,0);
407 if (res == 0) return NULL;
408
409 cJSON *json = cJSON_Parse(body), *username;
410 username = cJSON_Select(json,".result.username:s");
411 if (username) Bot.username = sdsnew(username->valuestring);
412 sdsfree(body);
413 cJSON_Delete(json);
414 return Bot.username;
415}
416
417/* Send a message to the specified channel, optionally as a reply to a
418 * specific message (if reply_to is non zero).

Callers 1

botMainFunction · 0.85

Calls 6

makeGETBotRequestFunction · 0.85
cJSON_ParseFunction · 0.85
cJSON_SelectFunction · 0.85
sdsnewFunction · 0.85
sdsfreeFunction · 0.85
cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected