<commit_before># encoding: utf-8

require 'cinch'
require 'open-uri'
require 'json'

class Status
    include Cinch::Plugin

    set :help, <<-EOF
!status
  Affiche le statut (ouvert/fermé) du hackerspace.
EOF

    match /(open|close)\s*(\d*)/, :method => :changeStatus
    def changeStatus msg, status, delay
        msg.reply "#{msg.user}: Hey ! Maintenant on utilise l'interrupteur :)"
    end

    match /status/, :method => :status
    def status msg
        if ! config[:status_get_url] || config[:status_get_url].empty?
            msg.reply "URL de récupération de statut non configurée"
            return
        end
        if ! config[:pamela_url] || config[:pamela_url].empty?
            msg.reply "URL Pamela non configurée"
            return
        end
        response = JSON.parse open(config[:status_get_url]).read
        since = (response.key? 'since') ? "depuis le #{Time.at(response['since']).strftime('%d/%m/%Y %H:%M')}" : ''
        if response['state'] == "closed"
            msg.reply "Le hackerspace est fermé #{since} /o\\"
            if Time.now < $opentime
                msg.reply "Le hs ouvrira à #{$opentime.strftime('%H:%M')}"
            end
        else
            pamela_data = JSON.parse open(config[:pamela_url]).read
            people = pamela_data['color'].length + pamela_data['grey'].length
            msg.reply "Le hackerspace est ouvert #{since}, et il y a en ce moment #{people} personnes \\o/"
            if Time.now < $closetime
                msg.reply "Le hs fermera à #{$closetime.strftime('%H:%M')}"
            end
        end
    end
end<commit_msg>[add] sudo !open && sudo !close (fix #9)<commit_after># encoding: utf-8

require 'cinch'
require 'open-uri'
require 'json'

class Status
    include Cinch::Plugin

    set :help, <<-EOF
!status
  Affiche le statut (ouvert/fermé) du hackerspace.
EOF

    match /(open|close).*/, :method => :changeStatus
    def changeStatus msg, status
        msg.reply "#{msg.user}: Hey ! Maintenant on utilise l'interrupteur :)"
    end

    match /sudo \!(open|close).*/, :prefix => '', :method => :forceChangeStatus
    def forceChangeStatus msg, status
        if ! config[:status_change_url] || config[:status_change_url].empty?
            msg.reply "URL de changement de statut non configurée"
            return
        end
        open("#{config[:status_change_url]}?status=#{status}")
        if status == "open"
            msg.reply "Le hackerspace est ouvert. Dites bonjour à HAL de ma part !"
        else
            msg.reply "Le hackerspace est fermé ! A l'occaze, demandez à HAL s'il va bien"
        end
    end


    match /status/, :method => :status
    def status msg
        if ! config[:status_get_url] || config[:status_get_url].empty?
            msg.reply "URL de récupération de statut non configurée"
            return
        end
        if ! config[:pamela_url] || config[:pamela_url].empty?
            msg.reply "URL Pamela non configurée"
            return
        end
        response = JSON.parse open(config[:status_get_url]).read
        since = (response.key? 'since') ? "depuis le #{Time.at(response['since']).strftime('%d/%m/%Y %H:%M')}" : ''
        if response['state'] == "closed"
            msg.reply "Le hackerspace est fermé #{since} /o\\"
        else
            pamela_data = JSON.parse open(config[:pamela_url]).read
            people = pamela_data['color'].length + pamela_data['grey'].length
            msg.reply "Le hackerspace est ouvert #{since}, et il y a en ce moment #{people} personnes \\o/"
        end
    end
end
{'fraction_non_alphanumeric': 0.1324022346368715, 'fraction_numerical': 0.0008379888268156424, 'mean_word_length': 2.3656015037593985, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2710402', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1100, 'n_words': 313}