Agardando a que Fittrackee federe³, tampouco hai presa, aquí vai un xeito de «ir tirando».
Comenteille o tema⁴ a Sam e pareceulle ben, non demasiado complicado, e aquí estamos unhas semanas máis tarde.
Desde a versión 0.12.0⁵ temos unha canle RSS que contén as últimas cinco actividades PÚBLICAS.
configurei o robot² para que publique os adestramentos PÚBLICOS de Fittrackee¹
é o único que tiven que facer, porque a canle RSS⁶ ven incluída en Fittrackee e só tiven que mirar o contido da mesma (os datos que se expoñen) e darlle formato no robot.
despois de ir probando, deixo aquí a parte relevante da primeira versión con publicacións públicas. O robot mira se hai novos adestramentos tres veces ao día (usando CRON):
def process(mastodon, fname, entry, debug): #text = to_text(entry.description) text = "" # a link counts as 23 characters for Mastodon, plus newline limit = 500-23-1 # categories to hashtags if "category" in entry and len(entry.category) > 0: hashtags = " ".join("#" + tag.term.replace("_","") for tag in entry.tags) + "\n" limit -= len(hashtags) else: hashtags = "#TrainingLog " # strip paragraphs, if necessary while len(text) >= limit and "\n\n" in text: text = text[0:text.rfind("\n\n")] text = re.sub(r"\n\n+", "\n", text) while len(text) >= limit and " " in text: text = text[0:text.rfind(" ")] + "…" if len(text) >= limit : text = text[0:limit-1] + "…" ## autoría e título if "title" in entry: text += "\n## " + entry.title + " :fittrackee:\n" else: text += "Nova actividade en Fittrackee\n" if "description" in entry: text += entry.description else: text += "Mira a actividade na web" text += "\n\n" text += entry.link # meter cancelos quitados do tipo de actividade # distingue entre maiús/min if "Correr" in (entry.title): hashtags += "#running" if "Ciclismo" in (entry.title): hashtags += "#cycling" if "Camiñar" in (entry.title): hashtags += "#walking" if "Trail" in (entry.title): hashtags += "#trailrunning" ## continúa text += "\n\n🤖 " + hashtags if mastodon: mastodon.status_post(text, visibility="public") with open(fname, "a") as outfile: outfile.write("%s\n" % entry.link) else: print(text, "\n")
Vese que non me matei moito a modificalo e DEIXEI PARTES QUE NON SE USAN por se cando se engada «description» resulta útil para recortar ese campo.
Normalmente vou facer actividades pola mañán cedo ou na hora do xantar, así que lle puxen que publique dúas ou tres horas máis tarde, para poder modificar o título ou engadir algún comentario se fose preciso (pois garmin2fittrackee a veces non os inclúe de xeito automático). A día de hoxe a canle non inclúe o campo «Description», pero xa un se fai á idea igual e pode mirar na actividade. Tamén dicir que lle consultei a Sam se sería posible engadilo en futuras versións.
¹ https:docs.fittrackee.org/en/index.html
² https:src.alexschroeder.ch/rss-bot.git/
³ https:github.com/SamR1/FitTrackee/pull/679
⁴ https:github.com/SamR1/FitTrackee/issues/835
⁵ https:github.com/SamR1/FitTrackee/releases/tag/v0.12.0
⁶ https:fit.xmgz.eu/users/ghose/workouts.rss?lang=gl
Note: use «en», «es», etc. as language value in you subscribe from the available options in Fittrackee.