-- Leo's gemini proxy

-- Connecting to m0yng.uk:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en

APRS to Mastodon - M0YNG.uk

Created 2020-08-08

Tagged

Amateur Radio

APRS

Mastodon


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;


Have "registered users" who's messages could be tooted by specific accounts, e.g. if it comes from `M0YNG` it gets tooted by `@M0YNG-APRS`

Be used at a hamfest or club event, and display the messages somewhere fun


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

๐Ÿ–ค 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

-- Response ended

-- Page fetched on Sat May 18 20:47:10 2024