<commit_before>#!/usr/bin/python3
import discord
import DiscordThrall
import logging
import socket
import sys
import os
from keyring import *  # @UnusedWildImport

lock_socket = None

def is_lock_free():
    global lock_socket
    lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
    try:
        lock_id = "RidiculousBadger.Discord-Wodbot"
        lock_socket.bind('\0' + lock_id)
        logging.debug("Acquired lock %r" % (lock_id,))
        print("Acquired lock %r" % (lock_id,))
        return True
    except socket.error:
        # socket already locked, task must already be running
        logging.info("Failed to acquire lock %r" % (lock_id,))
        print("Failed to acquire lock %r" % (lock_id,))
        return False

if not is_lock_free():
    sys.exit()

client = discord.Client()
Bot = DiscordThrall.Bot()

# This doesn't work. Why?
# @client.event
# async def wait_until_ready():
#     logger = logging.getLogger('discord')
#     logger.setLevel(logging.WARNING)
#     handler = logging.FileHandler(filename='bot_technical.loggimm', encoding='utf-8', mode='w')
#     handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
#     logger.addHandler(handler)

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

#When someone joins the server
# @client.event
# async def on_member_join(member):
#     server = member.server
#     fmt = 'Welcome {0.mention} to {1.name}!'
#     await client.send_message(server, fmt.format(member, server))

@client.event<commit_msg>Added character list update on bot restart with sort by ST<commit_after>#!/usr/bin/python3
import discord
import DiscordThrall
import logging
import socket
import sys
import os
from keyring import *  # @UnusedWildImport

lock_socket = None

def is_lock_free():
    global lock_socket
    lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
    try:
        lock_id = "RidiculousBadger.Discord-Wodbot"
        lock_socket.bind('\0' + lock_id)
        logging.debug("Acquired lock %r" % (lock_id,))
        print("Acquired lock %r" % (lock_id,))
        return True
    except socket.error:
        # socket already locked, task must already be running
        logging.info("Failed to acquire lock %r" % (lock_id,))
        print("Failed to acquire lock %r" % (lock_id,))
        return False

if not is_lock_free():
    sys.exit()

client = discord.Client()
Bot = DiscordThrall.Bot()

# This doesn't work. Why?
# @client.event
# async def wait_until_ready():
#     logger = logging.getLogger('discord')
#     logger.setLevel(logging.WARNING)
#     handler = logging.FileHandler(filename='bot_technical.loggimm', encoding='utf-8', mode='w')
#     handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
#     logger.addHandler(handler)

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')
    character_list_update = "__**Character List**__\n"
    for sheet in sorted(Bot.sheets.values(), key = lambda s: str(s.st)):
        character_list_update += sheet.name.capitalize() + ", owned by <@" + sheet.owner + "> (ST:<@" + str(sheet.st) + ">)\n"
    charlist = await client.get_message(client.get_channel(DiscordThrall.Sheets_Channel), DiscordThrall.Character_List)
    await client.edit_message(charlist, character_list_update)

#When someone joins the server
# @client.event
# async def on_member_join(member):
#     server = member.server
#     fmt = 'Welcome {0.mention} to {1.name}!'
#     await client.send_message(server, fmt.format(member, server))

@client.event
{'fraction_non_alphanumeric': 0.13662085691188358, 'fraction_numerical': 0.0026946914578280788, 'mean_word_length': 3.7773487773487773, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5332178', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1213, 'n_words': 279}