<commit_before>import logging
import traceback

from objects import *
from bot import *

class AdminableBot(Bot):
    def __init__(self,adminId,reportLevel=logging.ERROR,**kwargs):
        super().__init__(**kwargs)
        self.adminId = adminId
        self.reporter = None
        if not adminId is None:
            self.reporter = ReportHandler(self,reportLevel)
            self.logger.addHandler(self.reporter)

class ReportHandler(logging.Handler):
    def __init__(self,bot,level):
        super().__init__(level)
        self.bot = bot
    def emit(self,record):
        if record.exc_info:
            self.bot.sendMessage(self.bot.adminId,record.getMessage()+"\n"+traceback.format_exc(),True)
        else:
            self.bot.sendMessage(self.bot.adminId,record.getMessage())
<commit_msg>Added start of admin commnads<commit_after>import logging
import traceback

from objects import *
from bot import *

class AdminableBot(Bot):
    def __init__(self,adminId,reportLevel=logging.ERROR,**kwargs):
        super().__init__(**kwargs)
        self.adminId = adminId
        self.reporter = None
        if not adminId is None:
            self.reporter = ReportHandler(self,reportLevel)
            self.logger.addHandler(self.reporter)

    def checkSecureAdmin(self,msg):
        if msg.frm.id == adminId:
            if msg.chat.id == adminId:
                return True
            else:
                self.sendMessage(msg.chat.id,"Admin commands only valid in private chat. @{}".format(self.me.username),
                    replyingToId=msg.id
                )
        else:
            self.sendMessage(msg.chat.id,"You are not authorized to use admin controlls.", replyingToId=msg.id)
        return False


    def onCmd_adminhelp(self,msg):
        if not self.checkSecureAdmin(msg): return
        self.sendMessage(msg.chat.id,"Admin Commands: (None)",replyingToId=msg.id)

class ReportHandler(logging.Handler):
    def __init__(self,bot,level):
        super().__init__(level)
        self.bot = bot
    def emit(self,record):
        if record.exc_info:
            self.bot.sendMessage(self.bot.adminId,record.getMessage()+"\n"+traceback.format_exc(),True)
        else:
            self.bot.sendMessage(self.bot.adminId,record.getMessage())

{'fraction_non_alphanumeric': 0.11184500220167327, 'fraction_numerical': 0.0, 'mean_word_length': 2.652733118971061, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3658146', 'n_tokens_mistral': 669, 'n_tokens_neox': 662, 'n_words': 127}