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
d52183f8
Commit
d52183f8
authored
Sep 02, 2014
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Supported user#id... and chat#id... from lua
parent
7ce6dbbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
lua-tg.c
lua-tg.c
+10
-2
structures.c
structures.c
+17
-0
tgl.h
tgl.h
+2
-0
No files found.
lua-tg.c
View file @
d52183f8
...
...
@@ -1141,8 +1141,16 @@ static int parse_lua_function (lua_State *L, struct lua_function *F) {
ok
=
0
;
break
;
}
P
=
get_peer
(
s
);
if
(
!
P
||
!
(
P
->
flags
&
FLAG_CREATED
))
{
if
(
sscanf
(
s
,
"user#id%lld"
,
&
num
)
==
1
&&
num
>
0
)
{
tgl_insert_empty_user
(
num
);
P
=
tgl_peer_get
(
TGL_MK_USER
(
num
));
}
else
if
(
sscanf
(
s
,
"chat#id%lld"
,
&
num
)
==
1
&&
num
>
0
)
{
tgl_insert_empty_chat
(
num
);
P
=
tgl_peer_get
(
TGL_MK_CHAT
(
num
));
}
else
{
P
=
get_peer
(
s
);
}
if
(
!
P
/* || !(P->flags & FLAG_CREATED)*/
)
{
ok
=
0
;
break
;
}
...
...
structures.c
View file @
d52183f8
...
...
@@ -88,6 +88,7 @@ char *tgls_default_create_print_name (tgl_peer_id_t id, const char *a1, const ch
char
*
s
=
buf
;
while
(
*
s
)
{
if
(
*
s
==
' '
)
{
*
s
=
'_'
;
}
if
(
*
s
==
'#'
)
{
*
s
=
'@'
;
}
s
++
;
}
s
=
buf
;
...
...
@@ -1421,6 +1422,22 @@ void tglp_insert_chat (tgl_peer_t *P) {
Peers
[
peer_num
++
]
=
P
;
}
void
tgl_insert_empty_user
(
int
uid
)
{
tgl_peer_id_t
id
=
TGL_MK_USER
(
uid
);
if
(
tgl_peer_get
(
id
))
{
return
;
}
tgl_peer_t
*
P
=
talloc0
(
sizeof
(
*
P
));
P
->
id
=
id
;
tglp_insert_user
(
P
);
}
void
tgl_insert_empty_chat
(
int
cid
)
{
tgl_peer_id_t
id
=
TGL_MK_CHAT
(
cid
);
if
(
tgl_peer_get
(
id
))
{
return
;
}
tgl_peer_t
*
P
=
talloc0
(
sizeof
(
*
P
));
P
->
id
=
id
;
tglp_insert_chat
(
P
);
}
/* {{{ Free */
void
tgls_free_user
(
struct
tgl_user
*
U
)
{
if
(
U
->
first_name
)
{
tfree_str
(
U
->
first_name
);
}
...
...
tgl.h
View file @
d52183f8
...
...
@@ -307,5 +307,7 @@ void tgl_dc_iterator_ex (void (*iterator)(struct tgl_dc *DC, void *extra), void
double
tglt_get_double_time
(
void
);
void
tgl_insert_empty_user
(
int
id
);
void
tgl_insert_empty_chat
(
int
id
);
#endif
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