PHPFeed-to-BotToolforMastodo
AtoolforcreatigbotsforMastodowhichreadRSS/Atomfeeds.
Features:
MultiplebotsfromoescriptMultiplefeedsperbotSupports(valid)RSSadAtomStateless:ithesesethatitdoesotmaitaiacacheofwhichRSSpostshavebeecovertedtotoots.CurretlyruigtheRFIBotomastodo.social
SetupRequiresPHP7.0
YouwilleedacertfiletoruGuzzle.
Youwillalsoeedtosetthetimezoeofyourcomputerviathephp.iidate.timezoesettig.
LoadDepedeciesDepedeciesareloadedviaComposer
composeristallItusesthefollowigdepedecies:
phediverse/mastodo-restdg/rss-phpguzzlehttp/guzzleApplicatioThiscodetakescareofruigthe3rdpartyapplicatiowhichhadlesthebots.
Youwilleedtocopy/cofiguratios/APP.example.jsoto/cofiguratios/APP.jso.
I/cofiguratios/APP.jsochagetheamepropertytoacustomame.
BotCofiguratioYouwillfirsteedtomauallymaketheaccoutotheMastodoistaceofyourchoicewithaemail,passwordaduserame.
Thefile/cofiguratios/example.jsoisaexampleofabotcofiguratio.CreateaewJSONithe/cofiguratios/folderadameitforyourbot.
{"istace":"social.targarye.house",//like'mastodo.social'"userame":"my_userame",//userameforyourbot'saccout,otdisplayame//otusedatthispoit"email":"myemail+botame@mail.com",//emailforyourbot'slogi"password":"realpassword",//passwordforyourbot'slogi"hashtags":["all"],//arrayofstrigsthatyouwatas//hashtags(#)ieachtoot//dootadd'#'"feeds":[{//arrayoffeedsforthisbot"type":"rss",//typeoffeed,rssoratom"url":"https://www.website.com/rss/oe.xml",//urltofeed"hashtags":["cats"]//hashtagsforeverytootfromthisfeed},{"type":"rss","url":"https://www.website.com/rss/two.xml","hashtags":["music"]},{"type":"atom","url":"https://www.website.com/atom/three.xml","hashtags":["mood"]}]}Createaseparatecofiguratiofileforeachbotyouwishtoru.
UseUpdatesIfyourcofiguratiofileiscalledmy_rss.jso,thetheRSSitemscabeposted/updatedwith:
php/path/to/php-mastodo-rss-to-bot-stateless/idex.phpmy_rssPleaseotethelackof'.jso'itheparameter.
Tokeeptheapplicatio'stateless'(seetop),thetoolworksbasedoffoftimestamps.ThetoolwillcheckthetimestampofthelatesttootadgetallFeeditemsafterthattimestampadpoststhem.
Obviously,thishasthepotetialtootbeasaccurateasabotwithacache,butI'mtoolazytobuildoe.Ifyourfeedhasitemsaddedeverymiute(hopefullyulikely),thethistoolmaymissaitemortwoalogtheway.
Ifthebotisewadhasoposts,itwillolypostthemostrecetfeeditem,ottheetirefeed.
ScheduligIordertohaveabotthatupdatesregularly,youwilleedtoscheduletheabovePHPcallwithaCrotaskoraScheduledTaskdepedigoyoursystem.
Youwilleedtoscheduleseparatetasksforeachbot/cofig.
AdditioalIfyoueedtodisablethetoolforawhile(systemmaiteace,etc),butyoudo'twatthebottofloodMastodowithabuchofbelatedpostswheitstartsupagai,youcajustmakeapostdirectlytothebotviatheMastodoiterfaceadthestartthescheduledtaskagai.TheewpostwillmakesurethemostrecettimestampitheToottimelieisuptodate.
TODOCreatecofigclasstovalidatecofiguratiosAddutilityclassadPHPUitforlogtermstabilityGettootlegthbyistaceReplacestrlewithmorereliablefuctioExtedtoayiterable,fetchable,timestampedresource






评论