在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):dmcblue/php-mastodon-rss-to-bot-stateless开源软件地址(OpenSource Url):https://github.com/dmcblue/php-mastodon-rss-to-bot-stateless开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):PHP Feed-to-Bot Tool for MastodonA tool for creating bots for Mastodon which read RSS/Atom feeds. Features:
Currently running the RFI Bot on mastodon.social SetupRequires PHP 7.0 You will need a cert file to run Guzzle. You will also need to set the timezone of your computer via the php.ini Load DependenciesDependencies are loaded via Composer
It uses the following dependencies: ApplicationThis code takes care of running the 3rd party application which handles the bots. You will need to copy In Bot ConfigurationYou will first need to manually make the account on the Mastodon instance of your choice with an email, password and username. The file {
"instance" : "social.targaryen.house", //like 'mastodon.social'
"username" : "my_username", //username for your bot's account, not display name
//not used at this point
"email" : "[email protected]", //email for your bot's login
"password" : "realpassword", //password for your bot's login
"hashtags" : ["all"], //array of strings that you want as
//hashtags (#) in each toot
//do not add '#'
"feeds" : [{ //array of feeds for this bot
"type" : "rss", //type of feed, rss or atom
"url" : "http://www.website.com/rss/one.xml",
//url to feed
"hashtags" : ["cats"] //hashtags for every toot from this feed
},{
"type" : "rss",
"url" : "http://www.website.com/rss/two.xml",
"hashtags" : ["music"]
},{
"type" : "atom",
"url" : "http://www.website.com/atom/three.xml",
"hashtags" : ["mood"]
}]
} Create a separate configuration file for each bot you wish to run. UseUpdatesIf your configuration file is called my_rss.json, then the RSS items can be posted/updated with:
Please note the lack of '.json' in the parameter. To keep the application 'stateless' (see top), the tool works based off of timestamps. The tool will check the timestamp of the latest toot and get all Feed items after that timestamp and posts them. Obviously, this has the potential to not be as accurate as a bot with a cache, but I'm too lazy to build one. If your feed has items added every minute (hopefully unlikely), then this tool may miss an item or two along the way. If the bot is new and has no posts, it will only post the most recent feed item, not the entire feed. SchedulingIn order to have a bot that updates regularly, you will need to schedule the above PHP call with a Cron task or a Scheduled Task depending on your system. You will need to schedule separate tasks for each bot/config. AdditionalIf you need to disable the tool for a while (system maintenance, etc), but you don't want the bot to flood Mastodon with a bunch of belated posts when it starts up again, you can just make a post directly to the bot via the Mastodon interface and then start the scheduled task again. The new post will make sure the most recent timestamp in the Toot timeline is up to date. TODO
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论