GiteaBot-repeat/src/cleanup.php

27 lines
930 B
PHP

#!/usr/bin/php
<?php
/**************************************************************
* This will delete all comments that match a specific keyword
**************************************************************/
// load the config, create the connection and load the repo sepcified on the cmd line args
// we will then have $client and $repo available
require('setup.php');
$words=['Today!!','Overdue!!'];
// loop through the issues
// we use getIssues() here rather than forIssues() (see https://git.jhodges.co.uk/jhodges/GiteaBot/issues/1)
foreach($words as $word){
foreach($repo->getIssues(['q'=>$word]) as $issue){
// loop through the current issues comments
foreach($issue->getComments() as $comment){
// if the comment body matches
if(($comment->user->login=='Bot') && (strpos($comment->body,$word)!==false)){
// delete the commend
$repo->deleteComment($comment);
}
}
}
}