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?
Pokedex-ChatBot/PokedexCodeWithDisc.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
230 lines (197 sloc)
8.6 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
from gspread import * #not my code | |
from oauth2client.service_account import ServiceAccountCredentials #not my code | |
from GeneralOutputFixForDisc import * | |
from GeneralInput import * | |
from GeneralInputAnalysis import * | |
from PokemonTweet import * #not my code | |
from SQLite import * #not my code | |
import discord #not my code | |
from discord.ext import commands #not my code | |
scope = ["https://spreadsheets.google.com/feeds", #not my code | |
"https://www.googleapis.com/auth/drive.file", | |
"https://www.googleapis.com/auth/drive", | |
"https://www.googleapis.com/auth/spreadsheets.readonly", | |
"https://www.googleapis.com/auth/spreadsheets", | |
"https://www.googleapis.com/auth/drive.readonly"] | |
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope) #not my code | |
client =authorize(creds) | |
shet1 = client.open("PDB").worksheet('sheet1') #not my code | |
nameList=shet1.col_values(2) | |
FileLenght=len(nameList) | |
client = discord.Client() #not my code | |
@client.event #not my code | |
async def on_ready(): #not my code | |
print("The bot is ready.") #not my code | |
def searchName(infoList): | |
foundPokemons=False | |
pokemonInfoList=[] | |
allinfo=True | |
for i in infoList[7]: | |
i=i.capitalize() | |
if i in nameList: | |
cell=shet1.find(i) | |
y=cell.row | |
foundPokemons=True | |
if infoList[9] == True: | |
a="ID: "+str(shet1.cell(y, 1).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
if infoList[0] == True: | |
b=str(shet1.cell(y, 4).value) | |
b=len(b) | |
if b==False: | |
a="Type: "+str(shet1.cell(y, 3).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
elif b==True : | |
a="Type1: "+str(shet1.cell(y, 3).value) | |
pokemonInfoList.append(a) | |
a="Type2: "+str(shet1.cell(y, 4).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
if Weight == True: | |
a="Weight: "+str(shet1.cell(y, 5).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
if Description == True: | |
a="Description: "+str(shet1.cell(y, 6).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
if GoodAgainst == True: | |
a="Good Against: "+str(shet1.cell(y, 7).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
if BadAgainst == True: | |
a="Bad Against: "+str(shet1.cell(y, 8).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
if allinfo==True : | |
a="ID: "+str(shet1.cell(y, 1).value) | |
pokemonInfoList.append(a) | |
b=str(shet1.cell(y, 4).value) | |
b=len(b) | |
if b==False: | |
a="Type: "+str(shet1.cell(y, 3).value) | |
pokemonInfoList.append(a) | |
allinfo=False | |
else: | |
a="Type1: "+str(shet1.cell(y, 3).value) | |
pokemonInfoList.append(a) | |
a="Type2: "+str(shet1.cell(y, 4).value) | |
pokemonInfoList.append(a) | |
a="Weight: "+str(shet1.cell(y, 5).value) | |
pokemonInfoList.append(a) | |
a="Description: "+str(shet1.cell(y, 6).value) | |
pokemonInfoList.append(a) | |
a="Good Against: "+str(shet1.cell(y, 7).value) | |
pokemonInfoList.append(a) | |
a="Bad Against: "+str(shet1.cell(y, 8).value) | |
pokemonInfoList.append(a) | |
returnlist=[pokemonInfoList,foundPokemons] | |
return returnlist | |
def howManyTypePokemon(pokemonType): | |
howManyFound=0 | |
howManyFound1=0 | |
columb1=shet1.col_values(3) | |
columb2=shet1.col_values(4) | |
a=len(columb1)-len(columb2) | |
pokemonType.append("") | |
for i in range(a): | |
columb2.append("") | |
for y in range(0,FileLenght): | |
if pokemonType[0] == columb1[y] or pokemonType[0] == columb2[y]: | |
if len(pokemonType[1])>0: | |
if pokemonType[1] == columb1[y] or pokemonType[1] == columb2[y]: | |
howManyFound1=howManyFound1+1 | |
else: | |
howManyFound+=1 | |
if len(pokemonType[1])>0: | |
howManyFound=howManyFound1 | |
returnlist=[howManyFound] | |
return returnlist | |
def searchType(pokemonType,numberOfPokemons): | |
columb1=shet1.col_values(3) | |
columb2=shet1.col_values(4) | |
pokemonType.append("") | |
a=len(columb1)-len(columb2) | |
for i in range(a): | |
columb2.append("") | |
pokemonInfoList=[] | |
for y in range(0,FileLenght): | |
if pokemonType[0] == columb1[y] or pokemonType[0] == columb2[y]: | |
if len(pokemonType[1])>0: | |
if pokemonType[1]== columb1[y]or pokemonType[1]== columb2[y]: | |
numberOfPokemons-=1 | |
if numberOfPokemons>=0: | |
pokemonInfoList.append(nameList[y]) | |
else: | |
break | |
else: | |
numberOfPokemons-=1 | |
if numberOfPokemons>=0: | |
pokemonInfoList.append(nameList[y]) | |
else: | |
break | |
return pokemonInfoList | |
def allTrue(): | |
pokemonNameList=[] | |
for y in range(0,FileLenght): | |
print(shet1.cell(y, 2).value) | |
pokemonNameList.append(shet1.cell(y, 2).value) | |
return pokemonNameList | |
@client.event #not my code | |
async def on_message(message): #not my code | |
work=True | |
question=str(message.content) | |
if "$" in message.content: | |
work=False | |
if work==True: | |
if ("news" in question) or ("News" in question): | |
await message.channel.send("$" + pokemon_tweet(1)) | |
question="type" | |
infoList=[] | |
a=inputFunction(question) | |
infoList=inputBreakdown(a[0]) | |
b=a[1] | |
d=infoList[1] | |
infoList=infoList[0] | |
a=searchName(infoList) | |
g=a[0] | |
c=a[1] | |
a=g | |
if c==False: | |
if infoList[8]==True: | |
infoList[6]=FileLenght | |
#[types0,amount1,best2,worst3,speciaType4,specialTypeRequest5,reqNumber6,wordList7,All8,number9] | |
if infoList[4]==True: | |
if infoList[2]==False: | |
if infoList[3]==False: | |
if infoList[1]==True: | |
a=howManyTypePokemon(infoList[5]) | |
else: | |
a=searchType(infoList[5],infoList[6]) | |
elif infoList[3]==True: | |
a=BestPokemon(False,infoList[6],infoList[5]) | |
elif infoList[2]==True: | |
a=BestPokemon(True,infoList[6],infoList[5]) | |
else: | |
if infoList[0]==False: | |
if infoList[1]==False: | |
if infoList[9]==False: | |
if infoList[2]==False: | |
if infoList[3]==False: | |
if infoList[8]==True: | |
a=nameList | |
else: | |
a=[] | |
for i in range(infoList[6]): | |
a.append(nameList[i+1]) | |
else: | |
if infoList[8]==True: | |
a=[] | |
a.append(len(nameList)) | |
outString=outputFuncktion(a,b,infoList,c,d) | |
await message.channel.send("$"+outString) | |
if message.author == client.user: #not my code | |
return #not my code | |
client.run("API_KEY") #not my code |