ADD: FediTree
This commit is contained in:
parent
d5e0856a48
commit
53c29c13c4
|
@ -0,0 +1,113 @@
|
|||
from PIL import Image
|
||||
from common import get_api, get_new_notifications, list_read, list_append
|
||||
import datetime
|
||||
import gettext
|
||||
import requests
|
||||
|
||||
coordinates = [
|
||||
(350,200),
|
||||
(275,350),
|
||||
(425,350),
|
||||
(200,500),
|
||||
(350,500),
|
||||
(500,500),
|
||||
(125,650),
|
||||
(275,650),
|
||||
(425,650),
|
||||
(575,650),
|
||||
]
|
||||
|
||||
def get_ordered_accounts_ids(account_id):
|
||||
current_year = datetime.date.today().year
|
||||
accounts = {}
|
||||
stop = False
|
||||
max_id=None
|
||||
loops = 0
|
||||
while stop == False:
|
||||
statuses = api.account_statuses(account_id, exclude_reblogs=True, max_id=max_id, limit=80)
|
||||
for status in statuses:
|
||||
if(status.created_at.year < current_year):
|
||||
stop = True
|
||||
break
|
||||
for mention in status.mentions:
|
||||
if mention.id not in accounts:
|
||||
accounts[mention.id] = 1
|
||||
else:
|
||||
accounts[mention.id] = accounts[mention.id] + 1
|
||||
max_id=status.id
|
||||
loops = loops + 1
|
||||
if loops > 10 :
|
||||
stop = True
|
||||
accounts_list = sorted(accounts, key=accounts.get, reverse=True)
|
||||
accounts_list.insert(0,account_id)
|
||||
accounts_list.pop
|
||||
return accounts_list
|
||||
|
||||
def get_accounts(accounts_ids):
|
||||
accounts = []
|
||||
for i in range(len(accounts_ids)):
|
||||
account = api.account(accounts_ids[i])
|
||||
if "nobot" not in account.note:
|
||||
accounts.append(account)
|
||||
if len(accounts) == len(coordinates):
|
||||
break
|
||||
return accounts
|
||||
|
||||
|
||||
def create_image(accounts):
|
||||
with Image.open("feditree/fediverse-christmas-tree.png") as feditree:
|
||||
feditree.load()
|
||||
with Image.open("feditree/bola_radio.png") as bola_radio:
|
||||
bola_radio.load()
|
||||
with Image.open("feditree/bola_mask.png") as bola_mask:
|
||||
bola_mask.load()
|
||||
for i in range(min(len(accounts),len(coordinates))):
|
||||
account = api.account(accounts[i])
|
||||
avatar_url = account.avatar_static
|
||||
avatar_data = requests.get(avatar_url).content
|
||||
with open('feditree/avatar.png', 'wb') as handler:
|
||||
handler.write(avatar_data)
|
||||
with Image.open('feditree/avatar.png') as avatar:
|
||||
avatar.load()
|
||||
avatar = avatar.resize((100,100)).convert("RGB")
|
||||
avatar.paste(bola_radio, (0,0), bola_radio)
|
||||
feditree.paste(avatar, coordinates[i], bola_mask)
|
||||
feditree.save("feditree/feditree.png")
|
||||
bola_radio.close()
|
||||
bola_mask.close()
|
||||
avatar.close()
|
||||
feditree.close()
|
||||
description = _("A simple drawing of a fir tree, crowned with the pentagon symbolizing the Fediverse.")
|
||||
description = description + " " + _("There are some christmas bulbs hanging in the tree, which have the avatars of the mentioned accounts inside.")
|
||||
description = description + " " + _("The accounts appear in the tree in the same order as the mentions, from top to bottom and from left to right.")
|
||||
description = description + " " + _("The order symbolizes the number of interactions, from most to least.")
|
||||
description = description + "\n\n" + _("The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree design was obtained from https://freesvgdesigns.com")
|
||||
return api.media_post("feditree/feditree.png", description=description)
|
||||
|
||||
|
||||
bot_name = "feditree"
|
||||
localedir = './locales'
|
||||
api = get_api('masto.es', "test")
|
||||
notifications = get_new_notifications(api, bot_name, ["mention"])
|
||||
previous_ids = list_read(bot_name + "_previous_ids")
|
||||
|
||||
for notification in notifications:
|
||||
i18n = gettext.translation(bot_name, localedir, fallback=True, languages=[notification.status.language])
|
||||
i18n.install()
|
||||
if str(notification.account.id) in previous_ids:
|
||||
status = "@" + notification.account.acct + " "
|
||||
status += _("I have already generated a feditree for you this year. Try again next year!")
|
||||
api.status_post(status, visibility="direct", in_reply_to_id=notification.status.id)
|
||||
continue
|
||||
else:
|
||||
list_append(bot_name + "_previous_ids", previous_ids)
|
||||
accounts_ids = get_ordered_accounts_ids(notification.account.id)
|
||||
accounts = get_accounts(accounts_ids)
|
||||
image = create_image(accounts)
|
||||
status = _("These are the people who have adorned the #FediTree of") + " @" + notification.account.acct + ":"
|
||||
for account in accounts:
|
||||
if account.acct == notification.account.acct:
|
||||
continue
|
||||
status += " @/" + account.acct
|
||||
api.status_post(status, media_ids=image, visibility="unlisted", in_reply_to_id=notification.status.id)
|
||||
previous_ids.append(notification.account.id)
|
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,66 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-13 21:17+0100\n"
|
||||
"PO-Revision-Date: 2024-12-13 22:06+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: ca\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 3.4.2\n"
|
||||
|
||||
#: feditree.py:80
|
||||
msgid ""
|
||||
"A simple drawing of a fir tree, crowned with the pentagon symbolizing the "
|
||||
"Fediverse."
|
||||
msgstr ""
|
||||
"Un dibuix senzill d'un avet, coronat amb el pentàgon que simbolitza el "
|
||||
"Fediverse."
|
||||
|
||||
#: feditree.py:81
|
||||
msgid ""
|
||||
"There are some christmas bulbs hanging in the tree, which have the avatars "
|
||||
"of the mentioned accounts inside."
|
||||
msgstr ""
|
||||
"Hi ha penjades a l'arbre unes bombetes de Nadal, que tenen a dins els "
|
||||
"avatars dels esmentats comptes."
|
||||
|
||||
#: feditree.py:82
|
||||
msgid ""
|
||||
"The accounts appear in the tree in the same order as the mentions, from top "
|
||||
"to bottom and from left to right."
|
||||
msgstr ""
|
||||
"Els comptes apareixen a l'arbre en el mateix ordre que les mencions, de dalt "
|
||||
"a baix i d'esquerra a dreta."
|
||||
|
||||
#: feditree.py:83
|
||||
msgid "The order symbolizes the number of interactions, from most to least."
|
||||
msgstr "L'ordre simbolitza el nombre d'interaccions, de més a menys."
|
||||
|
||||
#: feditree.py:84
|
||||
msgid ""
|
||||
"The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree "
|
||||
"design was obtained from https://freesvgdesigns.com"
|
||||
msgstr ""
|
||||
"El logotip de Fediverse va ser creat per @eudaimon@fe.disroot.org i el "
|
||||
"disseny de l'arbre es va obtenir a https://freesvgdesigns.com"
|
||||
|
||||
#: feditree.py:98
|
||||
msgid ""
|
||||
"I have already generated a feditree for you this year. Try again next year!"
|
||||
msgstr ""
|
||||
"Ja he generat un feditree per a tu aquest any. Torna-ho a provar l'any que "
|
||||
"ve!"
|
||||
|
||||
#: feditree.py:103
|
||||
msgid "These are the people who have adorned the #FediTree of"
|
||||
msgstr "Aquestes són les persones que han adornat el #FediArbre de"
|
Binary file not shown.
|
@ -0,0 +1,56 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-13 21:17+0100\n"
|
||||
"PO-Revision-Date: 2024-12-13 21:18+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 3.4.2\n"
|
||||
|
||||
#: feditree.py:80
|
||||
msgid ""
|
||||
"A simple drawing of a fir tree, crowned with the pentagon symbolizing the "
|
||||
"Fediverse."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:81
|
||||
msgid ""
|
||||
"There are some christmas bulbs hanging in the tree, which have the avatars "
|
||||
"of the mentioned accounts inside."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:82
|
||||
msgid ""
|
||||
"The accounts appear in the tree in the same order as the mentions, from top "
|
||||
"to bottom and from left to right."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:83
|
||||
msgid "The order symbolizes the number of interactions, from most to least."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:84
|
||||
msgid ""
|
||||
"The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree "
|
||||
"design was obtained from https://freesvgdesigns.com"
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:98
|
||||
msgid ""
|
||||
"I have already generated a feditree for you this year. Try again next year!"
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:103
|
||||
msgid "These are the people who have adorned the #FediTree of"
|
||||
msgstr ""
|
Binary file not shown.
|
@ -0,0 +1,66 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-13 21:17+0100\n"
|
||||
"PO-Revision-Date: 2024-12-13 21:20+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 3.4.2\n"
|
||||
|
||||
#: feditree.py:80
|
||||
msgid ""
|
||||
"A simple drawing of a fir tree, crowned with the pentagon symbolizing the "
|
||||
"Fediverse."
|
||||
msgstr ""
|
||||
"Un dibujo simple de un abeto, coronado con el pentágono que simboliza el "
|
||||
"Fediverso."
|
||||
|
||||
#: feditree.py:81
|
||||
msgid ""
|
||||
"There are some christmas bulbs hanging in the tree, which have the avatars "
|
||||
"of the mentioned accounts inside."
|
||||
msgstr ""
|
||||
"Del árbol cuelgan unas bolas, que tienen dentro los avatares de las cuentas "
|
||||
"mencionadas."
|
||||
|
||||
#: feditree.py:82
|
||||
msgid ""
|
||||
"The accounts appear in the tree in the same order as the mentions, from top "
|
||||
"to bottom and from left to right."
|
||||
msgstr ""
|
||||
"Las cuentas aparecen en el árbol en el mismo orden que las menciones, de "
|
||||
"arriba a abajo y de izquierda a derecha."
|
||||
|
||||
#: feditree.py:83
|
||||
msgid "The order symbolizes the number of interactions, from most to least."
|
||||
msgstr "El orden simboliza el número de interacciones, de más a menos."
|
||||
|
||||
#: feditree.py:84
|
||||
msgid ""
|
||||
"The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree "
|
||||
"design was obtained from https://freesvgdesigns.com"
|
||||
msgstr ""
|
||||
"El logo del Fediverso es obra de @eudaimon@fe.disroot.org y el diseño del "
|
||||
"árbol ha sido obtenido de https://freesvgdesigns.com"
|
||||
|
||||
#: feditree.py:98
|
||||
msgid ""
|
||||
"I have already generated a feditree for you this year. Try again next year!"
|
||||
msgstr ""
|
||||
"Ya he generado un fediárbol para ti este año. ¡Vuelve a intentarlo el año "
|
||||
"que viene!"
|
||||
|
||||
#: feditree.py:103
|
||||
msgid "These are the people who have adorned the #FediTree of"
|
||||
msgstr "Estas son las personas que han adornado el #FediÁrbol de"
|
|
@ -0,0 +1,55 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-13 21:17+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: feditree.py:80
|
||||
msgid ""
|
||||
"A simple drawing of a fir tree, crowned with the pentagon symbolizing the "
|
||||
"Fediverse."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:81
|
||||
msgid ""
|
||||
"There are some christmas bulbs hanging in the tree, which have the avatars "
|
||||
"of the mentioned accounts inside."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:82
|
||||
msgid ""
|
||||
"The accounts appear in the tree in the same order as the mentions, from top "
|
||||
"to bottom and from left to right."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:83
|
||||
msgid "The order symbolizes the number of interactions, from most to least."
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:84
|
||||
msgid ""
|
||||
"The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree "
|
||||
"design was obtained from https://freesvgdesigns.com"
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:98
|
||||
msgid ""
|
||||
"I have already generated a feditree for you this year. Try again next year!"
|
||||
msgstr ""
|
||||
|
||||
#: feditree.py:103
|
||||
msgid "These are the people who have adorned the #FediTree of"
|
||||
msgstr ""
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-13 21:17+0100\n"
|
||||
"PO-Revision-Date: 2024-12-13 22:07+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: gl\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 3.4.2\n"
|
||||
|
||||
#: feditree.py:80
|
||||
msgid ""
|
||||
"A simple drawing of a fir tree, crowned with the pentagon symbolizing the "
|
||||
"Fediverse."
|
||||
msgstr ""
|
||||
"Un sinxelo debuxo dun abeto, coroado co pentágono que simboliza o Fediverse."
|
||||
|
||||
#: feditree.py:81
|
||||
msgid ""
|
||||
"There are some christmas bulbs hanging in the tree, which have the avatars "
|
||||
"of the mentioned accounts inside."
|
||||
msgstr ""
|
||||
"Na árbore colgaban unhas lámpadas de Nadal, que levan dentro os avatares das "
|
||||
"contas mencionadas."
|
||||
|
||||
#: feditree.py:82
|
||||
msgid ""
|
||||
"The accounts appear in the tree in the same order as the mentions, from top "
|
||||
"to bottom and from left to right."
|
||||
msgstr ""
|
||||
"As contas aparecen na árbore na mesma orde que as mencións, de arriba abaixo "
|
||||
"e de esquerda a dereita."
|
||||
|
||||
#: feditree.py:83
|
||||
msgid "The order symbolizes the number of interactions, from most to least."
|
||||
msgstr "A orde simboliza o número de interaccións, de máis a menos."
|
||||
|
||||
#: feditree.py:84
|
||||
msgid ""
|
||||
"The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree "
|
||||
"design was obtained from https://freesvgdesigns.com"
|
||||
msgstr ""
|
||||
"O logotipo de Fediverse foi creado por @eudaimon@fe.disroot.org e o deseño "
|
||||
"da árbore foi obtido de https://freesvgdesigns.com"
|
||||
|
||||
#: feditree.py:98
|
||||
msgid ""
|
||||
"I have already generated a feditree for you this year. Try again next year!"
|
||||
msgstr "Xa xerei un feditree para ti este ano. Téntao de novo o ano que vén!"
|
||||
|
||||
#: feditree.py:103
|
||||
msgid "These are the people who have adorned the #FediTree of"
|
||||
msgstr "Estas son as persoas que adornaron a #FediÁrbore de"
|
Binary file not shown.
|
@ -0,0 +1,65 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-12-13 21:17+0100\n"
|
||||
"PO-Revision-Date: 2024-12-13 22:08+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: pt\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 3.4.2\n"
|
||||
|
||||
#: feditree.py:80
|
||||
msgid ""
|
||||
"A simple drawing of a fir tree, crowned with the pentagon symbolizing the "
|
||||
"Fediverse."
|
||||
msgstr ""
|
||||
"Um desenho simples de um abeto, coroado com o pentágono que simboliza o "
|
||||
"Fediverse."
|
||||
|
||||
#: feditree.py:81
|
||||
msgid ""
|
||||
"There are some christmas bulbs hanging in the tree, which have the avatars "
|
||||
"of the mentioned accounts inside."
|
||||
msgstr ""
|
||||
"Existem algumas lâmpadas de Natal penduradas na árvore, que trazem no seu "
|
||||
"interior os avatares das contas referidas."
|
||||
|
||||
#: feditree.py:82
|
||||
msgid ""
|
||||
"The accounts appear in the tree in the same order as the mentions, from top "
|
||||
"to bottom and from left to right."
|
||||
msgstr ""
|
||||
"As contas aparecem na árvore pela mesma ordem das menções, de cima para "
|
||||
"baixo e da esquerda para a direita."
|
||||
|
||||
#: feditree.py:83
|
||||
msgid "The order symbolizes the number of interactions, from most to least."
|
||||
msgstr "A ordem simboliza o número de interações, da maior para a menor."
|
||||
|
||||
#: feditree.py:84
|
||||
msgid ""
|
||||
"The Fediverse logo was created by @eudaimon@fe.disroot.org and the tree "
|
||||
"design was obtained from https://freesvgdesigns.com"
|
||||
msgstr ""
|
||||
"O logótipo da Fediverse foi criado por @eudaimon@fe.disroot.org e o desenho "
|
||||
"da árvore foi obtido em https://freesvgdesigns.com"
|
||||
|
||||
#: feditree.py:98
|
||||
msgid ""
|
||||
"I have already generated a feditree for you this year. Try again next year!"
|
||||
msgstr ""
|
||||
"Já gerei um feditree para si este ano. Tente novamente no próximo ano!"
|
||||
|
||||
#: feditree.py:103
|
||||
msgid "These are the people who have adorned the #FediTree of"
|
||||
msgstr "Estas são as pessoas que adornaram a #FediÁrvore de"
|
Loading…
Reference in New Issue