Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ChatBot/aiDiscordBot.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (33 sloc)
1.44 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
import requests | |
from discord.ext import commands | |
# Example code from discord.py documentation that I edited for our use, added the change presence function I found within the documentation. | |
bot = commands.Bot(command_prefix='!', description='A bot to help the user choose a car.') | |
@bot.event | |
async def on_ready(): | |
print('Logged in as') | |
print(bot.user.name) | |
print(bot.user.id) | |
activity = discord.Activity(name='You Pick A Car', type=discord.ActivityType.watching) | |
await bot.change_presence(activity=activity) | |
bot.remove_command('help') | |
# End of example code from discord.py documentation that I edited. | |
# Ai api that roshan got working in terminal and I intergrated into our discord bot using the discord documentation. | |
@bot.event | |
async def on_message(message): | |
if message.author == bot.user: | |
return | |
else: | |
x = message.content | |
url = "https://acobot-brainshop-ai-v1.p.rapidapi.com/get" | |
querystring = {"bid": "178", "key": "", "uid": "mashape", "msg": x} | |
headers = { | |
'x-rapidapi-host': "acobot-brainshop-ai-v1.p.rapidapi.com", | |
'x-rapidapi-key': "" | |
} | |
response = requests.request("GET", url, headers=headers, params=querystring) | |
z=len(response.text) | |
y = response.text[8:z-2] | |
await message.channel.send(y) | |
# End of ai api that roshan coded that I intergrated to discord. | |
bot.run('') |