Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
6c4c76bd
Commit
6c4c76bd
authored
Jun 25, 2015
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed autocomplete for bots
parent
c4ffd8c3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
interface.c
interface.c
+22
-8
tgl
tgl
+1
-1
No files found.
interface.c
View file @
6c4c76bd
...
...
@@ -1707,11 +1707,15 @@ int complete_user_command (tgl_peer_t *P, int index, const char *text, int len,
text
++
;
len
--
;
struct
tgl_user
*
U
=
(
void
*
)
P
;
index
++
;
if
(
!
U
->
bot_info
)
{
*
R
=
NULL
;
return
-
1
;
}
if
(
index
>=
U
->
bot_info
->
commands_num
)
{
return
U
->
bot_info
->
commands_num
+
complete_message_answer
(
P
,
index
-
U
->
bot_info
->
commands_num
,
text
-
1
,
len
+
1
,
R
);
}
index
++
;
while
(
index
<
U
->
bot_info
->
commands_num
&&
strncmp
(
U
->
bot_info
->
commands
[
index
].
command
,
text
,
len
))
{
index
++
;
}
...
...
@@ -1721,8 +1725,7 @@ int complete_user_command (tgl_peer_t *P, int index, const char *text, int len,
assert
(
*
R
);
return
index
;
}
else
{
*
R
=
NULL
;
return
-
1
;
return
U
->
bot_info
->
commands_num
+
complete_message_answer
(
P
,
index
-
U
->
bot_info
->
commands_num
,
text
-
1
,
len
+
1
,
R
);
}
}
...
...
@@ -1741,19 +1744,31 @@ int complete_chat_command (tgl_peer_t *P, int index, const char *text, int len,
struct
tgl_user
*
U
=
(
void
*
)
tgl_peer_get
(
TLS
,
TGL_MK_USER
(
P
->
chat
.
user_list
[
i
].
user_id
));
if
(
!
U
)
{
continue
;
}
if
(
!
U
->
bot_info
)
{
continue
;
}
while
(
index
-
tot
<
U
->
bot_info
->
commands_num
&&
strncmp
(
U
->
bot_info
->
commands
[
index
-
tot
].
command
,
text
,
len
))
{
int
p
=
len
-
1
;
while
(
p
>=
0
&&
text
[
p
]
!=
'@'
)
{
p
--
;
}
if
(
p
<
0
)
{
p
=
len
;
}
while
(
index
-
tot
<
U
->
bot_info
->
commands_num
&&
strncmp
(
U
->
bot_info
->
commands
[
index
-
tot
].
command
,
text
,
p
))
{
index
++
;
}
if
(
index
-
tot
<
U
->
bot_info
->
commands_num
)
{
*
R
=
NULL
;
if
(
U
->
username
)
{
assert
(
asprintf
(
R
,
"/%s@%s"
,
U
->
bot_info
->
commands
[
index
].
command
,
U
->
username
)
>=
0
);
}
else
{
assert
(
asprintf
(
R
,
"/%s"
,
U
->
bot_info
->
commands
[
index
].
command
)
>=
0
);
}
assert
(
*
R
);
return
index
;
}
tot
+=
U
->
bot_info
->
commands_num
;
}
*
R
=
NULL
;
return
-
1
;
if
(
index
==
tot
)
{
return
tot
+
complete_message_answer
(
P
,
index
-
tot
,
text
-
1
,
len
+
1
,
R
);
}
else
{
return
tot
+
complete_message_answer
(
P
,
index
-
tot
-
1
,
text
-
1
,
len
+
1
,
R
);
}
}
char
*
command_generator
(
const
char
*
text
,
int
state
)
{
...
...
@@ -2238,7 +2253,6 @@ void print_user_info_gw (struct tgl_state *TLSR, void *extra, int success, struc
mprintf
(
ev
,
" @%s"
,
U
->
username
);
}
mprintf
(
ev
,
" (#%d):
\n
"
,
tgl_get_peer_id
(
U
->
id
));
mprintf
(
ev
,
"
\t
real name: %s %s
\n
"
,
U
->
real_first_name
,
U
->
real_last_name
);
mprintf
(
ev
,
"
\t
phone: %s
\n
"
,
U
->
phone
);
mprintf
(
ev
,
"
\t
"
);
print_user_status
(
&
U
->
status
,
ev
);
...
...
tgl
@
544c110e
Subproject commit
36f84242e97640fa92d05ca3be4381a08a86e076
Subproject commit
544c110eaf9c5a5e98e467694ba1c74303c54c52
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment