now posts random cats
This commit is contained in:
parent
51d38135dd
commit
3f888fff13
Binary file not shown.
|
@ -2,9 +2,12 @@ import discord
|
||||||
import os
|
import os
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
import random
|
||||||
|
|
||||||
class CatBot():
|
class CatBot():
|
||||||
def __init__(self):
|
|
||||||
|
|
||||||
|
def __init__(self, base_url, cats):
|
||||||
load_dotenv("./vars/.env")
|
load_dotenv("./vars/.env")
|
||||||
intents = discord.Intents.all()
|
intents = discord.Intents.all()
|
||||||
client = discord.Client(intents=intents)
|
client = discord.Client(intents=intents)
|
||||||
|
@ -17,8 +20,8 @@ class CatBot():
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
if "marco" in message.content:
|
if "Cat!" in message.content:
|
||||||
await message.channel.send('polo')
|
await message.channel.send(base_url + random.choice(cats))
|
||||||
|
|
||||||
|
|
||||||
bot.run(os.getenv('TOKEN'))
|
bot.run(os.getenv('TOKEN'))
|
5
main.py
5
main.py
|
@ -4,14 +4,15 @@ from bot.catbot import CatBot
|
||||||
from server.server import Server
|
from server.server import Server
|
||||||
|
|
||||||
SERVER_BASE_URL = "https://kaylee.wtf/cats/";
|
SERVER_BASE_URL = "https://kaylee.wtf/cats/";
|
||||||
|
cats = []
|
||||||
|
|
||||||
def run_bot():
|
def run_bot():
|
||||||
global cb
|
global cb
|
||||||
cb = CatBot()
|
cb = CatBot(SERVER_BASE_URL, cats)
|
||||||
|
|
||||||
def run_server():
|
def run_server():
|
||||||
global s
|
global s
|
||||||
s = Server()
|
s = Server(cats)
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,8 +1,6 @@
|
||||||
import time
|
import time
|
||||||
class Server():
|
class Server():
|
||||||
def __init__(self):
|
def __init__(self, cats):
|
||||||
i = 0
|
cats.append("cat1.jpg")
|
||||||
while True:
|
time.sleep(10)
|
||||||
i += 1
|
cats.append("cat2.jpg")
|
||||||
print(i)
|
|
||||||
time.sleep(1)
|
|
Loading…
Reference in New Issue