Menu

[r39]: / trunk / bot-example.php  Maximize  Restore  History

Download this file

52 lines (41 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
require_once 'bgbot.php';
/*
Configuration file with “OPTION = VALUE” lines.
Example content:
; wiki code
wiki = XX
; username on the wiki
user = USERNAME
; password for the user on the wiki
pass = xxx
; a file with all pages to be edited, one per line
input = pages
; sleep 60 secs between edits
sleep = 60
*/
$config_file = $argv[1] ? $argv[1] : 'config';
if ( !file_exists($config_file) ) {
die("The configuration file '$config_file' doesn't exist. The bot cannot proceed its work.\n");
}
$options = parse_ini_file($config_file);
$vars = array('wiki', 'user', 'pass', 'input', 'sleep');
foreach ($vars as $var) {
$$var = trim($options[$var]);
}
$bot = new Bgbot($wiki, $user, $pass);
$lines = file($input);
$pages = array();
foreach ($lines as $line) {
$pages[] = rtrim($line);
}
foreach ($pages as $page) {
if ( $bot->edit($page, $wiki, false) ) {
$content = $bot->page_content;
// do something to $content
$summary = 'My summary for this edit';
$bot->submit($content, $summary, $wiki);
$bot->log($summary);
sleep($sleep_time);
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.