Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
226 additions
and
118 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import discord | ||
from discord.ext import commands | ||
import geocoder | ||
from predicthq import Client | ||
import datetime | ||
|
||
|
||
class LocationAndWeather: | ||
def __init__(self, client): | ||
self.client = client | ||
|
||
|
||
@commands.command(name = "bot", | ||
description="format: ?bot, gives bots hosting location", | ||
brief="tells the user where the bot is currently being ran from", | ||
pass_context=True) | ||
async def botLocate(self, ctx): | ||
g = geocoder.ip('me') | ||
await self.client.say("```The bot is currently being hosted in: {}```".format(g.city)) | ||
|
||
|
||
@commands.command(name = "locate", | ||
description="format: ?locate [landmark name]', gives landmarks address", | ||
brief="tells the user the location of a place they search for", | ||
pass_context=True) | ||
async def searchPlaceAddress(self, ctx, place): | ||
g = geocoder.bing(place, key='Andk5NRaru9qQy_N3_NR4SsNB6JTfS1wp9MeD_4m1wJs2sYiIJsEGB7Ap97VrH4K') | ||
await self.client.say("```The location is {}```".format(g.address)) | ||
|
||
|
||
@commands.command(name = "coord", | ||
description="format: ?coord [landmark name]', gives landmarks lat and lng", | ||
brief="tells the user the latlng of a place they search for", | ||
pass_context=True) | ||
async def searchPlaceLatlng(self, ctx, place): | ||
g = geocoder.bing(place, key='Andk5NRaru9qQy_N3_NR4SsNB6JTfS1wp9MeD_4m1wJs2sYiIJsEGB7Ap97VrH4K') | ||
await self.client.say("```The location is {}```".format(g.latlng)) | ||
|
||
|
||
@commands.command(name = "event", | ||
description="format: ?event [city] [type of event]', gives landmarks address", | ||
brief="tells the user events happening around the location they enter", | ||
pass_context=True) | ||
async def searchEvents(self, ctx, place, eventType): | ||
output = [] | ||
text = "" | ||
phq = Client(access_token="Ds4t0V0Z71WuXvOyBsm2IFXDZaQxgh") | ||
g = geocoder.bing(place, key='Andk5NRaru9qQy_N3_NR4SsNB6JTfS1wp9MeD_4m1wJs2sYiIJsEGB7Ap97VrH4K') | ||
eventLocation = str('10km@' + str(g.lat) + ',' + str(g.lng)) | ||
for event in phq.events.search(q=eventType, within=eventLocation): | ||
if event.rank > 0: | ||
now = datetime.datetime.now() | ||
eventReverseLnglat = event.location | ||
eventLng = eventReverseLnglat[1] | ||
eventLat = eventReverseLnglat[0] | ||
eventLnglat = str("[" + str(eventLng) + "," + str(eventLat) + "]") | ||
h = geocoder.bing(eventLnglat, method='reverse', key='Andk5NRaru9qQy_N3_NR4SsNB6JTfS1wp9MeD_4m1wJs2sYiIJsEGB7Ap97VrH4K') | ||
if int(now.day) < int(event.start.strftime('%d')): | ||
output.append("Event details: {} - {} - {}".format(event.start.strftime('%d-%m-%Y'), event.title, event.category)) | ||
output.append("Event address: {}".format(h.address)) | ||
output.append("Event score : {}/ 100".format(event.rank)) | ||
output.append("") | ||
for eventdetails in output: | ||
text = text + eventdetails + "\n" | ||
await self.client.say("```{}```".format(text)) | ||
|
||
def setup(client): | ||
client.add_cog(LocationAndWeather(client)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import random | ||
import discord | ||
from discord.ext import commands | ||
import requests | ||
from lxml import html | ||
|
||
class Random: | ||
def __init__(self, client): | ||
self.client = client | ||
|
||
# ahmed's | ||
@commands.command(name="guesscountry", | ||
description="has a list of all countries that have been web scrapped", | ||
brief="randomly says a country", | ||
pass_context=True) | ||
async def guess_country(self, ctx): | ||
page = requests.get('https://en.wikipedia.org/wiki/List_of_countries_by_intentional_homicide_rate') | ||
tree = html.fromstring(page.content) | ||
guesscountry = tree.xpath('//*[@id="mw-content-text"]/div/table[2]/tbody/tr/td[2]/table/tbody/tr/td[1]/a/text()') | ||
await self.client.say("{0} {1}".format(ctx.message.author.mention, random.choice(guesscountry))) | ||
|
||
|
||
# seva's | ||
@commands.command(description="takes a random joke from a list", | ||
brief="says a random joke", | ||
pass_context=True) | ||
async def joke(self, ctx): | ||
"""gives a random joke from the list below""" | ||
jokes = ["Two men walk into a bar. The third one ducks!", | ||
"Why was 6 afraid of 7? Because 7 ate 9!", | ||
"I’m reading an antigravity book It’s impossible to put down!", | ||
"What kind of cheese doesn’t belong to you? Nacho cheese!", | ||
"You can’t trust atoms. They make up everything!", | ||
"Why do mushrooms get invited to all the best parties? Because they are such fungis!"] | ||
await self.client.say("{0} {1}".format(ctx.message.author.mention, random.choice(jokes))) | ||
|
||
|
||
# ahmed's | ||
@commands.command(description="takes a random fact from a list", | ||
brief="says a random fact", | ||
pass_context=True) | ||
async def facts(self, ctx): | ||
"""gives a random fact from the list below""" | ||
facts = ["Banging your head against a wall for one hour burns 150 calories.", | ||
"In Switzerland it is illegal to own just one guinea pig.", | ||
"Pteronophobia is the fear of being tickled by feathers.", | ||
"Snakes can help predict earthquakes.", | ||
"A flock of crows is known as a murder.", | ||
"The oldest 'your mom' joke was discovered on a 3,500 year old Babylonian tablet.", | ||
"So far, two diseases have successfully been eradicated: smallpox and rinderpest.", | ||
"Cherophobia is an irrational fear of fun or happiness.", | ||
"7% of American adults believe that chocolate milk comes from brown cows.", | ||
"If you lift a kangaroo's tail off the ground it can't hop.", | ||
"Bananas are curved because they grow towards the sun.", | ||
"Billy goats urinate on their own heads to smell more attractive to females.", | ||
"The inventor of the Frisbee was cremated and made into a Frisbee after he died.", | ||
"During your lifetime, you will produce enough saliva to fill two swimming pools.", | ||
"If Pinocchio says 'My Nose Will Grow Now', it would cause a paradox.", | ||
"Polar bears could eat as many as 86 penguins in a single sitting...", | ||
"Movie trailers were originally shown after the movie, which is why they were called 'trailers'.", | ||
"An eagle can kill a young deer and fly away with it.", | ||
"Heart attacks are more likely to happen on a Monday.", | ||
"Tennis players are not allowed to swear when they are playing in Wimbledon.", | ||
"In 2017 more people were killed from injuries caused by taking a selfie than by shark attacks.", | ||
"The top six foods that make your fart are beans, corn, bell peppers, cauliflower, cabbage and milk.", | ||
"There is a species of spider called the Hobo Spider.", | ||
"A lion’s roar can be heard from 5 miles away.", | ||
"Saint Lucia is the only country in the world named after a woman.", | ||
"A baby spider is called a spiderling.", | ||
"The United States Navy has started using Xbox controllers for their periscopes.", | ||
"A baby octopus is about the size of a flea when it is born.", | ||
"Scarecrows have been around longer than you might think – the first scarecrows known to history were made about three-thousand-years ago!.", | ||
"The scientific name for brain freeze is sphenopalatine ganglioneuralgia." | ||
"A New Jersey man flunked out of law school and subsequently sued the school for having accepted him in the first place.", | ||
"Toni Morrison was the first African-American woman to receive a Nobel Prize. It was in recognition of her contributions to literature and poetry.", | ||
"Laughing boosts the immune system, burns calories and reduces stress hormones, making it a very healthy activity.", | ||
"Honey is a better cough suppressant than over-the-counter cough suppressants.", | ||
"People are more likely to agree with a statement written in Baskerville than any other font.", | ||
"3 out of 4 Americans use an emoji in text messaging every single day.", | ||
"Due to a genetic defect, cats can’t taste sweet things.", | ||
"According to the Centre for Retail Research, cheese is the most commonly shoplifted food in the world." | ||
] | ||
await self.client.say("{0} {1}".format(ctx.message.author.mention, random.choice(facts))) | ||
|
||
|
||
@commands.command(description="rolls a dice of d4,d6,d8,d10,d12,d20,d100", | ||
brief="rolls a dice of specified sides", | ||
pass_context=True) | ||
async def roll(self, ctx, dice): | ||
"""rolls a dice of sides var dice when specified""" | ||
dicedict={"d4":random.randint(1,4), | ||
"d6":random.randint(1,6), | ||
"d8":random.randint(1,8), | ||
"d10":random.randint(1,10), | ||
"d12":random.randint(1,12), | ||
"d20":random.randint(1,20), | ||
"d100":random.randint(1,100) | ||
} | ||
await self.client.say("{0} you rolled a: {1}".format(ctx.message.author.mention, dicedict[dice])) | ||
|
||
|
||
@commands.command(description="randomly picks a winner from the user list", | ||
brief="randomly picks a winner from the user list", | ||
pass_context=True) | ||
async def giveaway(self, ctx): | ||
memberlist=[] | ||
for member in ctx.message.server.members: | ||
for role in member.roles: | ||
if str(member.status) == "online" and role.name == "User": | ||
memberlist.append(member) | ||
await self.client.say("{} has won the giveaway".format(random.choice(memberlist).mention)) | ||
|
||
|
||
def setup(client): | ||
client.add_cog(Random(client)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import discord | ||
from discord.ext import commands | ||
|
||
class User: | ||
def __init__(self, client): | ||
self.client = client | ||
|
||
# andrew's | ||
@commands.command(description="shows the user info of the person mentioned @user", | ||
brief="shows a users info", | ||
pass_context=True) | ||
async def info(self, ctx, user: discord.Member): | ||
"""shows the user information of the person mentioned""" | ||
await self.client.say("The users name is: {}".format(user.name)) | ||
await self.client.say("The users ID is: {}".format(user.id)) | ||
await self.client.say("The users status is:{}".format(user.status)) | ||
await self.client.say("The user joined at:{}".format(user.joined_at)) | ||
|
||
def setup(client): | ||
client.add_cog(User(client)) |
Oops, something went wrong.