<commit_before>var fs = require('fs');
var request = require('request');
var Slack = require('slack-node');

var slack_token = process.argv[2];
var weather_code = process.argv[3];
var slack_channel = process.argv[4];

webhookUri = "https://hooks.slack.com/services/" + slack_token;
slack = new Slack();
slack.setWebhook(webhookUri);

var url = "http://weather.gc.ca/wxlink/site_js/" + weather_code + ".js"

request(url, function(error, response, html){
    if(!error){
/*
language = "e";
cityName = "Toronto";
provinceName = "ON";
cityURL = "http://weather.gc.ca/city/pages/on-143_metric_e.html";
isWarning = false;
isWatch = false;
isStatement = false;
obTemperature = "-1";
obIconCode = "10";
obCondition = "Cloudy"
obWindDir = "W";
obWindSpeed = "35";
obWindGust = "";
obWindChill = "-8";
obHumidex = "";
forecastPeriods = ["Today", "Tonight", "Wed"];
forecastIconCodes = ["03", "38", "02"];
forecastConditions = ["Mainly cloudy", "Chance of flurries", "A mix of sun and cloud"];
forecastHighs = ["0", "", "0"];
forecastLows = ["", "-5", ""];
*/
        eval (html);
        var i = 0;
        var icon = "";
        if (obCondition == "Cloudy") {
            icon = ":cloud:";
        }
        
        slack.webhook({
          channel: slack_channel,
          username: "WeatherBot: Currently",
          title: cityName + " " + obTemperature + "°C",
          title_link: cityURL,
          icon_emoji: icon,
          text: obTemperature + "°C " + obCondition + "(" + obWindSpeed + " km/h" + " " + obWindDir + ")"
        }, function(err, response) {
          console.log(response);
          display_future(html, i);
        });
    }
})

function display_future (html, i) {
    eval (html);
    var high = forecastHighs[i] != "" ? forecastHighs[i] + "°C" : "";
    var low = forecastLows[i] != "" ? forecastLows[i] + "°C" : "";

    icon = "";
    if (forecastIconCodes[i] == "Cloudy") {
        icon = ":cloud:";
    } else if (forecastIconCodes[i] == "02") {
        icon = ":sun_behind_cloud:";
    } else if (forecastIconCodes[i] == "03") {
        icon = ":sun_behind_cloud:";
    } else if (forecastIconCodes[i] == "16") {
        icon = ":snow_cloud:";
    } else if (forecastIconCodes[i] == "38") {
        icon = ":snow_cloud:";
    }

    slack.webhook({
      channel: slack_channel,
      username: forecastPeriods[i],
      icon_emoji: icon,
      text: " " + forecastConditions[i] + " " + high + "/" + low + "\n"
    }, function(err, response) {
      console.log(response);
      if (i < 2) {
        display_future(html, i + 1);
      }
    });
}<commit_msg>refactor icon code stuff<commit_after>var fs = require('fs');
var request = require('request');
var Slack = require('slack-node');

var slack_token = process.argv[2];
var weather_code = process.argv[3];
var slack_channel = process.argv[4];

webhookUri = "https://hooks.slack.com/services/" + slack_token;
slack = new Slack();
slack.setWebhook(webhookUri);

var url = "http://weather.gc.ca/wxlink/site_js/" + weather_code + ".js"

request(url, function(error, response, html){
    if(!error){
/*
language = "e";
cityName = "Toronto";
provinceName = "ON";
cityURL = "http://weather.gc.ca/city/pages/on-143_metric_e.html";
isWarning = false;
isWatch = false;
isStatement = false;
obTemperature = "-1";
obIconCode = "10";
obCondition = "Cloudy"
obWindDir = "W";
obWindSpeed = "35";
obWindGust = "";
obWindChill = "-8";
obHumidex = "";
forecastPeriods = ["Today", "Tonight", "Wed"];
forecastIconCodes = ["03", "38", "02"];
forecastConditions = ["Mainly cloudy", "Chance of flurries", "A mix of sun and cloud"];
forecastHighs = ["0", "", "0"];
forecastLows = ["", "-5", ""];
*/
        eval (html);
        var i = 0;
        var icon = get_icon (obIconCode);
        
        slack.webhook({
          channel: slack_channel,
          username: "WeatherBot: Currently",
          title: cityName + " " + obTemperature + "°C",
          title_link: cityURL,
          icon_emoji: icon,
          text: obTemperature + "°C " + obCondition + "(" + obWindSpeed + " km/h" + " " + obWindDir + ")"
        }, function(err, response) {
          console.log(response);
          display_future(html, i);
        });
    }
})

function display_future (html, i) {
    eval (html);
    var high = forecastHighs[i] != "" ? forecastHighs[i] + "°C" : "";
    var low = forecastLows[i] != "" ? forecastLows[i] + "°C" : "";

    icon = get_icon (forecastIconCodes[i]);

    slack.webhook({
      channel: slack_channel,
      username: forecastPeriods[i],
      icon_emoji: icon,
      text: " " + forecastConditions[i] + " " + high + "/" + low + "\n"
    }, function(err, response) {
      console.log(response);
      if (i < 2) {
        display_future(html, i + 1);
      }
    });
}

function get_icon (icon_code) {
    var icon;

    if (icon_code == "Cloudy") {
        icon = ":cloud:";
    } else if (icon_code == "02") {
        icon = ":sun_behind_cloud:";
    } else if (icon_code == "03") {
        icon = ":sun_behind_cloud:";
    } else if (icon_code == "08") {
        icon = ":snow_cloud:";
    } else if (icon_code == "15") {
        icon = ":snow_cloud:";
    } else if (icon_code == "16") {
        icon = ":snow_cloud:";
    } else if (icon_code == "38") {
        icon = ":snow_cloud:";
    } else {
        icon = ":no_entry_sign:";
        console.log (icon_code);
    }

    return icon;
}
{'fraction_non_alphanumeric': 0.18472402899089388, 'fraction_numerical': 0.012637056309236202, 'mean_word_length': 2.7848101265822787, 'pattern_counts': {'":': 14, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1937830', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1880, 'n_words': 412}