Skip to content

Commit 755183d

Browse files
committed
Now easy_bot_check_command() returns cmd's end.
1 parent 8fe2c72 commit 755183d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

bot_easy_api.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ int easy_perform_sendEscapedLongMessage(CURL *curl, TgInteger chatId,
386386
}
387387

388388
bool easy_bot_check_command(const char *cmd, size_t sz, const char *name,
389-
size_t name_sz, size_t *off, bool *shortcmd = 0)
389+
size_t name_sz, size_t *cmd_end_off, bool *shortcmd = 0)
390390
{
391391
if (cmd[0] != '/') {
392392
return false;
393393
}
394394
const char *tok = strpbrk(cmd + 1, "@ ");
395395
if (!tok) {
396-
if (off) {
397-
*off = sz;
396+
if (cmd_end_off) {
397+
*cmd_end_off = sz;
398398
}
399399
if (shortcmd) {
400400
*shortcmd = true;
@@ -404,8 +404,8 @@ bool easy_bot_check_command(const char *cmd, size_t sz, const char *name,
404404
switch (*tok) {
405405
case '@':
406406
if (strncmp(tok + 1, name, name_sz) == 0) {
407-
if (off) {
408-
*off = tok - cmd + name_sz + 1;
407+
if (cmd_end_off) {
408+
*cmd_end_off = tok - cmd;
409409
}
410410
if (shortcmd) {
411411
*shortcmd = false;
@@ -414,8 +414,8 @@ bool easy_bot_check_command(const char *cmd, size_t sz, const char *name,
414414
}
415415
return false;
416416
case ' ':
417-
if (off) {
418-
*off = tok - cmd;
417+
if (cmd_end_off) {
418+
*cmd_end_off = tok - cmd;
419419
}
420420
if (shortcmd) {
421421
*shortcmd = true;

bot_easy_api.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ int easy_perform_sendLocation(CURL *c, TgInteger chat_id,
3131
TgInteger reply_id = 0, writefn_data *d = 0);
3232
int easy_perform_leaveChat(CURL *c, TgInteger chatId);
3333
bool easy_bot_check_command(const char *cmd, size_t sz, const char *name,
34-
size_t name_sz, size_t *off, bool *shortcmd = 0);
34+
size_t name_sz, size_t *cmd_end_off, bool *shortcmd = 0);
3535
#endif

0 commit comments

Comments
 (0)