add cleanup script to remove all the bot spam!
This commit is contained in:
parent
5c53c5e690
commit
a5eaa40fc6
26
src/cleanup.php
Normal file
26
src/cleanup.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user