Compare commits

..

No commits in common. "main" and "0.0.1" have entirely different histories.
main ... 0.0.1

3 changed files with 8 additions and 18 deletions

View file

@ -29,7 +29,6 @@ jobs:
pip install setuptools wheel twine pip install setuptools wheel twine
- name: Install pibooth - name: Install pibooth
run: | run: |
sudo apt-get update
sudo apt-get install libsdl* libsmpeg-dev libportmidi-dev sudo apt-get install libsdl* libsmpeg-dev libportmidi-dev
pip install pibooth pip install pibooth
- name: Install telegram client - name: Install telegram client

View file

@ -15,7 +15,7 @@ import pibooth
from pibooth.utils import LOGGER from pibooth.utils import LOGGER
__version__ = "1.0.3" __version__ = "1.0.0"
SECTION = "Telegram" SECTION = "Telegram"
@ -25,12 +25,11 @@ def pibooth_configure(cfg):
"""Declare the new configuration options""" """Declare the new configuration options"""
cfg.add_option(SECTION, "telegram_token", "", "Telegram Token") cfg.add_option(SECTION, "telegram_token", "", "Telegram Token")
cfg.add_option(SECTION, "telegram_chat_id", "", "Telegram chat ID") cfg.add_option(SECTION, "telegram_chat_id", "", "Telegram chat ID")
cfg.add_option(SECTION, "telegram_thread_id", "", "Telegram thread ID")
cfg.add_option( cfg.add_option(
SECTION, SECTION,
"telegram_message", "telegram_message",
"", "",
"Message sent with every posted photo", "Message sended on every posted photo",
) )
@ -39,7 +38,6 @@ def pibooth_startup(app, cfg):
"""Verify Telegram credentials""" """Verify Telegram credentials"""
telegram_token = cfg.get(SECTION, "telegram_token") telegram_token = cfg.get(SECTION, "telegram_token")
telegram_chat_id = cfg.get(SECTION, "telegram_chat_id") telegram_chat_id = cfg.get(SECTION, "telegram_chat_id")
telegram_thread_id = cfg.get(SECTION, "telegram_thread_id")
if not telegram_token: if not telegram_token:
LOGGER.error( LOGGER.error(
@ -53,12 +51,6 @@ def pibooth_startup(app, cfg):
+ SECTION + SECTION
+ "][telegram_chat_id], uploading deactivated" + "][telegram_chat_id], uploading deactivated"
) )
elif not telegram_thread_id:
LOGGER.error(
"Telegram Thread ID not defined in ["
+ SECTION
+ "][telegram_thread_id], uploading deactivated"
)
else: else:
LOGGER.info("Initializing Telegram client") LOGGER.info("Initializing Telegram client")
app.telegram_client = telegram.Bot(token=telegram_token) app.telegram_client = telegram.Bot(token=telegram_token)
@ -69,16 +61,15 @@ def state_processing_exit(app, cfg):
"""Upload picture to Telegram chat""" """Upload picture to Telegram chat"""
if hasattr(app, "telegram_client"): if hasattr(app, "telegram_client"):
chat_id = cfg.get(SECTION, "telegram_chat_id").strip('"') chat_id = cfg.get(SECTION, "telegram_chat_id").strip('"')
thread_id = cfg.get(SECTION, "telegram_thread_id").strip('"') upload_path = os.path.basename(app.previous_picture_file)
message = cfg.get(SECTION, "telegram_message") message = cfg.get(SECTION, "telegram_message")
try: try:
response = app.telegram_client.send_photo( response = app.telegram_client.send_photo(
chat_id=chat_id, chat_id=chat_id,
message_thread_id=thread_id,
caption=message, caption=message,
photo=open(app.previous_picture_file, 'rb'), photo=app.previous_picture_file,
parse_mode=telegram.ParseMode.MARKDOWN, parse_mode=telegram.ParseMode.MARKDOWN,
) )
LOGGER.info("File uploaded to Telegram chat: " + str(response)) LOGGER.info("File uploaded to Telegram chat: " + response)
except TelegramError as e: except TelegramError as e:
LOGGER.error(e) LOGGER.error(e)

View file

@ -35,8 +35,8 @@ def main():
], ],
author="Dídac Sabatés", author="Dídac Sabatés",
author_email="sabatesduran@gmail.com", author_email="sabatesduran@gmail.com",
url="https://git.zio.sh/astra/pibooth-telegram-upload", url="https://github.com/sabatesduran/pibooth-telegram-upload",
download_url="https://git.zio.sh/astra/pibooth-telegram-upload/archive/{}.tar.gz".format( download_url="https://github.com/sabatesduran/pibooth-telegram-upload/archive/{}.tar.gz".format(
plugin.__version__ plugin.__version__
), ),
license="GPLv3", license="GPLv3",
@ -44,7 +44,7 @@ def main():
keywords=["Raspberry Pi", "camera", "photobooth", "telegram", "chat", "bot", "channel"], keywords=["Raspberry Pi", "camera", "photobooth", "telegram", "chat", "bot", "channel"],
py_modules=["pibooth_telegram_upload"], py_modules=["pibooth_telegram_upload"],
python_requires=">=3.6", python_requires=">=3.6",
install_requires=["pibooth>=2.0.0", "python-telegram-bot==13.15"], install_requires=["pibooth>=2.0.0", "python-telegram-bot==13.12"],
zip_safe=False, # Don't install the lib as an .egg zipfile zip_safe=False, # Don't install the lib as an .egg zipfile
entry_points={"pibooth": ["pibooth_telegram_upload = pibooth_telegram_upload"]}, entry_points={"pibooth": ["pibooth_telegram_upload = pibooth_telegram_upload"]},
) )