vysheng / tg

telegram-cli
GNU General Public License v2.0
6.37k stars 1.51k forks source link

BOT mode - lost Users ID (need to send /start to work) #1118

Open a-zazell opened 8 years ago

a-zazell commented 8 years ago

Hi! I'm using TG with Asterisk PBX to send notify about the calls, like on screen https://goo.gl/SjR7yi. But after a while sending doesn't happen, the boat doesn't accept user#id, writes that it is

FAIL: 38: can't parse arg #1.

./pbx_tg.sh user#12345 TEST2
Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
> safe_quit
> > FAIL: 38: can not parse arg #1
All done. Exit
halt

Script BASH:

#!/bin/bash
to="$1"
msg="$2"
tgpath=/usr/local/src/telegram/tg
cd ${tgpath}

(echo "safe_quit") | ${tgpath}/bin/telegram-cli -k ${topath}/tg-server.pub -I -U root -W -b -e "msg $to $msg"

HowTo fix this?

PS: Normal send like this:

./pbx_tg.sh user#54321 TEST2
Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
> safe_quit
 [11:46]  user#54321 >>> /start
 [11:46]  user#54321 <<< TEST2
> All done. Exit
halt
LukeLR commented 8 years ago

Try requesting the dialog_list or contact_list before sending the Message, maybe that fixes it ;)

On 01 Jun 2016, at 10:47, Telegram @cgood notifications@github.com wrote:

Hi! I'm using TG with Asterisk PBX to send notify about the calls, like on screen https://goo.gl/SjR7yi. But after a while sending doesn't happen, the boat doesn't accept user#id, writes that it is

FAIL: 38: can't parse arg #1.

./pbx_tg.sh user#12345 TEST2 Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type show_license'. This is free software, and you are welcome to redistribute it under certain conditions; type show_license' for details. Telegram-cli uses libtgl version 2.1.0 Telegram-cli includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/) I: config dir=[/root/.telegram-cli]

safe_quit

FAIL: 38: can not parse arg #1 All done. Exit halt Script BASH:

!/bin/bash

to="$1" msg="$2" tgpath=/usr/local/src/telegram/tg cd ${tgpath}

(echo "safe_quit") | ${tgpath}/bin/telegram-cli -k ${topath}/tg-server.pub -I -U root -W -b -e "msg $to $msg" HowTo fix this?

PS: Normal send like this:

./pbx_tg.sh user#54321 TEST2 Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type show_license'. This is free software, and you are welcome to redistribute it under certain conditions; typeshow_license' for details. Telegram-cli uses libtgl version 2.1.0 Telegram-cli includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/) I: config dir=[/root/.telegram-cli]

safe_quit [11:46] user#54321 >>> /start [11:46] user#54321 <<< TEST2 All done. Exit halt

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

a-zazell commented 8 years ago

@LukeLR not work:

:~$ telegram-cli -b
change_user_group: can't find the user telegramd to switch to
Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
> contact_list
FAIL: 71: RPC_CALL_FAIL 400: BOT_METHOD_INVALID
> dialog_list
FAIL: 71: RPC_CALL_FAIL 400: BOT_METHOD_INVALID
> safe_quit
> All done. Exit
halt
LukeLR commented 8 years ago

Okay, sorry, I forgot that you're running in bot mode, there these methods are not available, of course.

amin1softco commented 8 years ago

this is bot! and bot can't send msg to users before not send /start to bot check bot api document.

royzrj commented 8 years ago

I too have this same issue here. @vysheng could you give us a little light in here? Thx

a-zazell commented 6 years ago

OMG. Same problem again

./pbx_tg.sh "user#12XXXX" "test"
Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
> safe_quit
> > FAIL: 38: can not parse arg #1
All done. Exit
halt
a-zazell commented 6 years ago

OMG! It so EASY! https://redd.it/3tawd6

#!/bin/bash
TOKEN="XXXXXXXXXXXX"
ENDPOINT="https://api.telegram.org/bot"$TOKEN"/sendMessage?chat_id="$1
curl -s -X POST $ENDPOINT -F text="$2"

Sending like:

./telegram.sh "-10XXXXXX" test123
{"ok":true,"result":{"message_id":633,"chat":{"id":-10XXXXXX,"title":"CALLS @cgood.ru","type":"channel"},"date":1511372077,"text":"test123"}}

-10XXXXXX - my secret channel ID with some another users