Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Automated Class Reminders via WeChat with Dynamic Scheduling

Tech 3

The system uses Spring Boot for backend services, WxPush for messaging, and xxl-job for distributed task scheduling.

Dependencies

<dependency>
    <groupId>com.lxgnb</groupId>
    <artifactId>xxl-job-boot-starter</artifactId>
    <version>2.4.0</version>
</dependency>
<dependency>
    <groupId>com.zjiecode</groupId>
    <artifactId>wxpusher-java-sdk</artifactId>
    <version>2.2.0</version>
</dependency>

Core Workflow

  1. Create WxPush application with callback URL to capture user UIDs
  2. Store UID-taskID mappings in data base
  3. Trigger messsages via WxPush when xxl-job executes

Task Registration Logic

String[] inputSegments = rawInput.split(" ");
String schedulePattern = inputSegments[0];

// Validate cron syntax
if(!CronValidator.isValid(schedulePattern)) {
    PushMessage failureAlert = new PushMessage()
        .setType(MessageType.TEXT)
        .setTargetUser(uid)
        .setAppToken(appToken)
        .setBody("Invalid schedule pattern");
    WxPusher.send(failureAlert);
    return;
}

String alertContent = inputSegments[1];

JobConfiguration jobConfig = new JobConfiguration()
    .setContactEmail("admin@domain.com")
    .setOwner("scheduler")
    .setSummary("Class reminder")
    .setHandlerName("classAlertHandler")
    .setTriggerType(ScheduleMode.CRON)
    .setCronExpression(schedulePattern);

int generatedTaskId = jobManager.registerJob(jobConfig);
if(generatedTaskId > 0) {
    TaskMapping mapping = new TaskMapping()
        .setTaskIdentifier(generatedTaskId)
        .setUserId(uid)
        .setAlertText(alertContent);
    taskRepository.persist(mapping);
    jobManager.enableTask(generatedTaskId);
    
    PushMessage successNotice = new PushMessage()
        .setType(MessageType.TEXT)
        .setTargetUser(uid)
        .setAppToken(appToken)
        .setBody("Alert scheduled. Send DEL to cancel");
    WxPusher.send(successNotice);
}

Class Schedule Processing

  • Python scraper collects institutional timetables weekly
  • Database stores class schedules with week indices
  • UID-class mappings determine notification recipients
  • xxl-job executor checks mappings and triggers alerts when classes start

Scheduling Interface

Users submit cron expressions and alert messages. Future enhancement will integrate LLM-based cron generation from natural language requests.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.