The bot that powers the SMDW_downloads Telegram channel https://t.me/SMDW_downloads
Go to file
Felix e8dead66e4 SonyDevWorld: Catch expanded p, div tags
Sony have begun using more inline styling, e.g.
```
<p lang="en-US" style="margin: 0in; [...]">Open [...]</p>
<div class="content-block-module [...]>[...]</div>
```
2022-09-24 20:26:09 +02:00
.gitignore .gitignore: Add laststatus.txt 2020-12-30 01:20:41 +01:00
LICENSE.md Add MIT License 2020-12-30 01:29:11 +01:00
README.md README: Link to ansible role 2021-01-02 23:36:21 +01:00
SonyDevWorld.py SonyDevWorld: Catch expanded p, div tags 2022-09-24 20:26:09 +02:00
sonydevworldbot.service .gitignore: Add laststatus.txt 2020-12-30 01:20:41 +01:00
sonydevworldbot.timer sonydevworldbot.timer: Fix run for every 10min 2021-01-02 23:13:45 +01:00

README.md

SonyDevWorld Telegram Bot

The bot that powers t.me/SMDW_downloads

Neither affiliated nor endorsed by Sony Mobile

Requirements:

You need to have python3 installed with the requests module.

Further, you need to supply token and channel id via environment variables:

  • SONYDEVWORLD_BOT_TOKEN: Bot token, get one from t.me/botfather, e.g. 1234567890:ABCDb1o0-ASDKHKJ3oiavKJDSFKJHkjwebb
  • SONYDEVWORLD_BOT_CHANNEL: Channel id to post to, e.g. -1000000000000 for t.me/MyExampleChannel. You can quickly obtain channel info from @getidsbot

Running

export SONYDEVWORLD_BOT_TOKEN=<my-token>
export SONYDEVWORLD_BOT_CHANNEL=<my-channel-id>
python3 SonyDevWorld.py

It makes sense to run this bot maybe once an hour to avoid hammering the Sony Dev World API.

Set export DEBUG=true to run in debug mode, set export OFFLINE=True to run in offline mode after you've saved items.json.

Deploying

For deploying, a simple systemd unit file with a timer is included.

After you've supplied your token inside the .service file and copied the unit and timer files into /etc/systemd/system/, you can run the service periodically via systemctl daemon-reload and then systemctl reenable --now sonydevworldbot.timer

For convenience, there is also an ansible role available.

Details

SonyDevWorld.py does all the heavy lifting for you. It posts to the Telegram bot API at https://api.telegram.org/bot<token>/sendMessage

The last posted item's guid info is saved to laststatus.txt. It would look something like file-download-786918.

License

MIT, see LICENSE.md.