<commit_before>package net.sourceforge.jwbf.mediawiki.actions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.ImmutableList;

import net.sourceforge.jwbf.core.actions.Post;
import net.sourceforge.jwbf.core.actions.RequestBuilder;
import net.sourceforge.jwbf.core.actions.util.HttpAction;
import net.sourceforge.jwbf.mediawiki.ApiRequestBuilder;
import net.sourceforge.jwbf.mediawiki.MediaWiki;
import net.sourceforge.jwbf.mediawiki.actions.editing.GetApiToken;
import net.sourceforge.jwbf.mediawiki.actions.util.MWAction;

public class WatchUnwatchAction extends MWAction {

    private static final Logger log = LoggerFactory.getLogger(WatchUnwatchAction.class);

    private boolean watch;
    private ImmutableList<String> titles;
    private GetApiToken watchToken;
    private boolean actionToken = true;
    private boolean hasMore = true;

    public WatchUnwatchAction(boolean watch, String... titles) {
        this.watch = watch;
        this.titles = ImmutableList.copyOf(titles);
        this.watchToken = new GetApiToken(GetApiToken.Intoken.WATCH, titles);
    }

    @Override
    public String processReturningText(String s, HttpAction action) {
        System.out.println(s);
        if (actionToken) {
            watchToken.processReturningText(s, action);
            actionToken = false;
        }
        MediaWiki.checkResponseForError(s);
        return s;
    }

    @Override
    public HttpAction getNextMessage() {
        if (actionToken) {
            return watchToken.popAction();
        }
        hasMore = false;
        RequestBuilder requestBuilder = new ApiRequestBuilder() //
                .action("watch") //
                .formatJson() //
                .postParam(watchToken.get().token()) //
                .param("titles", MediaWiki.urlEncode(MediaWiki.pipeJoined(titles))) //
        ;
        if (!watch) {
            requestBuilder.param("unwatch", !watch);
        }

        Post msg = requestBuilder.buildPost();
        log.debug("watch url: \"{}\"", msg.getRequest());
        return msg;
    }

    @Override
    public boolean hasMoreMessages() {<commit_msg>Removed print<commit_after>package net.sourceforge.jwbf.mediawiki.actions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.ImmutableList;

import net.sourceforge.jwbf.core.actions.Post;
import net.sourceforge.jwbf.core.actions.RequestBuilder;
import net.sourceforge.jwbf.core.actions.util.HttpAction;
import net.sourceforge.jwbf.mediawiki.ApiRequestBuilder;
import net.sourceforge.jwbf.mediawiki.MediaWiki;
import net.sourceforge.jwbf.mediawiki.actions.editing.GetApiToken;
import net.sourceforge.jwbf.mediawiki.actions.util.MWAction;

public class WatchUnwatchAction extends MWAction {

    private static final Logger log = LoggerFactory.getLogger(WatchUnwatchAction.class);

    private boolean watch;
    private ImmutableList<String> titles;
    private GetApiToken watchToken;
    private boolean actionToken = true;
    private boolean hasMore = true;

    public WatchUnwatchAction(boolean watch, String... titles) {
        this.watch = watch;
        this.titles = ImmutableList.copyOf(titles);
        this.watchToken = new GetApiToken(GetApiToken.Intoken.WATCH, titles);
    }

    @Override
    public String processReturningText(String s, HttpAction action) {
        if (actionToken) {
            watchToken.processReturningText(s, action);
            actionToken = false;
        }
        MediaWiki.checkResponseForError(s);
        return s;
    }

    @Override
    public HttpAction getNextMessage() {
        if (actionToken) {
            return watchToken.popAction();
        }
        hasMore = false;
        RequestBuilder requestBuilder = new ApiRequestBuilder() //
                .action("watch") //
                .formatJson() //
                .postParam(watchToken.get().token()) //
                .param("titles", MediaWiki.urlEncode(MediaWiki.pipeJoined(titles))) //
        ;
        if (!watch) {
            requestBuilder.param("unwatch", !watch);
        }

        Post msg = requestBuilder.buildPost();
        log.debug("watch url: \"{}\"", msg.getRequest());
        return msg;
    }

    @Override
    public boolean hasMoreMessages() {
{'fraction_non_alphanumeric': 0.1050058207217695, 'fraction_numerical': 0.0009313154831199069, 'mean_word_length': 2.839142091152815, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1568160', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1220, 'n_words': 230}