'''
Add the Amazing feature to co-write fictional or non-fictional epics.
'''
import os
from datetime import datetime

import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from stickord.registry import Command, get_easy_logger, role_whitelist, channel_whitelist

Base = declarative_base() # pylint: disable=invalid-name
LOGGER = get_easy_logger('commands.storywriting')


class StoryElement(Base):
    ''' Represents a story piece of 3 words. '''
    __tablename__ = 'stories'

    id = sa.Column(sa.Integer, primary_key=True) # pylint: disable=invalid-name
    story_string = sa.Column(sa.String, nullable=False)
    author = sa.Column(sa.String, nullable=False)
    story_id = sa.Column(sa.Integer, nullable=False)
    created_at = sa.Column(sa.DateTime, default=datetime.utcnow)

    def __repr__(self):
        ''' Represent as <StoryElement(id, story_string, author,
        story_id, created_at)>.'''
        return (f'<StoryElement({self.id}, {self.story_string}, {self.author},'
                f' {self.story_id}, {self.created_at})>')


@Command(['addstory', 'as'], category='Games')