commit
bafbd21183
@ -9,22 +9,23 @@
|
|||||||
options:
|
options:
|
||||||
docker: true
|
docker: true
|
||||||
|
|
||||||
|
image: python:3.6.2
|
||||||
pipelines:
|
pipelines:
|
||||||
|
default:
|
||||||
|
- step:
|
||||||
|
script:
|
||||||
|
- echo "Making sure the python actually runs"
|
||||||
|
- pip install docker discord.py pybooru requests pylint
|
||||||
|
- python dragon-bot.py test
|
||||||
|
- export IMAGE_NAME=ldooks/dragon-bot:latest
|
||||||
|
# build the Docker image (this will use the Dockerfile in the root of the repo)
|
||||||
|
- docker build -t $IMAGE_NAME .
|
||||||
branches:
|
branches:
|
||||||
master:
|
master:
|
||||||
- step:
|
- step:
|
||||||
script:
|
script:
|
||||||
- export IMAGE_NAME=ldooks/dragon-bot:latest
|
- export IMAGE_NAME=ldooks/dragon-bot:latest
|
||||||
# build the Docker image (this will use the Dockerfile in the root of the repo)
|
|
||||||
- docker build -t $IMAGE_NAME .
|
|
||||||
# authenticate with the Docker Hub registry
|
# authenticate with the Docker Hub registry
|
||||||
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
|
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
|
||||||
# push the new Docker image to the Docker registry
|
# push the new Docker image to the Docker registry
|
||||||
- docker push $IMAGE_NAME
|
- docker push $IMAGE_NAME
|
||||||
feature/*:
|
|
||||||
- step:
|
|
||||||
script:
|
|
||||||
# Only build iamges, dont push when we're on a feature branch
|
|
||||||
- export IMAGE_NAME=ldooks/dragon-bot:latest
|
|
||||||
# build the Docker image (this will use the Dockerfile in the root of the repo)
|
|
||||||
- docker build -t $IMAGE_NAME .
|
|
@ -1,20 +1,13 @@
|
|||||||
from pybooru import Danbooru
|
import random
|
||||||
import asyncio
|
import sys
|
||||||
|
import requests
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import docker
|
import docker
|
||||||
import json
|
from pybooru import Danbooru
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import random
|
|
||||||
import requests
|
|
||||||
import time
|
|
||||||
|
|
||||||
# Client object
|
# Client object
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
|
|
||||||
botToken = "MzM5NDQ2NTgwMTU3MzQ5ODg4.DFkGYg.z-XD17nFP4rtBq-YsNbOJHuBWfQ" # get from the bot page. must be a bot, not a discord app
|
|
||||||
discord_server_id = '97456282729996288'
|
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print("Dragon bot up and ready to roll.\n")
|
print("Dragon bot up and ready to roll.\n")
|
||||||
@ -113,7 +106,7 @@ async def on_message(message):
|
|||||||
]
|
]
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
"https://reddit.com/r/{}.json?limit=500".format(random.choice(boards)),
|
"https://reddit.com/r/{}.json?limit=500".format(random.choice(boards)),
|
||||||
headers = {'User-agent': 'discord dragon-bot'}
|
headers = {'User-agent':'discord dragon-bot'}
|
||||||
).json()['data']['children']
|
).json()['data']['children']
|
||||||
|
|
||||||
image_urls = list(filter(lambda x: x['data']['domain'] in domains, response))
|
image_urls = list(filter(lambda x: x['data']['domain'] in domains, response))
|
||||||
@ -124,9 +117,20 @@ async def on_message(message):
|
|||||||
if client.user.mentioned_in(message):
|
if client.user.mentioned_in(message):
|
||||||
print('fuck u')
|
print('fuck u')
|
||||||
|
|
||||||
if(message.content.startswith('!help')):
|
if message.content.startswith('!define'):
|
||||||
|
word = message.content.split()[1:]
|
||||||
|
try:
|
||||||
|
definition = requests.get(
|
||||||
|
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
||||||
|
).json()['list'][0]['definition']
|
||||||
|
except IndexError:
|
||||||
|
definition = 'No definition found'
|
||||||
|
await client.send_message(message.channel, "`{}`\n```{}```".format(' '.join(word), definition))
|
||||||
|
|
||||||
|
if message.content.startswith('!help'):
|
||||||
supported_methods = {
|
supported_methods = {
|
||||||
'decide': 'Dragon-bot will help make the tough decisions for you\n!decide option 1 or option 2.\n\nIf only one option, it will give you a yes or no',
|
'decide': 'Dragon-bot will help make the tough decisions for you\n!decide option 1 or option 2.\n\nIf only one option, it will give you a yes or no',
|
||||||
|
'deine': 'Returns a definiton of a word from urban dictionary\n\nUsage: !define loli',
|
||||||
'docker': 'Two supported actions: logs and restart\n\nlogs: Shows you the last X number of lines from the minecraft server. If no number is specified, defaults to 10.\n\nrestart: will restart the minecraft server if something is fucky',
|
'docker': 'Two supported actions: logs and restart\n\nlogs: Shows you the last X number of lines from the minecraft server. If no number is specified, defaults to 10.\n\nrestart: will restart the minecraft server if something is fucky',
|
||||||
'excuse': 'Generates a random excuse you can give your boss',
|
'excuse': 'Generates a random excuse you can give your boss',
|
||||||
'help': 'Prints out a list of everything dragon-bot can do',
|
'help': 'Prints out a list of everything dragon-bot can do',
|
||||||
@ -140,28 +144,25 @@ async def on_message(message):
|
|||||||
if method not in supported_methods.keys():
|
if method not in supported_methods.keys():
|
||||||
await client.send_message(message.channel, "I cant help you with that")
|
await client.send_message(message.channel, "I cant help you with that")
|
||||||
return
|
return
|
||||||
await client.send_message(message.channel,"```{}```".format(supported_methods[method]))
|
await client.send_message(message.channel, "```{}```".format(supported_methods[method]))
|
||||||
else:
|
else:
|
||||||
await client.send_message(message.channel, "I currently have {} methods,\n\n```{}```\n\nYou can get information about a specific method by typing !help <method>".format(len(supported_methods), ', '.join(supported_methods.keys())))
|
await client.send_message(message.channel, "I currently have {} methods,\n\n```{}```\n\nYou can get information about a specific method by typing !help <method>".format(len(supported_methods), ', '.join(supported_methods.keys())))
|
||||||
|
|
||||||
|
|
||||||
if('autis' in message.content):
|
if 'autis' in message.content or message.content.startswith('!triggered'):
|
||||||
await client.send_message(message.channel, 'https://i.imgur.com/g6yOJjp.gif')
|
await client.send_message(message.channel, 'https://i.imgur.com/g6yOJjp.gif')
|
||||||
|
|
||||||
if(message.content.startswith('!triggered')):
|
if message.content.startswith('!excuse'):
|
||||||
await client.send_message(message.channel, 'https://i.imgur.com/g6yOJjp.gif')
|
|
||||||
|
|
||||||
if(message.content.startswith('!excuse')):
|
|
||||||
excuses = requests.get(
|
excuses = requests.get(
|
||||||
'https://gist.githubusercontent.com/AndrewBrinker/6763cdd5d79d6e3eaa3f/raw/624b946ebcca71ac76b74afa5ea41280540c1b97/excuses.txt'
|
'https://gist.githubusercontent.com/AndrewBrinker/6763cdd5d79d6e3eaa3f/raw/624b946ebcca71ac76b74afa5ea41280540c1b97/excuses.txt'
|
||||||
).text.split("\n")
|
).text.split("\n")
|
||||||
await client.send_message(message.channel, random.choice(excuses))
|
await client.send_message(message.channel, random.choice(excuses))
|
||||||
|
|
||||||
if(message.content.startswith('!purge')):
|
if message.content.startswith('!purge'):
|
||||||
deleted = await client.purge_from(message.channel, limit=20, check=is_me)
|
await client.purge_from(message.channel, limit=20, check=is_me)
|
||||||
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
|
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
|
||||||
|
|
||||||
if(message.content.startswith('!decide')):
|
if message.content.startswith('!decide'):
|
||||||
choices = message.content.replace('!decide', '').lstrip().split(' or ')
|
choices = message.content.replace('!decide', '').lstrip().split(' or ')
|
||||||
if len(choices) > 1:
|
if len(choices) > 1:
|
||||||
####### debug ###########
|
####### debug ###########
|
||||||
@ -171,13 +172,13 @@ async def on_message(message):
|
|||||||
else:
|
else:
|
||||||
await client.send_message(message.channel, "{} {}".format(message.author.mention, random.choice(['yes', 'no'])))
|
await client.send_message(message.channel, "{} {}".format(message.author.mention, random.choice(['yes', 'no'])))
|
||||||
|
|
||||||
if(message.content.startswith('!cleanup')) and '144986109804412928' == message.author.id:
|
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':
|
||||||
def is_bot(m):
|
def is_bot(m):
|
||||||
return m.author == client.user
|
return m.author == client.user
|
||||||
deleted = await client.purge_from(message.channel, limit=100, check=is_bot)
|
await client.purge_from(message.channel, limit=100, check=is_bot)
|
||||||
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
|
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
|
||||||
|
|
||||||
if(message.content.startswith('!wallpaper')):
|
if message.content.startswith('!wallpaper'):
|
||||||
url = 'https://source.unsplash.com/3840x2160/'
|
url = 'https://source.unsplash.com/3840x2160/'
|
||||||
if len(message.content.split()) > 1:
|
if len(message.content.split()) > 1:
|
||||||
keyword = message.content.split()[1]
|
keyword = message.content.split()[1]
|
||||||
@ -197,7 +198,7 @@ async def on_message(message):
|
|||||||
###### | | ######
|
###### | | ######
|
||||||
###### +-------------------+ ######
|
###### +-------------------+ ######
|
||||||
###################################
|
###################################
|
||||||
if(message.content.startswith('!lewd')):
|
if message.content.startswith('!lewd'):
|
||||||
if 'nsfw' in message.channel.name:
|
if 'nsfw' in message.channel.name:
|
||||||
if random.randint(0, 100) % 2 == 0:
|
if random.randint(0, 100) % 2 == 0:
|
||||||
await client.send_message(message.channel, "Heres a random image from reddit\n{}".format(get_from_reddit()))
|
await client.send_message(message.channel, "Heres a random image from reddit\n{}".format(get_from_reddit()))
|
||||||
@ -213,7 +214,7 @@ async def on_message(message):
|
|||||||
###### | | ######
|
###### | | ######
|
||||||
###### +-------------------+ ######
|
###### +-------------------+ ######
|
||||||
###################################
|
###################################
|
||||||
if(message.content.startswith('!docker') and (message.author != client.user)):
|
if message.content.startswith('!docker') and (message.author != client.user):
|
||||||
# Check permissions
|
# Check permissions
|
||||||
roles = []
|
roles = []
|
||||||
allowed_roles = ['MOD', 'Greasemonkey', 'Adminimodistrator']
|
allowed_roles = ['MOD', 'Greasemonkey', 'Adminimodistrator']
|
||||||
@ -255,4 +256,10 @@ async def on_message(message):
|
|||||||
else:
|
else:
|
||||||
await client.send_message(message.channel, "There arent {} lines of output yet".format(num_lines))
|
await client.send_message(message.channel, "There arent {} lines of output yet".format(num_lines))
|
||||||
|
|
||||||
client.run(botToken)
|
# Check if there is a command line argument after script
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
print("If you're seeing this, the python compiled")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
token = "MzM5NDQ2NTgwMTU3MzQ5ODg4.DFkGYg.z-XD17nFP4rtBq-YsNbOJHuBWfQ" # get from the bot page. must be a bot, not a discord app
|
||||||
|
client.run(token)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user