<commit_before># -*- coding: utf-8 -*-
"""
Commands:
.autoop add #channel nick!<EMAIL>         adds hostmask to #channels auto-op list
.autoop remove #channel nick!<EMAIL>      removes hostmask from #channels auto-op list
.autoop list <#channel>                             lists ops in current channel or #channel
.autoop status                                      lists channels where user is op
.op
"""

import sqlite3
import re


COMMANDS = ['add', 'remove', 'list', 'status']


def init(botconfig):
    open_DB(True)


def open_DB(createTable=False):
    conn = sqlite3.connect('module_autoop.db')
    c = conn.cursor()
    if createTable:
        c.execute('CREATE TABLE IF NOT EXISTS autoops (channel, hostmask, modes);')
        conn.commit()
    return conn, c


def add_op(channel, hostmask):
    if not get_op_status(channel, hostmask):
        conn, c = open_DB()
        c.execute('INSERT INTO autoops VALUES (?, ?);', (channel, hostmask))
        conn.commit()
        conn.close()
        return True


def remove_op(channel, hostmask):
    if get_op_status(channel, hostmask):
        conn, c = open_DB()
        c.execute('DELETE FROM autoops WHERE channel = ? AND hostmask = ?;', (channel, hostmask))
        conn.commit()
        conn.close()
        return True


def get_op_status(channel, hostmask):
    conn, c = open_DB()
    c.execute('SELECT * FROM autoops WHERE channel = ? AND hostmask = ? LIMIT 1;', (channel, hostmask))
    if c.fetchone():
        retval = True
    else:
        retval = False
    conn.close()
    return retval

<commit_msg>small correction to last commit<commit_after># -*- coding: utf-8 -*-
"""
Commands:
.autoop add #channel nick!<EMAIL>         adds hostmask to #channels auto-op list
.autoop remove #channel nick!<EMAIL>      removes hostmask from #channels auto-op list
.autoop list <#channel>                             lists ops in current channel or #channel
.autoop status                                      lists channels where user is op
.op
"""

import sqlite3
import re


COMMANDS = ['add', 'remove', 'list', 'status']


def init(botconfig):
    open_DB(True)


def open_DB(createTable=False):
    conn = sqlite3.connect('module_autoop.db')
    c = conn.cursor()
    if createTable:
        c.execute('CREATE TABLE IF NOT EXISTS autoops (channel, hostmask, modes);')
        conn.commit()
    return conn, c


def add_op(channel, hostmask, modes='o'):
    if not get_op_status(channel, hostmask):
        conn, c = open_DB()
        c.execute('INSERT INTO autoops VALUES (?, ?, ?);', (channel, hostmask, modes))
        conn.commit()
        conn.close()
        return True


def remove_op(channel, hostmask):
    if get_op_status(channel, hostmask):
        conn, c = open_DB()
        c.execute('DELETE FROM autoops WHERE channel = ? AND hostmask = ?;', (channel, hostmask))
        conn.commit()
        conn.close()
        return True


def get_op_status(channel, hostmask):
    conn, c = open_DB()
    c.execute('SELECT * FROM autoops WHERE channel = ? AND hostmask = ? LIMIT 1;', (channel, hostmask))
    if c.fetchone():
        retval = True
    else:
        retval = False
    conn.close()
    return retval


{'fraction_non_alphanumeric': 0.11947318908748825, 'fraction_numerical': 0.002508623392913139, 'mean_word_length': 2.513215859030837, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4647248', 'n_tokens_mistral': 973, 'n_tokens_neox': 955, 'n_words': 296}