๐Ÿ’พ Archived View for m0yng.uk โ€บ 2019 โ€บ 11 โ€บ %F0%9F%93%9F-Pager-notifications-from-Mastodon-%F0%9F%90%โ€ฆ captured on 2024-05-12 at 15:08:09. Gemini links have been rewritten to link to archived content

View Raw

More Information

โฌ…๏ธ Previous capture (2024-05-10)

โžก๏ธ Next capture (2024-07-08)

-=-=-=-=-=-=-

๐Ÿ“Ÿ Pager notifications from Mastodon ๐Ÿ˜ - M0YNG.uk

Created 2019-11-14

Modified 2019-11-15

Tagged

A little while ago SP6MR pointed out that Pi-Star now supports POCSAG, a pager standard. I know pagers are basically dead, but who cares, this is Amateur Radio!

So, after a couple of false starts with pagers bought off eBay that I couldn't modify, I bit the bullet and ordered a new pager from China ๐Ÿ‡จ๐Ÿ‡ณ which was suitable for use on the 70cm amateur radio band. Easy!

I'll spare you the details of getting it coded up, the software isn't great, only works on Windows, and the drivers aren't signed.

So, now I have a pager, it's registered on DAPNET[1], and my Pi-Star is too. I can send and receive pages!

1: https://hampager.de

What now?

Mastodon.Radio notifications!

Obviously (it's not obvious, is it?) I want to get notifications of things happening on Mastodon.Radio via my new pager!

The following code is hacked together, basic, has no error handling, and will break. Do not use it in production. It uses Python3 and is based on https://github.com/DL7FL/DAPNET/tree/master/DAPNET

You will need to setup an app on your mastodon server, and grab the `access_token` to put into your config file.

It uses the streaming API of Mastodon, so often the pager get's a notification faster than Tusky on my phone!

Main file

#!/usr/bin/env python3

# --------------------------------------
# Mastodon Notifications -> DAPNET Pager
# Maybe.
#
# M0YNG 2019
# --------------------------------------

# Requirements
import dapnet
import configparser
from mastodon import Mastodon
from mastodon.streaming import StreamListener

# Load the config
config = configparser.ConfigParser()
config.read('config.ini')

# Setup logging
import sys
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s;%(levelname)s;%(message)s")
logger = logging.getLogger(sys.argv[0])

# Connect to mastodon server
mastodon = Mastodon(
    access_token = config['mastodon']['access_token'],
    api_base_url = config['mastodon']['api_base_url']
)

# Setup what to do with streams
class myListener(StreamListener):
    def on_notification(self, notification):
        # Construct a message to send
        message = 'New ' + notification['type'] + ' from ' + notification['account']['acct']
        print(message)
        # Send it
        dapnet.send(message, config['dapnet']['callsign_list'].split(','), config['dapnet']['username'], config['dapnet']['password'], config['dapnet']['serverURL'], config['dapnet']['txgroup'])

# Connect the listener to the stream
listener = myListener()
mastodon.stream_user(listener)

config.ini

; Your Mastodon account credentials
[mastodon]
access_token = token_here
api_base_url = https://mastodon.radio
;  Your DAPNET account credentials
[dapnet]
username = callsign
password = password
serverURL = http://www.hampager.de:8080/calls
txgroup = uk-all
callsign_list = M0YNG

Like I said, entirely pointless, but maybe you find the idea amusing enough to try yourself? If you do, please light my pager up by sending me a toot! @M0YNG@mastodon.radio

-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-

๐Ÿ–ค Black Lives Matter

๐Ÿ’™๐Ÿค๐Ÿ’œ Trans Rights are Human Rights

โค๏ธ๐Ÿงก๐Ÿ’›๐Ÿ’š๐Ÿ’™๐Ÿ’œ Love is Love

Copyright ยฉ 2024 Christopher M0YNG - It is forbidden to use any part of this site for crypto/NFT/AI related projects.

Code snippets are licenced under the Hippocratic License 3.0 (or later.)

Page generated 2024-03-24 by Complex 19