Testing/CI #21
+2
-1
@@ -5,10 +5,11 @@ tijd/
|
|||||||
test.png
|
test.png
|
||||||
UpgradeLog\.htm
|
UpgradeLog\.htm
|
||||||
markov_dict.npy
|
markov_dict.npy
|
||||||
stroopwafel.ini
|
*.ini
|
||||||
Stroopwafel.sln
|
Stroopwafel.sln
|
||||||
Stroopwafel.pyproj
|
Stroopwafel.pyproj
|
||||||
*.txt
|
*.txt
|
||||||
!requirements.txt
|
!requirements.txt
|
||||||
*.sh
|
*.sh
|
||||||
*.npy
|
*.npy
|
||||||
|
.env
|
||||||
|
|||||||
+3
-3
@@ -18,8 +18,8 @@ class General(commands.Cog):
|
|||||||
self.muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
self.muzak_url = 'https://hdcon-muzak.herokuapp.com'
|
||||||
self.r = praw.Reddit(
|
self.r = praw.Reddit(
|
||||||
user_agent='StroopwafelBot',
|
user_agent='StroopwafelBot',
|
||||||
client_secret=self.bot.tokens["redditSecret"],
|
client_secret=os.getenv("STROOP_REDDIT_SECRET"),
|
||||||
client_id=self.bot.tokens["redditId"]
|
client_id=os.getenv("STROOP_REDDIT_ID")
|
||||||
)
|
)
|
||||||
self.r.read_only = True
|
self.r.read_only = True
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ Namens de directie van Stroopwafel B.V. onze excuses voor dit ongemak.""")
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def reboot(self, ctx, password=""):
|
def reboot(self, ctx, password=""):
|
||||||
""" Reboot.. """
|
""" Reboot.. """
|
||||||
if password == self.bot.passwords["resetpassword"]:
|
if password == os.getenv("STROOP_RESET_PASSWORD"):
|
||||||
yield from ctx.channel.send("Rebooting.. brb!")
|
yield from ctx.channel.send("Rebooting.. brb!")
|
||||||
os.execv(sys.executable, ['python3'] + sys.argv)
|
os.execv(sys.executable, ['python3'] + sys.argv)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from pprint import pprint
|
|||||||
import time
|
import time
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import random
|
import random
|
||||||
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
class Points(commands.Cog):
|
class Points(commands.Cog):
|
||||||
@@ -264,7 +265,7 @@ class Points(commands.Cog):
|
|||||||
np.save("pointscount.npy", pointsCount)
|
np.save("pointscount.npy", pointsCount)
|
||||||
|
|
||||||
# Add new/unknown members:
|
# 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 []
|
memberList = list_channel.members if list_channel else []
|
||||||
for member in memberList:
|
for member in memberList:
|
||||||
# Give new members 100 points
|
# Give new members 100 points
|
||||||
|
|||||||
+9
-9
@@ -27,7 +27,7 @@ class Shitpost(commands.Cog):
|
|||||||
'knoeier','sufferd','slaapkop','onbenul','enorme nerf herder','geinponem',
|
'knoeier','sufferd','slaapkop','onbenul','enorme nerf herder','geinponem',
|
||||||
'clownsfiguur','krotenkoker','hansworst','grappenmaker','flapdrol','oen',
|
'clownsfiguur','krotenkoker','hansworst','grappenmaker','flapdrol','oen',
|
||||||
'achterlijk gebakje','demente dibbes','geitenbreier','koekwous','sufkop']
|
'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?
|
def __check(self, ctx): #Todo: Is dit het shitpost kanaal?
|
||||||
return True
|
return True
|
||||||
@@ -218,7 +218,7 @@ class Shitpost(commands.Cog):
|
|||||||
Ja of Nee.. kom op nou.
|
Ja of Nee.. kom op nou.
|
||||||
"""
|
"""
|
||||||
#We halen dit op van de twitter account @gietitaloan die vertrouwen wij als de ultieme waarheid
|
#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)
|
client = oauth.Client(consumer)
|
||||||
resp, content = client.request("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=gietitaloan&count=1", "GET")
|
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
|
#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(
|
params = dict(
|
||||||
template_id = '78416340', #party hard
|
template_id = '78416340', #party hard
|
||||||
username = 'Stroopwafel',
|
username = 'Stroopwafel',
|
||||||
password = self.bot.passwords["imgflip"],
|
password = os.getenv("STROOP_IMGFLIP_PASSWORD"),
|
||||||
text0 = boven,
|
text0 = boven,
|
||||||
text1 = onder
|
text1 = onder
|
||||||
)
|
)
|
||||||
@@ -291,7 +291,7 @@ class Shitpost(commands.Cog):
|
|||||||
params = dict(
|
params = dict(
|
||||||
template_id = '112898841', #de marku
|
template_id = '112898841', #de marku
|
||||||
username = 'Stroopwafel',
|
username = 'Stroopwafel',
|
||||||
password = self.bot.passwords["imgflip"],
|
password = os.getenv("STROOP_IMGFLIP_PASSWORD"),
|
||||||
text0 = boven,
|
text0 = boven,
|
||||||
text1 = onder
|
text1 = onder
|
||||||
)
|
)
|
||||||
@@ -317,7 +317,7 @@ class Shitpost(commands.Cog):
|
|||||||
params = dict(
|
params = dict(
|
||||||
template_id = '93296473', #de eriku
|
template_id = '93296473', #de eriku
|
||||||
username = 'Stroopwafel',
|
username = 'Stroopwafel',
|
||||||
password = self.bot.passwords["imgflip"],
|
password = os.getenv('STROOP_IMGFLIP_PASSWORD'),
|
||||||
text0 = boven,
|
text0 = boven,
|
||||||
text1 = onder
|
text1 = onder
|
||||||
)
|
)
|
||||||
@@ -344,7 +344,7 @@ class Shitpost(commands.Cog):
|
|||||||
params = {
|
params = {
|
||||||
'template_id': '121572521', #delfts blauw
|
'template_id': '121572521', #delfts blauw
|
||||||
'username': 'Stroopwafel',
|
'username': 'Stroopwafel',
|
||||||
'password': self.bot.passwords["imgflip"],
|
'password': os.getenv('STROOP_IMGFLIP_PASSWORD'),
|
||||||
'text0': 'dummy0',
|
'text0': 'dummy0',
|
||||||
'text1': 'dummy1',
|
'text1': 'dummy1',
|
||||||
'font': 'arial',
|
'font': 'arial',
|
||||||
@@ -417,7 +417,7 @@ class Shitpost(commands.Cog):
|
|||||||
params = dict(
|
params = dict(
|
||||||
template_id = '116231806', #de martijn
|
template_id = '116231806', #de martijn
|
||||||
username = 'Stroopwafel',
|
username = 'Stroopwafel',
|
||||||
password = self.bot.passwords["imgflip"],
|
password = os.getenv('STROOP_IMGFLIP_PASSWORD'),
|
||||||
text0 = boven,
|
text0 = boven,
|
||||||
text1 = onder
|
text1 = onder
|
||||||
)
|
)
|
||||||
@@ -545,7 +545,7 @@ class Shitpost(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
v = True
|
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)
|
response = requests.get(url)
|
||||||
#Oant Moarn
|
#Oant Moarn
|
||||||
|
|
||||||
@@ -710,7 +710,7 @@ class Shitpost(commands.Cog):
|
|||||||
|
|
||||||
def watspelenweecht(self):
|
def watspelenweecht(self):
|
||||||
"""Geeft een paar terug, met de titel en omschrijving van het eerstvolgende event uit de kalender"""
|
"""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
|
# geen errorchecking hier, de caller doet dat maar gewoon ofzo, yolo
|
||||||
events = calendar.date_search(
|
events = calendar.date_search(
|
||||||
|
|||||||
+5
-21
@@ -7,14 +7,15 @@ import Cryptocoin
|
|||||||
import Chatbot
|
import Chatbot
|
||||||
import Points
|
import Points
|
||||||
import logging
|
import logging
|
||||||
import importlib
|
import dotenv
|
||||||
import configparser
|
import os
|
||||||
import base64
|
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
async def add_cogs(bot):
|
async def add_cogs(bot):
|
||||||
await bot.add_cog(Shitpost.Shitpost(bot))
|
await bot.add_cog(Shitpost.Shitpost(bot))
|
||||||
await bot.add_cog(General.General(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)
|
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
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
await add_cogs(bot)
|
await add_cogs(bot)
|
||||||
print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user))
|
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
|
numpy
|
||||||
youtube_dl
|
youtube_dl
|
||||||
python-ffmpeg
|
python-ffmpeg
|
||||||
|
python-dotenv
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import configparser
|
|
||||||
import praw
|
import praw
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
import dotenv
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@@ -12,32 +12,13 @@ import General
|
|||||||
|
|
||||||
class TestGeneral(unittest.TestCase):
|
class TestGeneral(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
config = configparser.ConfigParser()
|
dotenv.load_dotenv()
|
||||||
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
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
intents.members = True
|
intents.members = True
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents)
|
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)
|
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):
|
def test_playlist(self):
|
||||||
data = self.cog.get_playlist_json()
|
data = self.cog.get_playlist_json()
|
||||||
with self.subTest(msg="Reddit doesn't return 200"):
|
with self.subTest(msg="Reddit doesn't return 200"):
|
||||||
|
|||||||
Reference in New Issue
Block a user