Commit 8e9b1ef6 authored by NanoDano's avatar NanoDano

Removing bitcoin command, cleaning up code tiny bit

parent cb058c57
......@@ -4,11 +4,10 @@ import pkg_resources
from discord.ext import commands
import asyncio
import aiml
import requests
STARTUP_FILE = "std-startup.xml"
BOT_PREFIX = '?'
BOT_PREFIX = ('?', '!')
class ChattyCathy:
......@@ -19,14 +18,13 @@ class ChattyCathy:
# Load AIML kernel
self.aiml_kernel = aiml.Kernel()
initial_dir = os.getcwd()
os.chdir(pkg_resources.resource_filename(__name__, '')) # Change directories to load AIML files properly
os.chdir(pkg_resources.resource_filename(__name__, '')) # Change directories to load AIML files properly
startup_filename = pkg_resources.resource_filename(__name__, STARTUP_FILE)
self.aiml_kernel.learn(startup_filename)
self.aiml_kernel.respond("LOAD AIML B")
os.chdir(initial_dir)
# Set up Discord client
self.discord_client = discord.Client()
self.discord_client = commands.Bot(command_prefix=BOT_PREFIX)
self.setup()
......@@ -46,6 +44,10 @@ class ChattyCathy:
if message.author.bot or str(message.channel) != self.channel_name:
return
if message.content is None:
print("Empty message received.")
return
print("Message: " + str(message.content))
if message.content.startswith(BOT_PREFIX):
......@@ -55,15 +57,5 @@ class ChattyCathy:
aiml_response = self.aiml_kernel.respond(message.content)
yield from self.discord_client.send_message(message.channel, aiml_response)
@self.discord_client.command(pass_context=True)
@asyncio.coroutine
def bitcoin(context):
"""Get the current Bitcoin price"""
# Get the BTC price from CoinDesk
bitcoin_price_url = 'https://api.coindesk.com/v1/bpi/currentprice/BTC.json'
data = requests.get(bitcoin_price_url).json()
price_in_usd = data['bpi']['USD']['rate']
yield from self.discord_client.say("Bitcoin is currently worth $" + price_in_usd + " USD.")
def run(self):
self.discord_client.run(self.token)
......@@ -2,7 +2,7 @@ from setuptools import setup
setup(
name='cathy',
version='1.0.0',
version='1.0.2',
description='Discord chat bot using AIML artificial intelligence.',
url='https://github.com/DevDungeon/ChattyCathy',
author='DevDungeon',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment