Skip to content

Commit

Permalink
Add discord wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
srevinsaju committed Mar 14, 2020
1 parent ba97855 commit dcdd6d9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
1 change: 0 additions & 1 deletion wrappers/discord
Submodule discord deleted from b0e013
1 change: 1 addition & 0 deletions wrappers/discord/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python discord_bot.py
41 changes: 41 additions & 0 deletions wrappers/discord/discord_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# bot.py
import os
import random

import discord
from dotenv import load_dotenv

from sugaroid.sugaroid import Sugaroid

load_dotenv()
token = os.getenv('DISCORD_TOKEN')
sg = Sugaroid()
client = discord.Client()

@client.event
async def on_ready():
print(f'{client.user.name} has connected to Discord!')

@client.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(
f'Hi {member.name}, welcome to my Discord server!'
)

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('<@684746563540484099>') or message.content.startswith('<@!684746563540484099>'):
msg = message.content.replace('<@684746563540484099>', '').replace('<@!684746563540484099>', '')
response = sg.parse(msg)
if len(str(response)) > 1999:
response = str(response)[:1999]
await message.channel.send(response)
else:
print(message.content)


client.run(token)
4 changes: 4 additions & 0 deletions wrappers/discord/nltk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
stopwords
wordnet
vader_lexicon
punkt
11 changes: 11 additions & 0 deletions wrappers/discord/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.5/en_core_web_sm-2.2.5.tar.gz
discord.py
python-dotenv
-e git://github.com/srevinsaju/sugaroid.git#egg=sugaroid
Django
gunicorn
django_heroku
freegames
wikipedia-api
mediawikiapi
git+git://github.com/gunthercox/chatterbot-corpus.git#egg=chatterbot-corpus
1 change: 1 addition & 0 deletions wrappers/discord/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.8.1

0 comments on commit dcdd6d9

Please sign in to comment.