Testing/CI #21
+2
-1
@@ -5,10 +5,11 @@ tijd/
|
||||
test.png
|
||||
UpgradeLog\.htm
|
||||
markov_dict.npy
|
||||
stroopwafel.ini
|
||||
*.ini
|
||||
Stroopwafel.sln
|
||||
Stroopwafel.pyproj
|
||||
*.txt
|
||||
!requirements.txt
|
||||
*.sh
|
||||
*.npy
|
||||
.env
|
||||
|
||||
+3
-3
@@ -18,8 +18,8 @@ class General(commands.Cog):
|
||||
self.muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
||||
self.r = praw.Reddit(
|
||||
user_agent='StroopwafelBot',
|
||||
client_secret=self.bot.tokens["redditSecret"],
|
||||
client_id=self.bot.tokens["redditId"]
|
||||
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
||||
client_id=os.getenv("STROOP_REDDIT_ID")
|
||||
)
|
||||
self.r.read_only = True
|
||||
|
||||
@@ -137,7 +137,7 @@ Namens de directie van Stroopwafel B.V. onze excuses voor dit ongemak.""")
|
||||
@asyncio.coroutine
|
||||
def reboot(self, ctx, password=""):
|
||||
""" Reboot.. """
|
||||
if password == self.bot.passwords["resetpassword"]:
|
||||
if password == os.getenv("STROOP_RESET_PASSWORD"):
|
||||
yield from ctx.channel.send("Rebooting.. brb!")
|
||||
os.execv(sys.executable, ['python3'] + sys.argv)
|
||||
else:
|
||||
|
||||
@@ -5,6 +5,7 @@ from pprint import pprint
|
||||
import time
|
||||
import numpy as np
|
||||
import random
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
class Points(commands.Cog):
|
||||
@@ -264,7 +265,7 @@ class Points(commands.Cog):
|
||||
np.save("pointscount.npy", pointsCount)
|
||||
|
||||
# Add new/unknown members:
|
||||
list_channel = self.bot.get_channel(self.bot.hdChannels["shitpost"])
|
||||
list_channel = self.bot.get_channel(int(os.getenv('STROOP_CHANNEL_SHITPOST')))
|
||||
memberList = list_channel.members if list_channel else []
|
||||
for member in memberList:
|
||||
# Give new members 100 points
|
||||
|
||||
+9
-9
@@ -27,7 +27,7 @@ class Shitpost(commands.Cog):
|
||||
'knoeier','sufferd','slaapkop','onbenul','enorme nerf herder','geinponem',
|
||||
'clownsfiguur','krotenkoker','hansworst','grappenmaker','flapdrol','oen',
|
||||
'achterlijk gebakje','demente dibbes','geitenbreier','koekwous','sufkop']
|
||||
self.caldav_client = caldav.DAVClient(url=self.bot.tokens['caldav_url'])
|
||||
self.caldav_client = caldav.DAVClient(url=os.getenv('STROOP_CALDAV_HOST'))
|
||||
|
||||
def __check(self, ctx): #Todo: Is dit het shitpost kanaal?
|
||||
return True
|
||||
@@ -218,7 +218,7 @@ class Shitpost(commands.Cog):
|
||||
Ja of Nee.. kom op nou.
|
||||
"""
|
||||
#We halen dit op van de twitter account @gietitaloan die vertrouwen wij als de ultieme waarheid
|
||||
consumer = oauth.Consumer(key=self.bot.tokens["twitterKey"], secret=self.bot.tokens["twitterSecret"])
|
||||
consumer = oauth.Consumer(key=os.getenv('STROOP_TWITTER_KEY'), secret=os.getenv('STROOP_TWITTER_SECRET'))
|
||||
client = oauth.Client(consumer)
|
||||
resp, content = client.request("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=gietitaloan&count=1", "GET")
|
||||
#TODO kijken of resp iets zinnigs teruggeeft.. of iets doen met een try of catch ofzow
|
||||
@@ -266,7 +266,7 @@ class Shitpost(commands.Cog):
|
||||
params = dict(
|
||||
template_id = '78416340', #party hard
|
||||
username = 'Stroopwafel',
|
||||
password = self.bot.passwords["imgflip"],
|
||||
password = os.getenv("STROOP_IMGFLIP_PASSWORD"),
|
||||
text0 = boven,
|
||||
text1 = onder
|
||||
)
|
||||
@@ -291,7 +291,7 @@ class Shitpost(commands.Cog):
|
||||
params = dict(
|
||||
template_id = '112898841', #de marku
|
||||
username = 'Stroopwafel',
|
||||
password = self.bot.passwords["imgflip"],
|
||||
password = os.getenv("STROOP_IMGFLIP_PASSWORD"),
|
||||
text0 = boven,
|
||||
text1 = onder
|
||||
)
|
||||
@@ -317,7 +317,7 @@ class Shitpost(commands.Cog):
|
||||
params = dict(
|
||||
template_id = '93296473', #de eriku
|
||||
username = 'Stroopwafel',
|
||||
password = self.bot.passwords["imgflip"],
|
||||
password = os.getenv('STROOP_IMGFLIP_PASSWORD'),
|
||||
text0 = boven,
|
||||
text1 = onder
|
||||
)
|
||||
@@ -344,7 +344,7 @@ class Shitpost(commands.Cog):
|
||||
params = {
|
||||
'template_id': '121572521', #delfts blauw
|
||||
'username': 'Stroopwafel',
|
||||
'password': self.bot.passwords["imgflip"],
|
||||
'password': os.getenv('STROOP_IMGFLIP_PASSWORD'),
|
||||
'text0': 'dummy0',
|
||||
'text1': 'dummy1',
|
||||
'font': 'arial',
|
||||
@@ -417,7 +417,7 @@ class Shitpost(commands.Cog):
|
||||
params = dict(
|
||||
template_id = '116231806', #de martijn
|
||||
username = 'Stroopwafel',
|
||||
password = self.bot.passwords["imgflip"],
|
||||
password = os.getenv('STROOP_IMGFLIP_PASSWORD'),
|
||||
text0 = boven,
|
||||
text1 = onder
|
||||
)
|
||||
@@ -545,7 +545,7 @@ class Shitpost(commands.Cog):
|
||||
else:
|
||||
v = True
|
||||
|
||||
url = f"http://weerlive.nl/api/json-data-10min.php?key={self.bot.tokens['weerLive']}&locatie={location}"
|
||||
url = f"http://weerlive.nl/api/json-data-10min.php?key={os.getenv('STROOP_WEERLIVE')}&locatie={location}"
|
||||
response = requests.get(url)
|
||||
#Oant Moarn
|
||||
|
||||
@@ -710,7 +710,7 @@ class Shitpost(commands.Cog):
|
||||
|
||||
def watspelenweecht(self):
|
||||
"""Geeft een paar terug, met de titel en omschrijving van het eerstvolgende event uit de kalender"""
|
||||
calendar = self.caldav_client.calendar(url=self.bot.tokens["calendar"]) # refresh kalender
|
||||
calendar = self.caldav_client.calendar(url=os.getenv('STROOP_CALDAV_CAL')) # refresh kalender
|
||||
|
||||
# geen errorchecking hier, de caller doet dat maar gewoon ofzo, yolo
|
||||
events = calendar.date_search(
|
||||
|
||||
+5
-21
@@ -7,14 +7,15 @@ import Cryptocoin
|
||||
import Chatbot
|
||||
import Points
|
||||
import logging
|
||||
import importlib
|
||||
import configparser
|
||||
import base64
|
||||
import dotenv
|
||||
import os
|
||||
|
||||
from discord.ext import commands
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
async def add_cogs(bot):
|
||||
await bot.add_cog(Shitpost.Shitpost(bot))
|
||||
await bot.add_cog(General.General(bot))
|
||||
@@ -28,26 +29,9 @@ intents.members = True
|
||||
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents)
|
||||
|
||||
#Read configuration file:
|
||||
config = configparser.ConfigParser()
|
||||
config.read('stroopwafel.ini')
|
||||
bot.tokens = config["tokens"]
|
||||
bot.hdChannels = {}
|
||||
for channel in config["channels"]: #channelIDs must be integers
|
||||
bot.hdChannels[channel] = int(config["channels"][channel])
|
||||
|
||||
#passwords are base64 encoded, which makes it like 1% safer
|
||||
bot.passwords = {}
|
||||
for pw in config["passwords"]:
|
||||
try:
|
||||
bot.passwords[pw] = (base64.standard_b64decode(config["passwords"][pw])).decode()
|
||||
except:
|
||||
print("Problem with decoding password!")
|
||||
bot.passwords[pw] = config["passwords"][pw]
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
await add_cogs(bot)
|
||||
print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user))
|
||||
|
||||
bot.run(bot.tokens["discordbot"])
|
||||
bot.run(os.getenv("STROOP_DISCORD_TOKEN"))
|
||||
|
||||
@@ -5,3 +5,4 @@ sympy
|
||||
numpy
|
||||
youtube_dl
|
||||
python-ffmpeg
|
||||
python-dotenv
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import unittest
|
||||
import configparser
|
||||
import praw
|
||||
import random
|
||||
import requests
|
||||
import json
|
||||
import dotenv
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
@@ -12,32 +12,13 @@ import General
|
||||
|
||||
class TestGeneral(unittest.TestCase):
|
||||
def setUp(self):
|
||||
config = configparser.ConfigParser()
|
||||
config.read('stroopwafel.ini')
|
||||
self.tokens = config["tokens"]
|
||||
self.r = praw.Reddit(
|
||||
user_agent='StroopwafelBot',
|
||||
client_secret=self.tokens["redditSecret"],
|
||||
client_id=self.tokens["redditId"]
|
||||
)
|
||||
self.r.read_only = True
|
||||
dotenv.load_dotenv()
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
intents.members = True
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents)
|
||||
bot.tokens = self.tokens
|
||||
self.cog = General.General(bot)
|
||||
|
||||
def test_aww(self):
|
||||
# Duplicate code is tijdelijk!!!11one
|
||||
raww = self.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
||||
post = raww.top('month', limit=250)
|
||||
listing = list(post)
|
||||
random.shuffle(listing)
|
||||
post = listing[0]
|
||||
print(post)
|
||||
self.assertIsInstance(post,praw.models.Submission)
|
||||
|
||||
def test_playlist(self):
|
||||
data = self.cog.get_playlist_json()
|
||||
with self.subTest(msg="Reddit doesn't return 200"):
|
||||
@@ -45,4 +26,4 @@ class TestGeneral(unittest.TestCase):
|
||||
with self.subTest(msg="Not a good response"):
|
||||
self.assertIsInstance(data, requests.Response)
|
||||
with self.subTest(msg="Does not convert to json"):
|
||||
self.assertIsInstance(json.loads(data.content), dict)
|
||||
self.assertIsInstance(json.loads(data.content), dict)
|
||||
|
||||
Reference in New Issue
Block a user