๐Ÿ’พ Archived View for m0yng.uk โ€บ 2020 โ€บ 08 โ€บ APRS-to-Mastodon captured on 2021-12-03 at 14:04:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

โžก๏ธ Next capture (2022-01-08)

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

APRS to Mastodon - M0YNG.uk

Created 2020-08-08

Tagged

Who doesn't want to post messages to a social network using APRS?

It's an idea I've been not-really working on for a while, and I've had various iterations.

One would watch the log files of `APRX` and toot weather reports heard off the air.

This one connects to the APRS Internet Stream and lets people send an APRS message to `M0YNG-15`, then have it tooted by @APRSBot[1] (it toots "Followers only" so it might appear silent.)

1: https://mastodon.radio/@aprsbot

The code is fairly simple, and almost certainly has issues!

The Code

publicTooter.py

#!/usr/bin/env python3

"""
APRS -> Fediverse gateway
Maybe.

M0YNG 2020
"""
# imports (obviously)
import aprslib
import configparser
from mastodon import Mastodon

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

# hashes of already tooted messages
pastToots = []

# connect to mastodon
mastodonBot = Mastodon(
    access_token=config['mastodon']['access_token'],
    api_base_url=config['mastodon']['app_url']
)

# function to check and toot APRS packets
def callback(packet):
    if 'addresse' in packet and packet['addresse'] == config['aprs']['callsign'] and packet['format'] == 'message':
        # Construct toot text
        tootText = 'From ' + str(packet['from']) + ' via ' + \
            str(packet['path']) + '\n\n' + packet['message_text']
        tootHash = hash(tootText)
        if tootHash not in pastToots:
            # log it
            print(tootText)
            # toot it
            postedToot = mastodonBot.status_post(tootText)
            # log it
            print(postedToot['url'] + '\n')
            # record it
            pastToots.append(tootHash)
            # let the user know it worked
            AIS.sendall(config['aprs']['callsign'] +
                        '>APRS,TCPIP*::'+str(packet['from']) + ' : Message tooted!')
        else:
            print('Already tooted this message')


# connect to the stream
AIS = aprslib.IS(config['aprs']['callsign'], passwd=config['aprs']['passcode'])
AIS.connect()
# do something with each packet
AIS.consumer(callback)

config.ini

[mastodon]
access_token = youraccesstoken
app_url = https://your.domain.here
[aprs]
callsign = callsign-ssid
passcode = passcodde

The Future

Things this could do;

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

๐Ÿ–ค Black Lives Matter

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

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

Copyright ยฉ 2021 Christopher M0YNG

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

Page generated 2021-11-02 by Complex 19