Return the bot username. */
| 400 | |
| 401 | /* Return the bot username. */ |
| 402 | char *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). |
no test coverage detected