WikiMonitor is a comprehensive tool designed to monitor Wikimedia's RecentChanges stream in real-time. It empowers users to define custom filter rules using Spring Expression Language (SpEL) to automatically flag specific edits, detect vandalism, or track specific patterns across Wikimedia projects.
- Real-time Monitoring: Connects to the global Wikimedia
recentchangestream via Server-Sent Events (SSE). - Custom Abuse Filters: Define complex filter rules using SpEL (Spring Expression Language) to analyze edits as they happen.
- Multi-User Support: Individual users can maintain their own set of private filter rules.
- OAuth2 Integration: Secure sign-in and authentication using Wikimedia OAuth2 (via Meta-Wiki or other MediaWiki instances).
- Live Updates: Filtered events are broadcasted to the web interface in real-time.
- Responsive UI: Modern web interface for managing filters and viewing live streams.
- Java: Version 21 or higher.
- Diff Utilities:
diffcommand line tool (usually available on Linux/Unix). - Wikimedia Account: Required for OAuth2 authentication.
-
Clone the repository:
git clone https://github.com/yourusername/wikiconnect.git cd wikiconnect/wikimonitor -
Configure Environment Variables: The application uses standard Spring Boot property resolution. A
.envfile is not loaded automatically. You can provide the required variables using any of the following methods:Option A: System environment variables
export ACCESS_TOKEN=your_wikidata_access_token export MEDIAWIKI_CLIENT_ID=your_oauth_client_id export MEDIAWIKI_CLIENT_SECRET=your_oauth_client_secret export REQUIRE_ROLLBACK_RIGHT=true
Option B:
application.propertiesorapplication.ymlAdd the values tosrc/main/resources/application.properties:ACCESS_TOKEN=your_wikidata_access_token MEDIAWIKI_CLIENT_ID=your_oauth_client_id MEDIAWIKI_CLIENT_SECRET=your_oauth_client_secret REQUIRE_ROLLBACK_RIGHT=true
Option C: Command-line arguments
java -jar target/wikimonitor.jar \ --ACCESS_TOKEN=your_wikidata_access_token \ --MEDIAWIKI_CLIENT_ID=your_oauth_client_id \ --MEDIAWIKI_CLIENT_SECRET=your_oauth_client_secret \ --REQUIRE_ROLLBACK_RIGHT=true
Option D: IDE run configuration Add the variables to your IDE's run/debug configuration as environment variables.
Variable Description ACCESS_TOKENWikimedia owner-only OAuth2 access token for API interactions MEDIAWIKI_CLIENT_IDOAuth2 client ID registered on Meta-Wiki MEDIAWIKI_CLIENT_SECRETOAuth2 client secret REQUIRE_ROLLBACK_RIGHTSet to falseto bypass rollback rights check during local testing (default:true)Note: You need to register an OAuth2 consumer on Meta-Wiki or your target MediaWiki instance to obtain the Client ID and Secret. The
ACCESS_TOKENis used for initial API interactions or bot actions. -
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
Alternatively, run the built jar file:
java -jar target/wikimonitor.jar
-
Access the Dashboard: Open your web browser and navigate to
http://localhost:8000. -
Database Migrations (Flyway): This project uses Flyway for database schema versioning. Migrations run automatically when the application starts.
- Create New Migrations: Add
.sqlfiles tosrc/main/resources/db/migration/following the naming conventionV<Version>__<Description>.sql(e.g.,V2__add_new_table.sql). - Run Migrations Manually:
mvn flyway:migrate
- Repair Failed Migrations: If a migration fails (e.g., due to a syntax error), fix the SQL file and run:
mvn flyway:repair
- Create New Migrations: Add
-
Login: Click the login button to authenticate using your Wikimedia account via OAuth2.
-
Define Filters: Navigate to the settings or filter management page to add SpEL-based rules. Example Rule:
# Flag edits by specific user or containing specific text user == 'VandalUser' || title matches '.*Spam.*'
The application uses src/main/resources/application.properties for core settings:
- Server Port:
server.port=8000 - Database: MySQL (managed by Flyway)
- JPA/Hibernate:
spring.jpa.hibernate.ddl-auto=validateensuring schema changes are done through Flyway.
src/main/java:org.qrdlife.wikiconnect.wikimonitor: Main application package.controller: Spring MVC and REST controllers for handling web requests.service: Core business logic includingWikiStreamService(SSE),AbuseFilterService(SpEL filtering), andOAuth2Service.model: JPA Entities (User,RecentChange).
src/main/resources:templates: Thymeleaf templates for the frontend.static: Static assets (CSS, JS).application.properties: Configuration file.
- Backend: Java 21, Spring Boot 4.0.2
- Database: MySQL, Flyway (Migrations)
- Streaming: OkHttp (SSE)
- Authentication: ScribeJava (OAuth2)
- Templating: Thymeleaf
- Utilities: Java Diff Utils, Jsoup, Caffeine (Caching)
This project is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for details.