Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
import discord
from discord.ext import commands
import asyncio
import json
from urllib.request import urlopen
from nltk.tokenize import word_tokenize
import requests
from ad_nltk import find_word_synonyms
from ad_geocode import start_locating, cofirmation_status
import os
client = commands.Bot(command_prefix = '.')
TOKEN = 'NTA1Nzc5MjQxNzk1OTc3MjI2.DrdHTw.Y4X-A0MntmN9riVEpaFC55Nv3Wk'
API_key = "AIzaSyDBg2fHi_9lX6uo-6YkzRFJ_Uo1XAZxh8Q"
place_types = [
"accounting", "airport", "amusement_park", "aquarium", "art_gallery", "atm", "bakery", "bank", "bar",
"beauty_salon", "bicycle_store", "book_store", "bowling_alley", "bus_station", "cafe", "campground",
"car_dealer", "car_rental", "car_repair", "car_wash", "casino", "cemetery", "church", "city_hall",
"clothing_store", "convenience_store", "courthouse", "dentist", "department_store", "doctor", "electrician",
"electronics_store", "embassy", "fire_station", "florist", "funeral_home", "furniture_store", "gas_station", "gym",
"hair_care", "hardware_store", "hindu_temple", "home_goods_store", "hospital", "insurance_agency", "jewelry_store",
"laundry", "lawyer", "library", "liquor_store", "local_government_office", "locksmith", "lodging", "meal_delivery",
"meal_takeaway", "mosque", "movie_rental", "movie_theater", "moving_company", "museum", "night_club", "painter",
"park", "parking", "pet_store", "pharmacy", "physiotherapist", "plumber", "police", "post_office",
"real_estate_agency", "restaurant", "roofing_contractor", "rv_park", "school", "shoe_store", "shopping_mall", "spa",
"stadium", "storage", "store", "subway_station", "supermarket", "synagogue", "taxi_stand", "train_station",
"transit_station", "travel_agency", "veterinary_care", "zoo"
]
counter = 0
great_list = []
for typ in place_types:
synonyms = find_word_synonyms(typ)
counter += 1
syn_list = []
for synonym in synonyms:
syn_list.append(synonym)
great_list.append(list(set(syn_list)))
print(counter)
print(great_list[0])
async def confirmation_to_locate(message, status):
if status == 1:
await start_locating()
elif status == 0:
await client.say("Ok then.")
elif status == 2:
await client.send_message(message.channel, "I don't understand that, please say 'yes' or 'no'.")
confirmation = await client.wait_for_message(author=message.author, channel=message.channel)
confirmation_str = word_tokenize(confirmation.content.lower())
status = confirmation_status(confirmation_str)
await confirmation_to_locate(message, status)
async def check_nearby(message):
try:
f = open("location_data_{0.author.mention}.txt".format(message), "r").read()
json = json.loads(f)
c_address_components = json[0]
c_formatted_address = address_components["formatted_address"]
c_geometry = address_components["geometry"]
c_location = c_geometry["location"]
c_latitude = c_location["lat"]
c_longitude = c_location["lng"]
except:
msg1 = "I don't think your location data file has been created yet, {0.author.mention}.".format(message)
msg2 = "Do you want me to locate you now?"
await client.send_message(message.channel, msg1)
await client.send_message(message.channel, msg2)
confirmation = await client.wait_for_message(author=message.author, channel=message.channel)
status = await confirmation_status(confirmation)
confirmation_to_locate(message, status)
@client.event
async def on_message(message):
msg = word_tokenize(message.content.lower()) #tokenize sentences to make certain words more detectable.
state_counter_1 = 0
state_counter_2 = 0
place_type_1 = []
place_type_2 = []
print(msg)
if message.author == client.user:
return
#need to work on list to make second condition possible.
if "find" in msg:
for token in msg:
if token in place_types:
state_counter_1 += 1
place_type_1.append(token)
else:
for list in great_list:
if token in list:
state_counter_2 += 1
place_type_2.append(token)
else:
pass
print(state_counter_1)
print(state_counter_2)
print(place_type_1)
print(place_type_2)
await check_nearby(message)
@client.event
async def on_ready(jkljlkj):
"""Shows the name and id of the chatbot when it is ready."""
print('------')
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(TOKEN)