/newbot
and follow the steps specified by the BotFather. This results in a token, this token (e.g. something like 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
is required for defining a working telegram bot in fhem.
sudo apt-get install libjson-perl
) or the correct method for the underlying platform/system.Contacts
) and also internally in the module in a hashed list to allow the usage
of contact ids and also full names and usernames. Contact ids are made up from only digits, user names are prefixed with a @, group names are prefixed with a #.
All other names will be considered as full names of contacts. Here any spaces in the name need to be replaced by underscores (_).
Each contact is considered a triple of contact id, full name (spaces replaced by underscores) and username or groupname prefixed by @ respectively #.
The three parts are separated by a colon (:).
define <name> TelegramBot <token>
define teleBot TelegramBot 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
message|msg|_msg|send [ @<peer1> ... @<peerN> ] [ (<keyrow1>) ... (<keyrowN>) ] <text>
set aTelegramBotDevice message @@someusername a message to be sent
set aTelegramBotDevice message (yes) (may be) are you there?
set aTelegramBotDevice message @@someusername (yes) (may be) are you there?
set aTelegramBotDevice message (yes|no) (may be) are you there?
set aTelegramBotDevice message @@someusername @1234567 a message to be sent to multiple receipients
set aTelegramBotDevice message @Ralf_Mustermann another message
set aTelegramBotDevice message @#justchatting Hello
set aTelegramBotDevice message @1234567 Bye
silentmsg, silentImage, silentInline ...
msgForceReply [ @<peer1> ... @<peerN> ] <text>
reply <msgid> [ @<peer1> ] <text>
msgEdit <msgid> [ @<peer1> ] <text>
msgDelete <msgid> [ @<peer1> ]
favoritesMenu [ @<peer> ]
cmdSend|cmdSendSilent [ @<peer1> ... @<peerN> ] <fhem command>
set tbot cmdSend { plotAsPng('SVG_FileLog_Aussen') }
queryInline [ @<peer1> ... @<peerN> ] (<keyrow1>) ... (<keyrowN>) <text>
queryEditInline <msgid> [ @<peer> ] (<keyrow1>) ... (<keyrowN>) <text>
queryAnswer <queryid> [ <text> ]
sendImage|image [ @<peer1> ... @<peerN>] <file> [<caption>]
sendMedia|sendDocument [ @<peer1> ... @<peerN>] <file>
sendVoice [ @<peer1> ... @<peerN>] <file>
silentImage ...
sendLocation [ @<peer1> ... @<peerN>] <latitude> <longitude>
set aTelegramBotDevice sendLocation @@someusername 51.163375 10.447683
will send the coordinates of the geographical center of Germany as location.
replaceContacts <text>
reset
token <apitoken>
urlForFile <fileid>
update
peerId <peer>
defaultPeer <name>
defaultPeerCopy <1 (default) or 0>
parseModeSend <0_None or 1_Markdown or 2_HTML or 3_Inmsg >
webPagePreview <1 or 0>
cmdKeyword <keyword>
ok fhem
then a message starting with this string will be executed as fhem command
(see also cmdTriggerOnly).ok fhem
a message of ok fhem attr telegram room IM
send to the bot would execute the command attr telegram room IM
and set a device called telegram into room IM.
The result of the cmd is sent to the requestor and in addition (if different) sent also as message to the defaultPeer (This can be controlled with the attribute defaultPeerCopy
).
shutdown
is not supported as a command (also in favorites) and will be rejected. This is needed to avoid reexecution of the shutdown command directly after restart (endless loop !).
cmdSentCommands <keyword>
last cmd
a message of last cmd
woud lead to a reply with the list of the last sent fhem commands will be sent back.cmdFavorites <keyword>
favorites
).
favorite
a message of favorite
to the bot will return a list of defined favorite commands and their index number. In the same case the message favorite <n>
(with n being a number) would execute the command that is the n-th command in the favorites list. The result of the command will be returned as in other command executions.
favorites <list of commands>
favorite
and this attribute is set to a value of
get lights status; /light=set lights on; /dark[Make it dark]=set lights off; /-heating=set heater; /[status]=get heater status;
get lights status
set lights on
. And the favorite would show as "make it dark" in the list of favorites.set heater on
get heater status
and this favorite would show as "status" as a description in the favorite listget lights status; /light=?set lights on; /dark=set lights off; ?set heater;
get lights status; /light=!set lights on; /dark=set lights off; !set heater;
get lights status; /blink=set lights on;; sleep 3;; set lights off; set heater;
/alias[description]=commands
where the alias can be empty if the description is given or /alias=command
or /-alias=command
for a hidden favorite or just the commands
. In any case the commands can be also prefixed with a '?' or a '!' (or both). The description also can be given as [-description]
to remvoe the command or alias from the favorite menus in inline keyboard menus. Spaces are only allowed in the description and the commands, usage of spaces in other areas might lead to wrong interpretation of the definition. Spaces and also many other characters are not supported in the alias commands by telegram, so if you want to have your favorite/alias directly recognized in the telegram app, restriction to letters, digits and underscore is required. Double semicolon will be used for specifying mutliple fhem commands in a single favorites, while single semicolon is used to separate between different favorite definitions
favorites2Col <1 or 0>
favoritesInline <1 or 0>
cmdRestrictedPeer <peer(s)>
cmdRespondChat <1 or 0>
allowUnknownContacts <1 or 0>
saveStateOnContactChange <1 or 0>
cmdReturnEmptyResult <1 or 0>
allowedCommands <list of command>
cmdTriggerOnly <0 or 1>
ok fhem
and cmdTriggerOnly is set, then a message of ok fhem someMacro
would execute the fhem command trigger someMacro
.queryAnswerText <text>
pollingTimeout <number>
disable
.
pollingVerbose <0_None 1_Digest 2_Log>
PollingErrCount
and PollingLastError
disable <0 or 1>
cmdTimeout <number>
maxFileSize <number of bytes>
filenameUrlEscape <0 or 1>
%20
. Default is off (0).
maxReturnSize <number of chars>
maxRetries <0,1,2,3,4,5>
textResponseConfirm <TelegramBot FHEM : $peer\n Bestätigung \n>
textResponseFavorites <TelegramBot FHEM : $peer\n Favoriten \n>
textResponseCommands <TelegramBot FHEM : $peer\n Letzte Befehle \n>
textResponseResult <TelegramBot FHEM : $peer\n Befehl:$cmd:\n Ergebnis:\n$result\n>
textResponseUnauthorized <UNAUTHORIZED: TelegramBot FHEM request from user :$peer\n Msg: $msg>
utf8Special <0 or 1>
define notify_fhem_reload notify global:INITIALIZED set <telegrambot> message fhem started - just now
Send the following message as a command to the bot ok fhem { plotAsPng('SVG_FileLog_Aussen') }
assuming ok fhem
is the command keyword)
cmdSentCommands
is set to /History
. Then you can initiate the communication with the botfather, select the right bot and then with the command /setcommands
define one or more commands like
History-Show a history of the last 10 executed commands