• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

indyhall/mastodon-welcome-bot

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

indyhall/mastodon-welcome-bot

开源软件地址(OpenSource Url):

https://github.com/indyhall/mastodon-welcome-bot

开源编程语言(OpenSource Language):

Python 100.0%

开源软件介绍(OpenSource Introduction):

Mastodon Welcome Bot

This is a Mastodon bot that sends out a welcome toot (DM) to new users, brought to you by jawns.club.

Because Mastodon's API doesn't currently have a route for getting an array of accounts in an instance, this bot queries the followers of an account and pages through for any have been created in the last x days (see configuration below). This means that you'll want ACCOUNT_ID to be an account that is auto-followed by all new users.

Deploy to Heroku

Deploy

Hosting the bot on Heroku is probably the easiest (and cheapest, it's free!) way to go. There's only a few steps:

  1. Click the button above. Once you're logged in to Heroku, you'll be taken to a window where you can set the environment variables as detailed below. Then you can create the app.
  2. Once the app is created, you'll have to schedule when it should run. Heroku's Scheduler addon is used for this (don't worry, it's free). On your new app's page, click "Heroku Scheduler" under "Installed Add-ons". In the new window, set "python run.py" as the task to run and configure the schedule for the job.

Installation/Development

Requires:

  • python3
  • pip

Steps

  1. git clone [email protected]:indyhall/mastodon-welcome-bot.git
  2. pip install -r requirements.txt (you'll probably want to setup a virtualenv for this)
  3. cp .env.dist .env
  4. Fill in the env vars as required in the .env file (see definitions below)
  5. Run the app with python run.py

Environment Variables

The application uses the following environment variables.

name required default description
ACCESS_TOKEN yes n/a the access token for the Mastodon account that you want the toots to come from
DAYS_SINCE no 1 how many days back of new users you want to go
INSTANCE_BASE_URL yes n/a the base url of the Mastodon instance you want to run this for (ex: "https://jawns.club")
TOOT_TEMPLATE yes n/a the template of the toot that you want to send out. Jinja2 syntax is used here and you can use any of the Account variables
DEBUG no false boolean (either "true" or "false") for debug mode. If true, won't actually send out the toots, will just print the message for each to stdout
ACCOUNT_ID yes n/a the account ID that you want to pull followers from

Example Welcome Toot Template

This can be copy/pasted into the TOOT_TEMPLATE environment variable. Note that \n\ndenotes a line break, as the entire var must remain on one line. Total characters cannot exceed 500, including those line breaks.

@{{ username }} Hi, and welcome to jawns.club!\n\nHere are a few handy tips:\n\n- This is a great (non-technical) intro to the Mastodon platform: https://bit.ly/2zk8t8c\n\n- Our "local" timeline is the real magic of jawns.club: https://bit.ly/2PDYyl3\n\n- Some less obvious ways to find people: https://bit.ly/2MMN2Xz\n\n- Install a free mobile app! Many people like Tootdon (iOS and Android).\n\n- Asking questions is okay and encouraged! We (@mods) are here to help.\n\nEnjoy :)




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap