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

sipb/mastodon-bot-autoresponder

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

开源软件名称(OpenSource Name):

sipb/mastodon-bot-autoresponder

开源软件地址(OpenSource Url):

https://github.com/sipb/mastodon-bot-autoresponder

开源编程语言(OpenSource Language):

Python 100.0%

开源软件介绍(OpenSource Introduction):

mastodon autoresponder bot

This bot was developed for mastodon.mit.edu, where people sometimes message @mastodon, the official announcement account, but the maintainers are too lazy to actually monitor it.

The bot is written in Python 3 and uses Mastodon.py and beautifulsoup4.

The bot can do the following:

  • respond to every toot sent to it by a non-admin with a predefined message mentioning the admins
    • regardless of the visibility setting of the response, the response is always sent as a DM. because of how DMs work, if the predefined message includes other peple's usernames, they'll also see the DM!
  • if it receives a DM from a non-admin, it can forward the text of that DM to the admins
  • it can boost public announcement toots by admins that mention it

The bot will not respond retroactively, i.e., the first time you run it, it will not respond to all the messages your account has received in the past.

Configuration

The bot is configured in a JSON file that looks like this:

{
    "base_url": "https://mastodon.mit.edu",
    "client_id": "0dd...65d",
    "client_secret": "a7e...6b7",
    "access_token": "9af...d33",

    "message": "[robot voice] beep boop, this account isn't monitored regularly! forwarding this in a DM to our human maintainers:",
    "admins": ["aleksejs", "dukhovni"],

    "state_file": "/home/mastodon/autoresponder/state"
}

All keys are mandatory. The first group contains information about connecting to the API and authenticating to it. The second group contains the autoresponder message and the usernames of the admins. The last group contains the path to the state file, which contains informations that lets the bot remember which messages it's already replied to (this cannot be empty, but the file doesn't have to exist the first time you run the bot).

Installation

This should really be packaged as a proper Python package, but I haven't done that. If you want to run this bot:

# 1. clone this repo
git clone [email protected]:sipb/mastodon-bot-autoresponder.git

# 2. set up a virtual environment for Python and activate it
virtualenv -p python3 env
source env/bin/activate

# 3. install the dependencies
pip install Mastodon.py==1.0.7
pip install beautifulsoup4==4.6.0

# 4. use tokentool to register the bot as an app on your server,
# then authenticate to it (don't worry, it's not hard, there's a nice
# interactive text interface)
python tokentool.py

# 5. create a config file and edit it appropriately
cp sample_config.json config.json
nano config.json

# 6. run the bot!
python autoresponder.py -c config.json



鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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