<commit_before>import asyncio
from datetime import datetime
import traceback
import elasticsearch

es = elasticsearch.Elasticsearch()

print("[Public Plugin] <log_events.py>: Log events to ElasticSearch.")


def setup_index():
    elastic = elasticsearch.Elasticsearch()
    try:
        mapping = {
            "discord_event": {
                "properties": {
                    "server": {"type": "string"},
                    "author": {"type": "string", "index": "not_analyzed"},
                    "author_id": {"type": "string"},
                    "channel": {"type": "string", "index": "not_analyzed"},
                    "content": {"type": "string"},
                    "timestamp": {"type": "date"},
                    "event_type": {"type": "string"},
                    "event_message": {"type": "string"},
                }
            }
        }

        elastic.indices.create("discord_events")
        elastic.indices.put_mapping(index="discord_events", doc_type="discord_event", body=mapping)

    except:
        traceback.print_exc()


@asyncio.coroutine
def action(object_before, client, config, event_type, object_after=None):
    server = str(object_before.server)
    timestamp = datetime.utcnow()
    event_message = None
    body = None

    if event_type == "delete" or event_type == "edit":
        author = str(object_before.author)
        channel = str(object_before.channel)
        content = object_before.content
        author_id = str(object_before.author.id)
        bot_channel = config.get("BotSettings", "bot_channel")

        if event_type == "delete" and channel != bot_channel:
            body = {"event_type": event_type, "server": server, "author": author, "event_message": event_message,
                    "channel": channel, "content": content, "timestamp": timestamp, "author_id": author_id}

        if (event_type == "edit") and (content != event_message):
            event_message = object_after.content
            body = {"event_type": event_type, "server": server, "author": author, "event_message": event_message,
                    "channel": channel, "content": content, "timestamp": timestamp, "author_id": author_id}

    if event_type == "member_update":
        author = object_before.name
        author_id = object_before.id
        event_message = object_after.name
        content = "namechange"
<commit_msg>Actually checking between messages this time.<commit_after>import asyncio
from datetime import datetime
import traceback
import elasticsearch

es = elasticsearch.Elasticsearch()

print("[Public Plugin] <log_events.py>: Log events to ElasticSearch.")


def setup_index():
    elastic = elasticsearch.Elasticsearch()
    try:
        mapping = {
            "discord_event": {
                "properties": {
                    "server": {"type": "string"},
                    "author": {"type": "string", "index": "not_analyzed"},
                    "author_id": {"type": "string"},
                    "channel": {"type": "string", "index": "not_analyzed"},
                    "content": {"type": "string"},
                    "timestamp": {"type": "date"},
                    "event_type": {"type": "string"},
                    "event_message": {"type": "string"},
                }
            }
        }

        elastic.indices.create("discord_events")
        elastic.indices.put_mapping(index="discord_events", doc_type="discord_event", body=mapping)

    except:
        traceback.print_exc()


@asyncio.coroutine
def action(object_before, client, config, event_type, object_after=None):
    server = str(object_before.server)
    timestamp = datetime.utcnow()
    event_message = None
    body = None

    if event_type == "delete" or event_type == "edit":
        author = str(object_before.author)
        channel = str(object_before.channel)
        content = object_before.content
        author_id = str(object_before.author.id)
        bot_channel = config.get("BotSettings", "bot_channel")

        if event_type == "delete" and channel != bot_channel:
            body = {"event_type": event_type, "server": server, "author": author, "event_message": event_message,
                    "channel": channel, "content": content, "timestamp": timestamp, "author_id": author_id}

        if (event_type == "edit") and (content != object_after.content):
            event_message = object_after.content
            body = {"event_type": event_type, "server": server, "author": author, "event_message": event_message,
                    "channel": channel, "content": content, "timestamp": timestamp, "author_id": author_id}

    if event_type == "member_update":
        author = object_before.name
        author_id = object_before.id
        event_message = object_after.name
        content = "namechange"

{'fraction_non_alphanumeric': 0.1319775887113509, 'fraction_numerical': 0.0, 'mean_word_length': 2.5545722713864305, 'pattern_counts': {'":': 76, '<': 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': '895343', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1289, 'n_words': 309}