<commit_before><?php
/**
 * YourHusbandoBot
 *
 * @author @vampire__
 * @author @alvaroveliz
 * @version 1.0
 */

require_once 'libs/twitteroauth.php';
require_once 'config.php';
include 'husbando.php';

// configuring twitter
$twitter = new twitteroauth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET);

// getting user mentions
$mentions_url = 'https://api.twitter.com/1.1/statuses/mentions_timeline.json';
$statuses_url = 'https://api.twitter.com/1.1/statuses/update.json';
$upload_url   = 'https://upload.twitter.com/1.1/media/upload.json';

$mentions_params = array();
$mentions = $twitter->get($mentions_url, $mentions_params);

// using while because foreach and for uses more memory :3
$m = 0;
while ($m < count($mentions)) {
    $user_to_reply = $mentions[$m]->user->screen_name;
    $husbando = what_is_my_husbando($user_to_reply);

    // first we upload the photo
    $image_path   = 'husbandos/'.$husbando['picture'];
    $uploaded_image = '';
    if (file_exists($image_path)) {
        $media_base64 = base64_encode(file_get_contents($image_path));
        $image_params = array(
            'media' => $media_base64
        );
        $uploaded_image = $twitter->post($upload_url, $image_params);
    }

    $status = '@'.$user_to_reply.' Your husbando is '.$husbando['name'];

    $tweet_params = array(
        'status' => $status,
        'in_reply_to_status_id' => $mentions[$m]->id,
    );

    if (is_object($uploaded_image)) {
        $tweet_params['media_ids'] = $uploaded_image->media_id;
    }

    $twitter->post($statuses_url, $tweet_params);
<commit_msg>just in case<commit_after><?php
/**
 * YourHusbandoBot
 *
 * @author @vampire__
 * @author @alvaroveliz
 * @version 1.0
 */

require_once 'libs/twitteroauth.php';
require_once 'config.php';
include 'husbando.php';

// configuring twitter
$twitter = new twitteroauth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET);

// getting user mentions
$mentions_url = 'https://api.twitter.com/1.1/statuses/mentions_timeline.json';
$statuses_url = 'https://api.twitter.com/1.1/statuses/update.json';
$upload_url   = 'https://upload.twitter.com/1.1/media/upload.json';

$mentions_params = array();
$mentions = $twitter->get($mentions_url, $mentions_params);

// using while because foreach and for uses more memory :3
$m = 0;
while ($m < count($mentions)) {
    $user_to_reply = $mentions[$m]->user->screen_name;
    $husbando = what_is_my_husbando($user_to_reply);

    // first we upload the photo
    $image_path   = 'husbandos/'.$husbando['picture'];
    $uploaded_image = '';
    if (file_exists($image_path)) {
        $media_base64 = base64_encode(file_get_contents($image_path));
        $image_params = array(
            'media' => $media_base64
        );
        $uploaded_image = $twitter->post($upload_url, $image_params);
    }

    $status = '@'.$user_to_reply.' Your husbando is '.$husbando['name'];

    $tweet_params = array(
        'status' => $status,
        'in_reply_to_status_id' => $mentions[$m]->id,
    );

    if (is_object($uploaded_image)) {
        $tweet_params['media_ids'] = "$uploaded_image->media_id_string";
    }

    $twitter->post($statuses_url, $tweet_params);

{'fraction_non_alphanumeric': 0.1615720524017467, 'fraction_numerical': 0.009981285090455396, 'mean_word_length': 3.8961832061068704, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 6, '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': '3640762', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1154, 'n_words': 186}