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/PokedexCodeBeforeDiscord.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
204 lines (184 sloc)
7.9 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 GeneralOutput import * | |
from GeneralInput import * | |
from GeneralInputAnalysis import * | |
from PokemonTweet import * #Not my code | |
from SQLite import * #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) #creates a namelist | |
FileLenght=len(nameList) #creates an intreger with the lenght of the whole list | |
def searchName(infoList): #searches for a pokemon name and information about it | |
foundPokemons=False | |
pokemonInfoList=[] | |
allinfo=True | |
for i in infoList[7]: #looks through the word list to find names | |
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 | |
reapeat=1 | |
print("Discord turns on") | |
print(pokemon_tweet(1)) #Not my code | |
while reapeat==1: | |
infoList=[] | |
a=inputFunction() | |
if len(a[0])==True: | |
if str(a[0][0])=="exit": | |
break | |
infoList=inputBreakdown(a[0]) | |
b=a[1] | |
d=infoList[1] | |
infoList=infoList[0] | |
name=searchName(infoList) | |
g=name[0] | |
nameExistance=name[1] | |
a=g | |
if nameExistance==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)) | |
outputFuncktion(a,b,infoList,nameExistance,d) |