Telegram instant messaging TelegramBot - Empfangen und Senden per FHEM

Begonnen von viegener, 20 Juni 2015, 18:59:41

Vorheriges Thema - Nächstes Thema

viegener

Es gibt eine neue Version 0.9!

Hinweise (Bitte lesen):

Wie oben angesprochen habe ich ein alignment der Kommandos von telegramBot mit dem msg-Befehl (siehe http://forum.fhem.de/index.php/topic,39983.0.html). Das hat zu einer Aufräumaktion geführt, die ein paar Inkompatibilitäten mit sich bringt:
- Die msg/message/sendImage Befehle erlauben jetzt die optionale Angabe eines peers vor dem Text/Bild. Damit kann man entweder eine id, einen vollständigen Namen oder auch einen user-bzw Gruppennamen angeben.
Beispiele:
set <telegrambotdevice> msg @Lieschen_Mueller Hallo
set <telegrambotdevice> image @@lieschensusername /opt/fhem/image.jpg
- Achtung: messageTo/sendImageTo/sendPhotoTo sind zwar noch vorhanden, werden aber demnächst entfernt (deprecated). / sendPhoto / sendPhotoTo sind entfallen
- Es werden jetzt auch Umlaute und Emojis unterstützt
- Gruppen (Chats) können jetzt ebenfalls als Ziel einer Nachricht verwendet werden (eingeleitet mit # oder durch angabe der id).
- Doku überarbeitet etc etc

Wie immer ist die Version auch im ersten Post verfügbar und in Github.

Wenn diese Version keine Probleme bereitet würde ich sie auch ins SVN einchecken.
Gruss,
Johannes
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

Maista

Hallo Johannes
Habe am Freitag frei.
Wenn nichts dazwischen kommt, werde ich testen.

Gruß
Gerd

speex

Bisher läuft auch die neue Version prima bei mir...

Vielen Dank!

UweH

Zitat von: viegener am 15 Oktober 2015, 19:12:27
- Gruppen (Chats) können jetzt ebenfalls als Ziel einer Nachricht verwendet werden (eingeleitet mit # oder durch angabe der id).

Soweit funktioniert alles, nur das Senden an Gruppen habe ich nicht nachvollziehen können. Ich habe in Telegram eine Gruppe angelegt und will mit set <blabla> msg #<Gruppe> Test eine Nachricht senden. Funktioniert nicht, demzufolge mach ich was falsch...
Die Nachricht kommt mit dem Inhalt "#<Gruppe> Test" auf meinem Bot an.

Ich glaube, ich brauch wieder ein Beispiel für Dummies  ;)

Gruß
Uwe

speex

Hast du mal wie in der Doku beschrieben, dass hier getestet:

set aTelegramBotDevice message @#justchatting Hello
to send the message "Hello" to a chat with the name "justchatting"

Hab bisher noch keinen Gruppenchat eingerichtet daher kann ich auch nicht mehr dazu sagen.

Allerdings habe ich festgestellt das wenn ich aus einem Notify heraus einem Bestimmten msgPeer schreiben möchte das mit dem @ nicht klappt ab dem '@' wird dann immer die id mit in der nachricht geschickt sowie steht am anfang noch der notify name in der nachricht...

viegener

Zitat von: UweH am 16 Oktober 2015, 14:00:24
Soweit funktioniert alles, nur das Senden an Gruppen habe ich nicht nachvollziehen können. Ich habe in Telegram eine Gruppe angelegt und will mit set <blabla> msg #<Gruppe> Test eine Nachricht senden. Funktioniert nicht, demzufolge mach ich was falsch...
Die Nachricht kommt mit dem Inhalt "#<Gruppe> Test" auf meinem Bot an.


speex hat recht: Wenn im neuen msg Befehl ein Empfänger stehen soll, muss immer ein @ vorher stehen (also für Gruppennamen sogar @# und für usernames sogar @@ vorher).

Versuche mal
set <blabla> msg @#<Gruppenname> Test
oder
set <blabla> msg @<Gruppenid> Test
Gruppenids sind soweit ich das sehe negativ also müsste da für Gruppenid soetwas stehen wie -1234567

gruss,
Johannes
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

viegener

Zitat von: speex am 16 Oktober 2015, 14:58:43
Allerdings habe ich festgestellt das wenn ich aus einem Notify heraus einem Bestimmten msgPeer schreiben möchte das mit dem @ nicht klappt ab dem '@' wird dann immer die id mit in der nachricht geschickt sowie steht am anfang noch der notify name in der nachricht...

Ich kann das jetzt gerade nicht ausprobieren, aber meine erste Vermutung ist, dass der perl-Interpreter hier irgendeine Ersetzung macht, weil @ ja verwendet wird um Arrays zu verwenden. Laut notify-Doku
ZitatTo use % or @ in the text itself, use the double mode (%% or @@).

Kannst Du mal @@ probieren oder alternativ gar  \@ oder \@\@ oder \\\@ ausprobieren?

Gruss,
Johannes
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

speex

#187
Hi also was mir auch nicht  klar war ist das man @@ nehmen muss meine nachricht die durch das notify ausgelöst wurde sah so aus:
set teleBot message @<peerid> text

Ich hab das jetzt nochmal mit @@ im notify getestet, funktioniert wunderbar:
set teleBot message @@<peerid> text

Vielen Dank!

UweH

So, nun hab ich es. Der eigene Bot muss erst mal gruppenfähig gemacht werden, dann kann man damit auch eine Gruppe erstellen. Danach läuft's dann recht problemlos  :)

Danke und Gruß
Uwe

UweH

Gerade festgestellt: Auf /short bekomme ich keine Antwort mehr, ein /short 1 z.B. löst den entsprechenden Befehl aber aus. Die Rückmeldung auf den Befehl wird ebenfalls nicht mehr gesendet.

Gruß
Uwe

Maista

#190
Hallo zusammen,

also entweder stell ich mich an, oder es geht nichts mehr  :(

Weder
Zitat
cmdFavorites #
cmdKeyword /hey
cmdSentCommands /last
Funktionieren?!

Ein
set mybot reset
half auch nichts.

Das senden an den Client funktioniert mit

set mybot message @eumel Bla
und
set mybot msg Blabla


Ein Bild habe ich auch nicht mehr verschickt bekommen.
set sendImage @eumel /opt/fhem/35kb.jpg
wird als versendet angezeigt.

Hier das Log

Zitat
2015.10.16 19:59:41 3: HttpUtils url=<hidden>
2015.10.16 19:59:41 3: <hidden>: HTTP response code 200
2015.10.16 19:59:41 3: HttpUtils <hidden>: Got data, length: 244
2015.10.16 20:00:09 3: HttpUtils url=<hidden>
2015.10.16 20:00:39 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:01:28 3: HttpUtils url=<hidden>
2015.10.16 20:01:58 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:02:35 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found ::
2015.10.16 20:02:43 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found :list:
2015.10.16 20:07:54 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found ::
2015.10.16 20:10:11 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found :1:
2015.10.16 20:10:21 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found :list:
2015.10.16 20:15:18 3: HttpUtils url=<hidden>
2015.10.16 20:15:36 3: TelegramBot_SendIt myfhemBot: add send to queue :Maista: -:/opt/fhem/35kb.jpg: - :<undef>:
2015.10.16 20:15:44 3: TelegramBot_SendIt myfhemBot: add send to queue :Maista: -:Test: - :<undef>:
2015.10.16 20:15:49 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:15:49 3: HttpUtils url=<hidden>
2015.10.16 20:15:57 3: TelegramBot_SendIt myfhemBot: add send to queue :@Maista: -:Test: - :<undef>:
2015.10.16 20:16:11 3: TelegramBot_SendIt myfhemBot: add send to queue :@Maista: -:test: - :<undef>:
2015.10.16 20:16:19 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:16:19 3: HttpUtils url=<hidden>
2015.10.16 20:16:19 3: <hidden>: HTTP response code 200
2015.10.16 20:16:19 3: HttpUtils <hidden>: Got data, length: 220
2015.10.16 20:16:19 3: HttpUtils url=<hidden>
2015.10.16 20:16:19 3: <hidden>: HTTP response code 200
2015.10.16 20:16:19 3: HttpUtils <hidden>: Got data, length: 220
2015.10.16 20:16:19 3: HttpUtils url=<hidden>
2015.10.16 20:16:20 3: <hidden>: HTTP response code 200
2015.10.16 20:16:20 3: HttpUtils <hidden>: Got data, length: 220
2015.10.16 20:16:36 3: HttpUtils url=<hidden>
2015.10.16 20:16:36 3: <hidden>: HTTP response code 200
2015.10.16 20:16:36 3: HttpUtils <hidden>: Got data, length: 223
2015.10.16 20:16:44 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found ::
2015.10.16 20:17:34 3: HttpUtils url=<hidden>
2015.10.16 20:17:34 3: <hidden>: HTTP response code 200
2015.10.16 20:17:34 3: HttpUtils <hidden>: Got data, length: 224
2015.10.16 20:21:14 3: HttpUtils url=<hidden>
2015.10.16 20:21:45 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:26:10 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found ::
2015.10.16 20:26:24 3: HttpUtils url=<hidden>
2015.10.16 20:26:40 3: TelegramBot_SendIt myfhemBot: add send to queue :Maista: -:/opt/fhem/35kb.jpg: - :Test:
2015.10.16 20:26:54 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:26:54 3: HttpUtils url=<hidden>
2015.10.16 20:30:13 3: HttpUtils url=<hidden>
2015.10.16 20:30:33 3: TelegramBot_SendIt myfhemBot: add send to queue :@Maista: -:/opt/fhem/35kb.jpg: - :<undef>:
2015.10.16 20:30:43 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.16 20:30:43 3: HttpUtils url=<hidden>

Irgend eine Idee?

Gruss Gerd

Edit1: Hat sich erledigt. Fehler sass vorm PC  ::)

UweH


Maista

Kannst Du hier das Kommando schicken welches bei dir klappt?

viegener

Ich musste gerade nochmals einen Fix nachschieben...    ???

Leider waren die Befehle messageTo und sendImageTo komplett abgeklemmt und nicht nur aus dem Web, dabei ist auch gleich die Kommandoantwort ausgeblieben. Das ist auch mir bei weiteren Tests heute abend aufgefallen.

Neue Version ist hochgeladen und Sorry für das Problem,
Johannes




Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

Maista

#194
Moin Johannes,

wer nix macht , macht nix falsch  ;D
Dann doch was falsch machen  8)

Gerade probiert. Texte können an Clients verschickt werden.
Der Client kann nun auch wieder Anfragen stellen.
Das klappt alles soweit.

Bekam jetzt zum ersten mal die Meldung vom Notify das Fhem neu gestartet wurde!

Nur Bild bekomme ich nicht verschickt.
Das Bild ist noch vom ersten Versuch und steht unter /opt/fhem/ oder /opt/fhem/FHEM/

Zitat
2015.10.17 00:25:00 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at FHEM/Blocking.pm line 105.
2015.10.17 00:25:00 1: CallBlockingFn: Can't connect to localhost:: IO::Socket::INET: Bad hostname 'localhost:'
2015.10.17 00:25:06 3: HttpUtils url=<hidden>
2015.10.17 00:25:23 3: TelegramBot_SendIt myfhemBot: add send to queue :Maista: -:/opt/fhem/35kb.jpg: - :<undef>:
2015.10.17 00:25:37 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.17 00:25:37 3: HttpUtils url=<hidden>
2015.10.17 00:26:00 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at FHEM/Blocking.pm line 105.
2015.10.17 00:26:00 1: CallBlockingFn: Can't connect to localhost:: IO::Socket::INET: Bad hostname 'localhost:'
2015.10.17 00:26:02 3: TelegramBot_SendIt myfhemBot: add send to queue :@Maista: -:/opt/fhem/35kb.jpg: - :<undef>:
2015.10.17 00:26:07 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.17 00:26:07 3: HttpUtils url=<hidden>
2015.10.17 00:26:15 3: TelegramBot_SendIt myfhemBot: add send to queue :@Maista: -:f: - :<undef>:
2015.10.17 00:26:37 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.17 00:26:37 3: HttpUtils url=<hidden>
2015.10.17 00:26:37 3: <hidden>: HTTP response code 200
2015.10.17 00:26:37 3: HttpUtils <hidden>: Got data, length: 217
2015.10.17 00:27:01 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at FHEM/Blocking.pm line 105.
2015.10.17 00:27:01 1: CallBlockingFn: Can't connect to localhost:: IO::Socket::INET: Bad hostname 'localhost:'
2015.10.17 00:27:21 3: HttpUtils url=<hidden>
2015.10.17 00:27:21 3: <hidden>: HTTP response code 200
2015.10.17 00:27:21 3: HttpUtils <hidden>: Got data, length: 220
2015.10.17 00:27:23 3: HttpUtils url=<hidden>
2015.10.17 00:27:24 3: TelegramBot_SendIt myfhemBot: add send to queue :13363079: -:TelegramBot fhem cmd :aussen: result :OWTHERM: OWX_28_FF313C4E0400.temperature => 1.75:: - :<undef>:
2015.10.17 00:27:24 3: TelegramBot_ReadHandleCommand myfhemBot: cmd found :list:
2015.10.17 00:27:24 3: TelegramBot_SendIt myfhemBot: add send to queue :13363079: -:TelegramBot fhem cmd :list: result :
.
.
2015.10.17 00:27:25 3: <hidden>: HTTP response code 200
2015.10.17 00:27:25 3: HttpUtils <hidden>: Got data, length: 695
2015.10.17 00:27:25 3: HttpUtils url=<hidden>
2015.10.17 00:27:25 3: <hidden>: HTTP response code 200
2015.10.17 00:27:25 3: HttpUtils <hidden>: Got data, length: 303
2015.10.17 00:27:25 3: HttpUtils url=<hidden>
2015.10.17 00:27:25 3: <hidden>: HTTP response code 200
2015.10.17 00:27:25 3: HttpUtils <hidden>: Got data, length: 3848
2015.10.17 00:27:35 3: HttpUtils url=<hidden>
2015.10.17 00:27:36 3: <hidden>: HTTP response code 200
2015.10.17 00:27:36 3: HttpUtils <hidden>: Got data, length: 279
2015.10.17 00:27:46 3: HttpUtils url=<hidden>
2015.10.17 00:27:47 3: <hidden>: HTTP response code 200
2015.10.17 00:27:47 3: HttpUtils <hidden>: Got data, length: 695
2015.10.17 00:27:51 3: HttpUtils url=<hidden>
2015.10.17 00:27:51 3: <hidden>: HTTP response code 200
2015.10.17 00:27:51 3: HttpUtils <hidden>: Got data, length: 305
2015.10.17 00:27:57 3: HttpUtils url=<hidden>
2015.10.17 00:27:57 3: <hidden>: HTTP response code 200
2015.10.17 00:27:57 3: HttpUtils <hidden>: Got data, length: 329
2015.10.17 00:28:02 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at FHEM/Blocking.pm line 105.
2015.10.17 00:28:02 1: CallBlockingFn: Can't connect to localhost:: IO::Socket::INET: Bad hostname 'localhost:'
2015.10.17 00:28:21 3: HttpUtils url=<hidden>
2015.10.17 00:28:51 3: TelegramBot_Callback myfhemBot: resulted in :NonBlockingGet timed out on read from <hidden> after 30s: from SendIt
2015.10.17 00:29:03 1: PERL WARNING: Use of uninitialized value in concatenation (.) or string at FHEM/Blocking.pm line 105.
2015.10.17 00:29:03 1: CallBlockingFn: Can't connect to localhost:: IO::Socket::INET: Bad hostname 'localhost:'


Gute Nacht erst ein mal....

Gerd

Edit1: Hat sich erledigt. Fehler sass vorm PC  ::)