Exemplo n.º 1
0
#API refrence sheet - http://discordpy.readthedocs.io/en/latest/api.html#client
#bot commands framework https://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html

import gspread
from oauth2client.service_account import ServiceAccountCredentials

#Github documentation for gspread-https://github.com/burnash/gspread
#Good video explaining sheets API - https://www.youtube.com/watch?v=vISRn5qFrkM
#needed installs - pip install gspread oauth2client

#this is from the Discord API and it is the setup that is required for the bot to run
Client = discord.Client()
bot_prefix = "#"
client = commands.Bot(command_prefix=bot_prefix)
myToken = Token()
token = myToken.getToken()
eQuotes = Quote()
aQuotes = eQuotes.getQuotes  #not currently used

today = datetime.datetime.now(
)  #this uses the datetime library to make a variable that is today's date
error = ""  #this is a variable that is used in the add_quote function to keep track of what is formatted incorrectly

#This is the setup that us needed for the google sheets API including a client id for the project and a link to the google sheet
scope = ['http://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name(
    'client_secret.json', scope)
clients = gspread.authorize(creds)
sheet = clients.open_by_url(
    'https://docs.google.com/spreadsheets/d/1tXI_ZYpqUoIuKiPrE4A5UzDKbSTpkw1BvvXf7RU1ofI/edit#gid=0'
).sheet1