<commit_before>#!/usr/bin/env python3

import socket
import random
import subprocess
import os
from collections import deque


def add_history(string):
    global history

    history.append(string)
    while len(history) > 1000:
        history.popleft()
    return


def say(msg):
    irc.send(("PRIVMSG %s :%s\r\n" % (channel, msg)).encode())


def ans_nick(nick):
    return lambda msg: say("%s%s" % (nick, msg))


server = "clipper.ens.fr"
channel = "#hackens"
botnick = "jarvis"
password = "***"
debug = True
devnull = subprocess.DEVNULL

joined = False
identified = False

basepath = os.path.dirname(__file__)
history = deque([])

while True:
    irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print("Connecting to : "+server)
    irc.connect((server, 6667))
    irc.send(("USER " + botnick + " " + botnick + " " + botnick +
              " :Jarvis au rapport !\n").encode())
    irc.send(("NICK " + botnick + "\n").encode())

    while True:
        text = irc.recv(2040).decode()

        if text.find("ERROR :Closing Link:") != -1:
            irc.close()
            break

        if(text.find('MODE ' + botnick) != -1 and
           not joined and not identified):
            print("Identifying with NickServ")
            irc.send(("PRIVMSG NICKSERV " +
                      ":IDENTIFY %s\r\n" % (password)).encode())
            print("Joining " + channel)
            irc.send(("JOIN " + channel + "\n").encode())

        if text.find('End of /NAMES list') != -1:
            joined = True
            print(channel+" joined")

        if(text.find(':NickServ') != -1
           and text.find("NOTICE "+botnick+" :You are now identified") != -1):
            identified = True
            print("Successfully identified")

        if text.find('PING') != -1:
            irc.send(('PONG ' + text.split()[1] + '\r\n').encode())
            if debug:
                print("PING received, PONG sent")

        if text.find('PRIVMSG '+botnick) != -1:
            continue

        t = text.split(botnick+':')
        if text.find('!') != -1:
            nick = text[1:text.index('!')]+": "
        else:
            nick = ''
        ans = ans_nick(nick)
        if len(t) > 1:
            prefix = t[1].strip().upper().startswith
            if prefix('AIDE'):
                ans("Jarvis au rapport ! Usage :")
                say(" jarvis: control center")
                say(" jarvis: camera ANGLE, ANGLE entre 0 et 180")
                say(" jarvis: camera ALIAS")
                say(" jarvis: alias ALIAS, ALIAS = camera, more to come")
                say(" jarvis: lumiere R V B, R, V et B entre 0 et 255")
                say(" jarvis: led wtf/jarvis/strobo")
                say(" jarvis: dis \"qqchose\"")
                say(" jarvis: atx on/off")
                say(" jarvis: historique N, N=nombre de lignes, " +
                    "facultatif (défaut = 5)")
                say(" jarvis: citation")
                say(" jarvis: jeu")
            elif prefix('CONTROL CENTER'):
                ans("Control center disponible ici : " +
                    "http://ulminfo.fr:8080/hackave.ogg")
            elif prefix('CAMERA'):
                angle = (t[1].strip())[6:].strip()
                try:
                    angle_int = int(angle)
                    if angle_int < 0 or angle_int > 180:
                        raise ValueError
                    add_history("camera "+str(angle_int))
                    ret = subprocess.call([basepath+"/jarvis",
                                          "camera",<commit_msg>Francisation<commit_after>#!/usr/bin/env python3

import socket
import random
import subprocess
import os
from collections import deque


def add_history(string):
    global history

    history.append(string)
    while len(history) > 1000:
        history.popleft()
    return


def say(msg):
    irc.send(("PRIVMSG %s :%s\r\n" % (channel, msg)).encode())


def ans_nick(nick):
    return lambda msg: say("%s%s" % (nick, msg))


server = "clipper.ens.fr"
channel = "#hackens"
botnick = "jarvis"
password = "***"
debug = True
devnull = subprocess.DEVNULL

joined = False
identified = False

basepath = os.path.dirname(__file__)
history = deque([])

while True:
    irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print("Connecting to : "+server)
    irc.connect((server, 6667))
    irc.send(("USER " + botnick + " " + botnick + " " + botnick +
              " :Jarvis au rapport !\n").encode())
    irc.send(("NICK " + botnick + "\n").encode())

    while True:
        text = irc.recv(2040).decode()

        if text.find("ERROR :Closing Link:") != -1:
            irc.close()
            break

        if(text.find('MODE ' + botnick) != -1 and
           not joined and not identified):
            print("Identifying with NickServ")
            irc.send(("PRIVMSG NICKSERV " +
                      ":IDENTIFY %s\r\n" % (password)).encode())
            print("Joining " + channel)
            irc.send(("JOIN " + channel + "\n").encode())

        if text.find('End of /NAMES list') != -1:
            joined = True
            print(channel+" joined")

        if(text.find(':NickServ') != -1
           and text.find("NOTICE "+botnick+" :You are now identified") != -1):
            identified = True
            print("Successfully identified")

        if text.find('PING') != -1:
            irc.send(('PONG ' + text.split()[1] + '\r\n').encode())
            if debug:
                print("PING received, PONG sent")

        if text.find('PRIVMSG '+botnick) != -1:
            continue

        t = text.split(botnick+':')
        if text.find('!') != -1:
            nick = text[1:text.index('!')]+": "
        else:
            nick = ''
        ans = ans_nick(nick)
        if len(t) > 1:
            prefix = t[1].strip().upper().startswith
            if prefix('AIDE'):
                ans("Jarvis au rapport ! Usage :")
                say(" jarvis: info")
                say(" jarvis: camera ANGLE, ANGLE entre 0 et 180")
                say(" jarvis: camera ALIAS")
                say(" jarvis: alias ALIAS, ALIAS = camera, more to come")
                say(" jarvis: lumiere R V B, R, V et B entre 0 et 255")
                say(" jarvis: led wtf/jarvis/strobo")
                say(" jarvis: dis \"qqchose\"")
                say(" jarvis: atx on/off")
                say(" jarvis: historique N, N=nombre de lignes, " +
                    "facultatif (défaut = 5)")
                say(" jarvis: citation")
                say(" jarvis: jeu")
            elif prefix('INFO'):
                ans("Quartier général en direct ici : " +
                    "http://ulminfo.fr:8080/hackave.ogg")
            elif prefix('CAMERA'):
                angle = (t[1].strip())[6:].strip()
                try:
                    angle_int = int(angle)
                    if angle_int < 0 or angle_int > 180:
                        raise ValueError
                    add_history("camera "+str(angle_int))
                    ret = subprocess.call([basepath+"/jarvis",
                                          "camera",
{'fraction_non_alphanumeric': 0.14758698092031425, 'fraction_numerical': 0.012345679012345678, 'mean_word_length': 1.6942554799697658, 'pattern_counts': {'":': 4, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6559838', 'n_tokens_mistral': 2274, 'n_tokens_neox': 2108, 'n_words': 540}