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
4882b0ad
Commit
4882b0ad
authored
Oct 12, 2014
by
Grishka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an option to use IDs instead of names
Useful for bots
parent
d564c653
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
interface.c
interface.c
+5
-4
main.c
main.c
+6
-1
No files found.
interface.c
View file @
4882b0ad
...
...
@@ -103,6 +103,7 @@ struct in_ev *notify_ev;
extern
int
usfd
;
extern
int
sfd
;
extern
int
use_ids
;
int
is_same_word
(
const
char
*
s
,
size_t
l
,
const
char
*
word
)
{
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
...
...
@@ -2335,7 +2336,7 @@ int unknown_user_list[1000];
void
print_user_name
(
struct
in_ev
*
ev
,
tgl_peer_id_t
id
,
tgl_peer_t
*
U
)
{
assert
(
tgl_get_peer_type
(
id
)
==
TGL_PEER_USER
);
mpush_color
(
ev
,
COLOR_RED
);
if
(
!
U
)
{
if
(
!
U
||
use_ids
)
{
mprintf
(
ev
,
"user#%d"
,
tgl_get_peer_id
(
id
));
int
i
;
int
ok
=
1
;
...
...
@@ -2374,7 +2375,7 @@ void print_user_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *U) {
void
print_chat_name
(
struct
in_ev
*
ev
,
tgl_peer_id_t
id
,
tgl_peer_t
*
C
)
{
assert
(
tgl_get_peer_type
(
id
)
==
TGL_PEER_CHAT
);
mpush_color
(
ev
,
COLOR_MAGENTA
);
if
(
!
C
)
{
if
(
!
C
||
use_ids
)
{
mprintf
(
ev
,
"chat#%d"
,
tgl_get_peer_id
(
id
));
}
else
{
mprintf
(
ev
,
"%s"
,
C
->
chat
.
title
);
...
...
@@ -2385,7 +2386,7 @@ void print_chat_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
void
print_encr_chat_name
(
struct
in_ev
*
ev
,
tgl_peer_id_t
id
,
tgl_peer_t
*
C
)
{
assert
(
tgl_get_peer_type
(
id
)
==
TGL_PEER_ENCR_CHAT
);
mpush_color
(
ev
,
COLOR_MAGENTA
);
if
(
!
C
)
{
if
(
!
C
||
use_ids
)
{
mprintf
(
ev
,
"encr_chat#%d"
,
tgl_get_peer_id
(
id
));
}
else
{
mprintf
(
ev
,
"%s"
,
C
->
print_name
);
...
...
@@ -2396,7 +2397,7 @@ void print_encr_chat_name (struct in_ev *ev, tgl_peer_id_t id, tgl_peer_t *C) {
void
print_encr_chat_name_full
(
struct
in_ev
*
ev
,
tgl_peer_id_t
id
,
tgl_peer_t
*
C
)
{
assert
(
tgl_get_peer_type
(
id
)
==
TGL_PEER_ENCR_CHAT
);
mpush_color
(
ev
,
COLOR_MAGENTA
);
if
(
!
C
)
{
if
(
!
C
||
use_ids
)
{
mprintf
(
ev
,
"encr_chat#%d"
,
tgl_get_peer_id
(
id
));
}
else
{
mprintf
(
ev
,
"%s"
,
C
->
print_name
);
...
...
main.c
View file @
4882b0ad
...
...
@@ -111,6 +111,7 @@ int readline_disabled;
int
disable_output
;
int
reset_authorization
;
int
port
;
int
use_ids
;
char
*
start_command
;
void
set_default_username
(
const
char
*
s
)
{
...
...
@@ -465,6 +466,7 @@ void usage (void) {
printf
(
" -P <port> port to listen for input commands
\n
"
);
printf
(
" -S <socket-name> unix socket to create
\n
"
);
printf
(
" -e <commands> make commands end exit
\n
"
);
printf
(
" -I use user and chat IDs in updates instead of names
\n
"
);
exit
(
1
);
}
...
...
@@ -567,7 +569,7 @@ char *unix_socket;
void
args_parse
(
int
argc
,
char
**
argv
)
{
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:"
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:
I
"
#ifdef HAVE_LIBCONFIG
"c:p:"
#else
...
...
@@ -659,6 +661,9 @@ void args_parse (int argc, char **argv) {
case
'e'
:
start_command
=
optarg
;
break
;
case
'I'
:
use_ids
++
;
break
;
case
'h'
:
default:
usage
();
...
...
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