Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2020 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of jerrycan.
6jerrycan is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11jerrycan is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with jerrycan. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
21# noinspection PyPackageRequirements
22from telegram.error import Conflict
23from jerrycan.base import app
24from jerrycan.Config import Config
25from bokkichat.entities.message.TextMessage import TextMessage
28def telegram_whoami():
29 """
30 Specifies the background behaviour of the telegram bot
31 By default, the bot listens to /whoami messages
32 and answers with the telegram chat ID
33 :return: None
34 """
35 telegram = Config.TELEGRAM_BOT_CONNECTION
37 def handler(_, msg):
38 if msg.is_text():
39 msg: TextMessage = msg
41 if msg.body == "/whoami":
42 sender = telegram.address
43 receiver = msg.sender
44 telegram.send(
45 TextMessage(sender, receiver, receiver.address))
47 try:
48 telegram.loop(handler)
49 except Conflict:
50 app.logger.warning("It seems that two instances of the telegram "
51 "bot are running")