zacharyhooker / cybot

A generic socket.io bot. Currently framed for cytu.be.
0 stars 1 forks source link

TODO: Connection Bootstrapping #1

Closed zacharyhooker closed 7 years ago

zacharyhooker commented 7 years ago

The config/run.py currently requires other modules to be imported and the namespace->connection function needs to be run.

  | import requests as req
  | from urllib.parse import urlparse
  | from socketIO_client import SocketIO

Solve:

__init__(self, connection):
  ...
  <current connect functionality/server lookup>
  self.initalize()
zacharyhooker commented 7 years ago

The config, including the message router config, should be defined separate from the run.py/sample.run.py.

Currently inside of the cybot class:

route = {
    'imdbot':
    {
    'perds': '\[([^\s]+) [0-9]+ :perdgive: #!# ([0-9]*)',
    'jumble': 'word: (.*)\]'
    }
}

Config may possibly be *.py. YAML multidimensional arrays (for routing) are not as readable as a json config or just a dict, as it currently is.

zacharyhooker commented 7 years ago

Config, including routing, has been removed from the class definition and boxed into the config.py file. Currently it has been expanded to look like:

    'username': 'username',
    'password': 'password',
    'channel': 'channel',
    'route': {
        'imdbot':
        {
            'perds': '\[([^\s]+) [0-9]+ :perdgive: #!# ([0-9]*)',
            'jumble': 'word: (.*)\]'
        }
    },
    'response': {
        'catboy': 'Meow, meow. Meow. <3 %s',
        'bdizzle': 'Please no.',
        'generic':
        [
            'I love you %s! -%s',
            '%s is the best. -%s',
            '%s: Thanks for everything, %s.'
        ]
    }
}

The config is currently in python dict and list format. Still need to pull the namespace and connection configuration out of the same file.

zacharyhooker commented 7 years ago

The project has now been wrapped in a package. The config.py will contain the different setups for connections. Currently config.py contains a configuration helper for Cytube, but others can be added to allow for other connection types.

The *.config.py files are built out -- but the config needs to be better parsed in the bot itself.

Eg:

if 'tmdbapi' in config:
    tmdb.API_KEY = config['tmdbapi']
if 'giphyapi' in config:
    self.giphy = giphypop.Giphy(api_key=config['giphyapi'])

However, this issue can be closed -- the config has been pulled out of the main class but is still used in the module.