The big security update.

This commit is contained in:
JP
2018-10-21 15:39:17 +02:00
parent 5193489dc9
commit 6a28173ce4
3 changed files with 26 additions and 11 deletions
+2 -2
View File
@@ -37,11 +37,11 @@ class Chatbot(object):
if "DMChannel" in type(message.channel).__name__: #respond to messages in PM channels
yield from self.learnFromMessagesInChannel(message.channel.id, 1)
yield from self.respondToMessage(message)
elif message.channel.id == 139061614178598912: #don't abuse the "belangrijk" channel
elif message.channel.id == self.bot.hdChannels["belangrijk"]: #don't abuse the "belangrijk" channel
pass
else:
a = random.randint(0,999)
if message.channel.id == 137218228953939968 and a < 40: #shitpost channel
if message.channel.id == self.bot.hdChannels["shitpost"] and a < 40: #shitpost channel
yield from self.learnFromMessagesInChannel(message.channel.id, 10)
yield from self.respondToMessage(message)
elif a < 10: #all other channels
+5 -6
View File
@@ -137,8 +137,7 @@ class Shitpost(object):
Ja of Nee.. kom op nou.
"""
#We halen dit op van de twitter account @gietitaloan die vertrouwen wij als de ultieme waarheid
#hahaha geheime tokens in de code hahahaha TODO
consumer = oauth.Consumer(key="eUotijxUEcTVpegNCIzEqz0be", secret="Opj95FAhRkpgVpo61PEJcConvYHgAk7TlouETk2NaSh6dvhCLu")
consumer = oauth.Consumer(key=self.bot.tokens["twitterKey"], secret=self.bot.tokens["twitterSecret"])
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
@@ -166,7 +165,7 @@ class Shitpost(object):
params = dict(
template_id = '112898841', #de marku
username = 'Stroopwafel',
password = 'ruyter118',
password = self.bot.passwords["imgflip"],
text0 = boven,
text1 = onder
)
@@ -192,7 +191,7 @@ class Shitpost(object):
params = dict(
template_id = '93296473', #de eriku
username = 'Stroopwafel',
password = 'ruyter118',
password = self.bot.passwords["imgflip"],
text0 = boven,
text1 = onder
)
@@ -219,7 +218,7 @@ class Shitpost(object):
params = {
'template_id': '121572521', #delfts blauw
'username': 'Stroopwafel',
'password': 'ruyter118',
'password': self.bot.passwords["imgflip"],
'text0': 'dummy0',
'text1': 'dummy1',
'font': 'arial',
@@ -292,7 +291,7 @@ class Shitpost(object):
params = dict(
template_id = '116231806', #de martijn
username = 'Stroopwafel',
password = 'ruyter118',
password = self.bot.passwords["imgflip"],
text0 = boven,
text1 = onder
)
+19 -3
View File
@@ -7,6 +7,8 @@ import Cryptocoin
import Chatbot
import logging
import importlib
import configparser
import base64
from discord.ext import commands
@@ -20,11 +22,25 @@ bot.add_cog(General.General(bot))
bot.add_cog(Cryptocoin.Cryptocoin(bot))
bot.add_cog(Chatbot.Chatbot(bot))
tokenfile = open("stroopwafel.token","r")
token = tokenfile.readline().strip()
#tokenfile = open("stroopwafel.token","r")
#token = tokenfile.readline().strip()
config = configparser.ConfigParser()
config.read('stroopwafel.ini')
bot.tokens = config["tokens"]
bot.hdChannels = config["channels"]
#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
@asyncio.coroutine
def on_ready():
print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user))
bot.run(token)
bot.run(bot.tokens["discordbot"])