<commit_before>import re
import json
import ConfigParser
from plugin import Plugin

class OpenStatus(Plugin):

  def __init__(self, config=None):
    try:
      self.openstatus = config.get('OpenStatus', 'url')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
      print "OpenStatus was not properly configured in your config.ini"
    super(OpenStatus, self).__init__()

  def help_text(self, bot):
    return bot.translate("openstatus_help")

  def on_privmsg(self, bot, user_nick, host, channel, message):
    if message.startswith("!offen") or message.startswith("!open"):
      if hasattr(self, "openstatus"):
        msg = bot.sanitize(self.get_status())
        msg = json.loads(msg)
        f = msg['online']

        if int(f) > 0:
          bot.send_message(channel, bot.translate("openstatus_str1").format(d=f))
        else:
          bot.send_message(channel, bot.translate("openstatus_str2").format(d=f))
      else:
        print "OpenStatus Error: [OpenStatus] url is not configured in your config.ini"

  def get_status(self):
    j = self.getpage(self.openstatus)
    return j
<commit_msg>fixed openstatus #26<commit_after>import re
import json
import ConfigParser
from plugin import Plugin

class OpenStatus(Plugin):

  def __init__(self, config=None):
    try:
      self.openstatus = config.get('OpenStatus', 'url')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
      print "OpenStatus was not properly configured in your config.ini"
    super(OpenStatus, self).__init__()

  def help_text(self, bot):
    return bot.translate("openstatus_help")

  def on_msg(self, bot, user_nick, host, channel, message):
    if message.startswith("!offen") or message.startswith("!open"):
      if hasattr(self, "openstatus"):
        msg = bot.sanitize(self.get_status(bot))
        msg = json.loads(msg)
        f = msg['online']

        if int(f) > 0:
          bot.send_message(channel, bot.translate("openstatus_str1").format(d=f))
        else:
          bot.send_message(channel, bot.translate("openstatus_str2").format(d=f))
      else:
        print "OpenStatus Error: [OpenStatus] url is not configured in your config.ini"

  def get_status(self, bot):
    j = bot.getpage(self.openstatus)
    return j

{'fraction_non_alphanumeric': 0.12003530450132392, 'fraction_numerical': 0.00353045013239188, 'mean_word_length': 3.5890688259109313, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7352549', 'n_tokens_mistral': 709, 'n_tokens_neox': 701, 'n_words': 171}