项目作者: Apurer

项目描述 :
Tutorial on how to build simple discord chat bot using discord.py and DialoGPT.
高级语言: Python
项目地址: git://github.com/Apurer/interactive-chat-bot.git
创建时间: 2020-05-03T00:01:14Z
项目社区:https://github.com/Apurer/interactive-chat-bot

开源协议:MIT License

下载


Discord interactive chat bot assembled using discord.py and DialoGPT.

Requirements:

  • Ubuntu terminal
  • Discord account
  • At least 2GB of RAM to run DialoGPT-small model, more if using larger model

Installation of dependencies:

In Ubuntu terminal run following commands.

  1. $ sudo apt-get update
  2. $ sudo apt-get install python3-pip libffi-dev libnacl-dev python3-dev

Change root password (if you know what it is ignore this step).

  1. $ passwd

Create user from which you are going to run bot to not run bot as root.

  1. $ sudo adduser bot
  2. $ su - bot
  3. $ pip3 install -U torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
  4. $ pip3 install -U discord.py
  5. $ pip3 install -U transformers

Alternatively if installation doesn’t work follow instructions from:

Generating Discord Token:

  • Go to https://discordapp.com/developers/applications
  • Click “New Application”
  • Name it whatever you want (i named mine “ai-bot”)
  • Click “Create”
  • Go to “Bot” tab (it’s on the left side under settings)
  • Click “Add Bot”
  • Alert with “ADD A BOT TO THIS APP?” will appear, click “Yes, do it!”
  • Under Token click “Copy” for the next step

Setting up environment variable:

  1. $ echo "export DISCORD_TOKEN=paste_your_token_here" >> ~/.bash_profile
  2. $ source ~/.bash_profile

Adding bot to your server and giving it permissions:

  • Go back to your application view (if you haven’t closed it from step “Generating Discord Token” you can skip sub steps for this bullet)
  • Under “Privileged Gateway Intents” toggle:
    -“MESSAGE CONTENT INTENT” as true
  • Go to OAuth2 tab (it’s on the left side under “General Information”)
  • Under “SCOPES” select:
    • “bot”
  • Under “URL Generator” select:
    • Send Messages
    • Read Message History
  • Go to Bot tab
  • From “GENERATED URL” area copy link
  • Paste copied link into your browser and select server you want to invite bot to
  • Click continue
  • Click Authorize
  • Pass capcha
  • Go to server you invited your bot
  • Depending on your server settings you might have to modify bot role to have permissions to use the channel and read / send messages

Running bot:

  • Go to terminal and run:
    1. $ wget https://raw.githubusercontent.com/Apurer/interactive-chat-bot/master/ai-bot.py
    2. $ python3 ai-bot.py
  • To stop bot from running press: CTRL + C

To run in bot background

  • Go to terminal and run:
    1. $ chmod +x ai-bot.py
    2. $ nohup ~/ai-bot.py &
  • To stop bot from running run command:
    1. $ pkill -f ai-bot.py