Skip to content

itsmehemant123/discord-wheatley

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wheatley

Setup

  • Install dependencies with:
pip install -r requirements.txt
  • Create auth.json, and place it inside the config folder. Its content should be:
{
   "token": "<your_token>"
}
  • Create wheatley.json, and place it inside the config folder. Its content should be:
{
  "mongo_database_uri": "mongodb://<uname>:<pwd>@<host>:<port>/<auth_db>",
  "mysql_database_uri": "mysql://<uname>:<pwd>@<host>:<port>/<auth_db>",
  "database": "<db>",
  "database_type": "mongo",
  "corpus-folder": "./corpus/",
  "admin-roles": ["executives", "admins"],
  "max_dialog_length": 500
}

The admin-roles contains the list of roles any of which can issue the train and dwnld commands.

These two files will not be tracked by git, so will not be pushed. Remove their entries from the .gitignore if you want otherwise.

  • To restrict DMs from anyone else but you, replace the <your_id> at L115 in wheatley.py with your discord secret id.

How to run

  • Create the corpus folder in the project root.

  • Run the script with:

python client.py

How to train

  • Download the chat transcripts (in order) by typing this in discord:
!dwnld <limit> #<channel_name>

Where limit can either be all - for all messages, or a number - the number of messages to download.

  • This should start the download and writing of the transcripts to yml files in the corpus folder in order.

  • Issue the train command with:

!train
  • This should start the training. You'll have to keep track with the console output. If using nohup on a server, use the tail -f on the logs to see the live progress.

  • If errors occur while training, its usually with some weird unicode in the yml files. Find out the file name from the error, and fix the error in the file.

  • Once finished, you're done.

Improvements

  • The train command has the chatbot.train, which can be offloaded to a sub-process, and then switch that sub-process' sysout to a buffer/pipe. Now, in the parent process, use the pipe to send it to another parallely running sub-process to print the pipe content to discord (bot.edit_message). This will print out the training process to discord.

  • Improve the chat transcript cleanup before writing to yml.

  • Switch mongo to mysql/postgres.

  • Make the role verification into a function decorator.

  • Make a better reply format other than alternate.