Removing birb as the site is down and adding youtube
This commit is contained in:
parent
21dd26823f
commit
97b100e0a2
@ -36,10 +36,3 @@ def random_dog_reddit():
|
||||
'zoomies',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def get_birb():
|
||||
return "https://random.birb.pw/img/{}".format(
|
||||
requests.get(
|
||||
'https://random.birb.pw/tweet'
|
||||
).text)
|
@ -8,6 +8,8 @@ then imported into the main bot
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
from urllib import parse, request
|
||||
import re
|
||||
|
||||
import animals
|
||||
import core_utils
|
||||
@ -133,12 +135,6 @@ async def on_message(message):
|
||||
)
|
||||
)
|
||||
|
||||
if message.content.startswith('!birb'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
embed=generate_embed(embed_url=animals.get_birb())
|
||||
)
|
||||
|
||||
if message.content.startswith('!clap'):
|
||||
await client.delete_message(message)
|
||||
await client.send_message(
|
||||
@ -370,104 +366,119 @@ async def on_message(message):
|
||||
embed=generate_embed(embed_url=wallpaper.get_wall(message.content))
|
||||
)
|
||||
|
||||
if message.content.startswith('!minecraft'):
|
||||
# Check permissions
|
||||
if not role_check.docker_permissions(message.author.roles):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"You dont have permission to run docker commands"
|
||||
)
|
||||
return
|
||||
|
||||
if len(message.content.split()) == 1:
|
||||
actions = ['restart', 'status', 'logs', 'map']
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"\nSupported actions:```\n{}```".format(", ".join(actions))
|
||||
)
|
||||
else:
|
||||
docker_client = docker.from_env()
|
||||
try:
|
||||
minecraft_container = docker_client.containers.get('beyondreality')
|
||||
except:
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"The minecraft server is not running"
|
||||
)
|
||||
return
|
||||
if message.content.startswith('!youtube'):
|
||||
query_string = parse.urlencode({'search_query': message.content.split()[1:]})
|
||||
html_content = request.urlopen('http://www.youtube.com/results?' + query_string)
|
||||
# print(html_content.read().decode())
|
||||
search_results = re.findall('href=\"\\/watch\\?v=(.{11})', html_content.read().decode())
|
||||
print(search_results)
|
||||
# I will put just the first result, you can loop the response to show more results
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
'https://www.youtube.com/watch?v=' + search_results[0]
|
||||
)
|
||||
|
||||
# Figure out what action they want to take
|
||||
action = message.content.split()[1]
|
||||
if action == 'restart':
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"{}, restart the server? [!yes/!no]".format(
|
||||
message.author.mention)
|
||||
)
|
||||
|
||||
confirm_restart = await client.wait_for_message(
|
||||
author=message.author,
|
||||
channel=message.channel,
|
||||
content='!yes'
|
||||
)
|
||||
|
||||
if confirm_restart:
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"Sending restart action to {} server".format(
|
||||
minecraft_container.name
|
||||
)
|
||||
)
|
||||
# if message.content.startswith('!minecraft'):
|
||||
# # Check permissions
|
||||
# if not role_check.docker_permissions(message.author.roles):
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "You dont have permission to run docker commands"
|
||||
# )
|
||||
# return
|
||||
|
||||
minecraft_container.restart()
|
||||
# if len(message.content.split()) == 1:
|
||||
# actions = ['restart', 'status', 'logs', 'map']
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "\nSupported actions:```\n{}```".format(", ".join(actions))
|
||||
# )
|
||||
# else:
|
||||
# docker_client = docker.from_env()
|
||||
# try:
|
||||
# minecraft_container = docker_client.containers.get('beyondreality')
|
||||
# except:
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "The minecraft server is not running"
|
||||
# )
|
||||
# return
|
||||
|
||||
if action == 'status':
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"{} server is {}".format(
|
||||
minecraft_container.name,
|
||||
minecraft_container.status
|
||||
)
|
||||
)
|
||||
# # Figure out what action they want to take
|
||||
# action = message.content.split()[1]
|
||||
# if action == 'restart':
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "{}, restart the server? [!yes/!no]".format(
|
||||
# message.author.mention)
|
||||
# )
|
||||
|
||||
if action == 'logs':
|
||||
if len(message.content.split()) == 3:
|
||||
num_lines = int(message.content.split()[2])
|
||||
else:
|
||||
num_lines = 10
|
||||
# confirm_restart = await client.wait_for_message(
|
||||
# author=message.author,
|
||||
# channel=message.channel,
|
||||
# content='!yes'
|
||||
# )
|
||||
|
||||
log_stream = minecraft_container.logs(
|
||||
tail=num_lines
|
||||
).decode('utf-8')
|
||||
# if confirm_restart:
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "Sending restart action to {} server".format(
|
||||
# minecraft_container.name
|
||||
# )
|
||||
# )
|
||||
|
||||
if len(log_stream) >= num_lines:
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"Pulling last {} lines from the {} server ".format(
|
||||
num_lines,
|
||||
minecraft_container.name
|
||||
)
|
||||
)
|
||||
# minecraft_container.restart()
|
||||
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"```{}```".format(
|
||||
minecraft_container.logs(
|
||||
tail=num_lines
|
||||
).decode('utf-8')
|
||||
)
|
||||
)
|
||||
# if action == 'status':
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "{} server is {}".format(
|
||||
# minecraft_container.name,
|
||||
# minecraft_container.status
|
||||
# )
|
||||
# )
|
||||
|
||||
else:
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"There arent {} lines of output yet".format(num_lines)
|
||||
)
|
||||
if action == 'map':
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"https://luker.gq/minecraft"
|
||||
)
|
||||
# if action == 'logs':
|
||||
# if len(message.content.split()) == 3:
|
||||
# num_lines = int(message.content.split()[2])
|
||||
# else:
|
||||
# num_lines = 10
|
||||
|
||||
# log_stream = minecraft_container.logs(
|
||||
# tail=num_lines
|
||||
# ).decode('utf-8')
|
||||
|
||||
# if len(log_stream) >= num_lines:
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "Pulling last {} lines from the {} server ".format(
|
||||
# num_lines,
|
||||
# minecraft_container.name
|
||||
# )
|
||||
# )
|
||||
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "```{}```".format(
|
||||
# minecraft_container.logs(
|
||||
# tail=num_lines
|
||||
# ).decode('utf-8')
|
||||
# )
|
||||
# )
|
||||
|
||||
# else:
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "There arent {} lines of output yet".format(num_lines)
|
||||
# )
|
||||
# if action == 'map':
|
||||
# await client.send_message(
|
||||
# message.channel,
|
||||
# "https://luker.gq/minecraft"
|
||||
# )
|
||||
|
||||
|
||||
client.run(os.getenv('token'))
|
||||
|
@ -17,10 +17,6 @@ def get_help_message(method):
|
||||
'Returns the avatar for the mentioned user',
|
||||
'\nUsage: !avatar @somebody'
|
||||
],
|
||||
'birb': [
|
||||
'Sends an image of a birb',
|
||||
'\nUsage: !birb'
|
||||
],
|
||||
'clap': [
|
||||
'Returns the shittiest meme created by sassy girls on twitter this century',
|
||||
'Usage: !clap some text to be meme\'mt'
|
||||
@ -139,13 +135,17 @@ def get_help_message(method):
|
||||
'\nUsage: !tts who watches the watchmen?',
|
||||
'\nTo list all languages, you can type `!tts langs`'
|
||||
],
|
||||
'youtube': [
|
||||
'Searches youtube for the query string and returns the first result',
|
||||
'\nUsage: !youtube sick bmx tricks'
|
||||
],
|
||||
}
|
||||
|
||||
return "```css\n{}: {}\n```".format(method, ' '.join(supported_methods[method]))
|
||||
|
||||
def get_help_embed(client):
|
||||
categories = {
|
||||
'fun': ['clap', 'birb', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'meme', 'homepage', 'pout', 'roll', 'smug', 'quake'],
|
||||
'fun': ['clap', 'youtube', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'meme', 'homepage', 'pout', 'roll', 'smug', 'quake'],
|
||||
'util': ['8ball', 'decide', 'icon', 'wallpaper', 'weather', 'stock', 'tts', 'issue'],
|
||||
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
|
||||
'admin': ['emoji', 'cleanup']
|
||||
|
Loading…
x
Reference in New Issue
Block a user