diff --git a/.gitignore b/.gitignore index 7a00c01..04ad9ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +MiRCARTImgurApiKey.py __pycache__/ *.sw[op] diff --git a/IrcMiRCARTBot.py b/IrcMiRCARTBot.py index f4499ff..170d3ee 100755 --- a/IrcMiRCARTBot.py +++ b/IrcMiRCARTBot.py @@ -28,12 +28,14 @@ import json import IrcClient import requests, urllib.request from MiRCARTCanvasImportStore import MiRCARTCanvasImportStore +from MiRCARTImgurApiKey import MiRCARTImgurApiKey from MiRCARTToPngFile import MiRCARTToPngFile class IrcMiRCARTBot(IrcClient.IrcClient): """IRC<->MiRC2png bot""" clientChannelLastMessage = clientChannelOps = clientChannel = None clientChannelRejoin = None + imgurApiKey = MiRCARTImgurApiKey.imgurApiKey # {{{ ContentTooLargeException(Exception): Raised by _urlretrieveReportHook() given download size > 1 MB class ContentTooLargeException(Exception): @@ -154,7 +156,7 @@ class IrcMiRCARTBot(IrcClient.IrcClient): canvasStore.outMap.insert(0, [[1, 1, 0, " "]] * len(canvasStore.outMap[0])) canvasStore.outMap.append([[1, 1, 0, " "]] * len(canvasStore.outMap[0])) MiRCARTToPngFile(canvasStore.outMap, "DejaVuSansMono.ttf", 11).export(imgTmpFilePath) - imgurResponse = self._uploadToImgur(imgTmpFilePath, "MiRCART image", "MiRCART image", "c9a6efb3d7932fd") + imgurResponse = self._uploadToImgur(imgTmpFilePath, "MiRCART image", "MiRCART image", self.imgurApiKey) if imgurResponse[0] == 200: self._log("Uploaded as: {}".format(imgurResponse[1])) self.queue("PRIVMSG", message[2], "8/!\\ Uploaded as: {}".format(imgurResponse[1])) diff --git a/MiRCARTCanvas.py b/MiRCARTCanvas.py index a66cc43..8c9c2c5 100644 --- a/MiRCARTCanvas.py +++ b/MiRCARTCanvas.py @@ -27,6 +27,7 @@ from MiRCARTCanvasJournal import MiRCARTCanvasJournal from MiRCARTCanvasExportStore import MiRCARTCanvasExportStore, haveMiRCARTToPngFile, haveUrllib from MiRCARTCanvasImportStore import MiRCARTCanvasImportStore from MiRCARTCanvasInterface import MiRCARTCanvasInterface +from MiRCARTImgurApiKey import MiRCARTImgurApiKey import wx class MiRCARTCanvas(wx.Panel): @@ -38,6 +39,7 @@ class MiRCARTCanvas(wx.Panel): canvasBackend = canvasJournal = None canvasExportStore = canvasImportStore = None canvasInterface = None + imgurApiKey = MiRCARTImgurApiKey.imgurApiKey # {{{ _commitPatch(self, patch): XXX def _commitPatch(self, patch): diff --git a/MiRCARTCanvasInterface.py b/MiRCARTCanvasInterface.py index e099537..33de616 100644 --- a/MiRCARTCanvasInterface.py +++ b/MiRCARTCanvasInterface.py @@ -34,6 +34,7 @@ import os, wx class MiRCARTCanvasInterface(): """XXX""" + imgurApiKey = None parentCanvas = parentFrame = canvasPathName = canvasTool = None # {{{ _dialogSaveChanges(self) @@ -136,8 +137,8 @@ class MiRCARTCanvasInterface(): # {{{ canvasExportImgur(self, event): XXX def canvasExportImgur(self, event): self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT)) - imgurResult = self.parentCanvas.canvasExportStore.exportBitmapToImgur( \ - "c9a6efb3d7932fd", self.parentCanvas.canvasBackend.canvasBitmap, \ + imgurResult = self.parentCanvas.canvasExportStore.exportBitmapToImgur( \ + self.imgurApiKey, self.parentCanvas.canvasBackend.canvasBitmap, \ "", "", wx.BITMAP_TYPE_PNG) self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor)) if imgurResult[0] == 200: diff --git a/MiRCARTImgurApiKey.py.template b/MiRCARTImgurApiKey.py.template new file mode 100644 index 0000000..6580ac7 --- /dev/null +++ b/MiRCARTImgurApiKey.py.template @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# +# MiRCARTImgurApiKey.py -- melp? +# Copyright (c) 2018 Lucio Andrés Illanes Albornoz +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +class MiRCARTImgurApiKey(object): + imgurApiKey = None + +# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120