Browse Source

Deleting some unused code, keeping in history for later

Kirk Trombley 4 years ago
parent
commit
609399e135
2 changed files with 0 additions and 139 deletions
  1. 0 68
      src/discord_bot.py
  2. 0 71
      src/test_driver.py

+ 0 - 68
src/discord_bot.py

@@ -1,68 +0,0 @@
-#!/usr/bin/env python3
-import logging
-from logging.config import dictConfig
-import atexit
-
-import discord
-import discord.utils
-
-from rollbot import Rollbot, RollbotMessage, RollbotPlugin
-
-import plugins
-
-import db
-from config import get_config, get_secret
-
-dictConfig({
-    'version': 1,
-    'disable_existing_loggers': False,
-    'formatters': {
-        'default': {'format': '%(asctime)s - %(levelname)s - %(message)s', 'datefmt': '%Y-%m-%d %H:%M:%S'}
-    },
-    'handlers': {
-        'console': {
-            'level': 'INFO',
-            'formatter': 'default',
-            'class': 'logging.StreamHandler',
-            'stream': 'ext://sys.stdout',
-        },
-    },
-    'loggers': {
-        '': {
-            'handlers': ['console'],
-            'level': 'INFO',
-            'propagate': True
-        },
-    }
-})
-
-client = discord.Client()
-
-msg_queue = []
-
-rollbot = Rollbot(
-    logger=logging,
-    plugin_classes=RollbotPlugin.find_all_plugins(),
-    aliases=get_config("aliases"),
-    responses=get_config("responses"),
-    callback=lambda msg, channel_id: msg_queue.append((msg, discord.utils.get(client.get_all_channels(), id=int(channel_id)))),
-    session_factory=db.Session
-)
-rollbot.logger.info("Initializing database tables")
-db.init_db()
-rollbot.logger.info("Finished initializing database")
-rollbot.start_plugins()
-atexit.register(rollbot.shutdown_plugins)
-
-
-@client.event
-async def on_message(message):
-    msg = RollbotMessage.from_discord(message) # TODO admins
-    rollbot.handle_command(msg)
-    while len(msg_queue) > 0:
-        content, channel = msg_queue.pop()
-        await channel.send(content)
-
-
-if __name__ == "__main__":
-    client.run(get_secret("discord_token"))

+ 0 - 71
src/test_driver.py

@@ -1,71 +0,0 @@
-import atexit
-import logging
-import os
-
-from rollbot import Rollbot, RollbotMessage
-
-from config import BOTS_LOOKUP, DB_FILE, get_config
-
-try:
-    os.remove(DB_FILE)
-except FileNotFoundError:
-    pass
-
-import db
-
-rollbot = Rollbot(
-    plugin_classes=get_config("plugins"),
-    aliases=get_config("aliases"),
-    responses=get_config("responses"),
-    sleep_time=float(get_config("sleep_time")),
-    callback=None,
-    session_factory=db.Session
-)
-db.init_db()
-
-
-def test_drive(msg, from_admin=True):
-    rmsg = RollbotMessage("mock", None, None, "test_group", None, msg, from_admin)
-    r =rollbot.run_command(rmsg)
-    print(msg, ":", r.txt, ",", r.failure)
-
-
-if __name__ == "__main__":
-    [logging.disable(level) for level in [
-        logging.DEBUG,
-        logging.INFO,
-        logging.WARN,
-        logging.ERROR,
-    ]]
-
-    rollbot.start_plugins()
-    atexit.register(rollbot.shutdown_plugins)
-
-    [test_drive(msg) for msg in [
-        "!session worst",
-        "!session blah",
-        "!session cancel",
-        "!session next",
-        "!session next asdf",
-        "!session next Sunday",
-        "!session late",
-        "!session view",
-        "!session cancel T e S t",
-        "!session next Sunday",
-        "!session late",
-        "!session view",
-        "!session cancel T e S t",
-        "!session next Sunday",
-        "!session late",
-        "!session view",
-        "!session cancel dIfFeReNt",
-        "!session late",
-        "!session cancel",
-        "!session next Saturday",
-        "!session next 01/01/1980",
-        "!session next 01/01/2980",
-        "!session late",
-        "!session view",
-        "!session cancel",
-        "!session worst",
-    ]]