mastoes-bots/bienvenibot.py

35 lines
1.1 KiB
Python
Raw Normal View History

2023-04-23 11:47:16 +00:00
from common import get_api
from common import list_read
2023-08-18 20:21:03 +00:00
from common import list_append
2023-04-23 11:47:16 +00:00
from common import list_write
# Messages
2023-11-13 17:05:28 +00:00
message = "¡Hola, te doy la bienvenida a Mastodon :mastodon: en https://masto.es!\n\nTe recomiendo que empieces escribiendo una publicación con la etiqueta #presentación y tus intereses para darte a conocer.\n\n¡Espero que tengas un buen comienzo! Si necesitas ayuda, ¡cuenta conmigo!"
2023-04-23 11:47:16 +00:00
# Initialization
bot_name = 'bienvenibot'
api = get_api('masto.es', 'rober')
2023-08-18 20:21:03 +00:00
users = list_read(bot_name)
users_limited = list_read(bot_name + "_limited")
users_limited_new = []
notifications = api.notifications(types=["admin.sign_up"])
def try_dm(user):
try:
api.status_post("@" + user + " " + message, visibility="direct")
except:
users_limited_new.append(user)
2023-04-23 11:47:16 +00:00
2023-08-18 20:21:03 +00:00
for user in users_limited:
try_dm(user)
for n in notifications:
# Message new users
user = n['account']['acct']
if n['type'] == "admin.sign_up" and user not in users:
list_append(bot_name, user)
try_dm(user)
2023-04-23 11:47:16 +00:00
2023-08-18 20:21:03 +00:00
list_write(bot_name + "_limited", users_limited_new)