initia
This commit is contained in:
commit
1c748308f9
12
.woodpecker.yml
Normal file
12
.woodpecker.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
pipeline:
|
||||||
|
publish-docker-image:
|
||||||
|
image: plugins/kaniko
|
||||||
|
settings:
|
||||||
|
registry: gitea.asdf.cafe
|
||||||
|
repo: gitea.asdf.cafe/abs3nt/lmgtfy-bot
|
||||||
|
tags: latest
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
username:
|
||||||
|
from_secret: DOCKER_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: DOCKER_PASSWORD
|
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM python:3
|
||||||
|
FROM gorialis/discord.py
|
||||||
|
RUN mkdir -p /usr/src/bot
|
||||||
|
WORKDIR /usr/src/bot
|
||||||
|
COPY . .
|
||||||
|
CMD [ "python3", "bot.py" ]
|
60
bot.py
Normal file
60
bot.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import sys
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
import discord
|
||||||
|
import os
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
|
||||||
|
|
||||||
|
class LMGTFYBot(commands.Bot):
|
||||||
|
def __init__(self):
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
command_prefix=commands.when_mentioned_or('!'),
|
||||||
|
intents=intents
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_ready(self):
|
||||||
|
print(f'Logged in as {self.user})')
|
||||||
|
print('------')
|
||||||
|
|
||||||
|
|
||||||
|
class LMGTFY(discord.ui.View):
|
||||||
|
def __init__(self, query: str):
|
||||||
|
super().__init__()
|
||||||
|
query = quote_plus(query)
|
||||||
|
search_url = f'https://lmgtfy.asdf.cafe/?search={query}'
|
||||||
|
self.add_item(discord.ui.Button(
|
||||||
|
label='Google Search',
|
||||||
|
url=search_url)
|
||||||
|
)
|
||||||
|
self.add_item(discord.ui.Button(
|
||||||
|
label='Feeling Lucky',
|
||||||
|
url=search_url+"&lucky=true")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
bot = LMGTFYBot()
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
async def lmgtfy(ctx: commands.Context, search: str | None):
|
||||||
|
if search is None:
|
||||||
|
if ctx.message.reference is None:
|
||||||
|
return
|
||||||
|
if ctx.message.reference.message_id is None:
|
||||||
|
return
|
||||||
|
repl = await ctx.fetch_message(ctx.message.reference.message_id)
|
||||||
|
await repl.reply('I will do it for you :)', view=LMGTFY(repl.content))
|
||||||
|
if search is not None:
|
||||||
|
await ctx.reply('I will do it for you :)', view=LMGTFY(search))
|
||||||
|
return
|
||||||
|
|
||||||
|
TOKEN = os.getenv("TOKEN")
|
||||||
|
if TOKEN is None:
|
||||||
|
sys.exit("TOKEN INVALID")
|
||||||
|
|
||||||
|
bot.run(TOKEN)
|
Loading…
Reference in New Issue
Block a user