aboutsummaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2016-03-15 16:41:58 +0200
committerkongr45gpen <electrovesta@gmail.com>2016-03-15 16:41:58 +0200
commit23d851aff066a39e3ceb01f85c30539e467a70ea (patch)
tree2feeadac920c62161163b3b4d7ee0ae8361787b9 /plugin.py
parente56a487b2a6672284a8f18a816782b5fdebf3b08 (diff)
downloadsupybot_github-23d851aff066a39e3ceb01f85c30539e467a70ea.tar.gz
supybot_github-23d851aff066a39e3ceb01f85c30539e467a70ea.tar.bz2
supybot_github-23d851aff066a39e3ceb01f85c30539e467a70ea.zip
Add support for github secrets
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/plugin.py b/plugin.py
index 6153d62..89a4832 100644
--- a/plugin.py
+++ b/plugin.py
@@ -34,6 +34,7 @@ import urlparse
import threading
import BaseHTTPServer
+import supybot.dbi as dbi
import supybot.log as log
import supybot.conf as conf
import supybot.utils as utils
@@ -61,6 +62,11 @@ class Github(callbacks.Plugin):
messages = []
pass
+ add = None
+ search = None
+ stats = None
+ change = None
+
def ServerStart(self, httpd):
try:
log.info('Server Starts - %s:%s' % ('', self.port))
@@ -68,6 +74,7 @@ class Github(callbacks.Plugin):
except:
return
+
def __init__(self, irc):
self.__parent = super(Github, self)
self.__parent.__init__(irc)
@@ -117,6 +124,63 @@ class Github(callbacks.Plugin):
# Debug command
get = wrap(get, ['lowered', optional('lowered'), optional('text')]) if world.testing else False
+ def abs_val(self,irc,msg,args):
+ pass
+ abs_val = wrap(abs_val,[])
+
+ class secret(callbacks.Commands):
+ class DB(plugins.DbiChannelDB):
+ class DB(dbi.DB):
+ class Record(dbi.Record):
+ __fields__ = [
+ 'secret'
+ ]
+ def add(self, secret, **kwargs):
+ record = self.Record(secret = secret, **kwargs)
+ return super(self.__class__, self).add(record)
+ def set(self, id, secret, **kwargs):
+ record = self.Record(secret = secret, **kwargs)
+ return super(self.__class__, self).set(id, record)
+
+ def __init__(self, irc):
+ # self.db = self.DB(("%s-secret") % (self.name(),))
+ print(conf.supybot.databases())
+ super(Github.secret, self).__init__(irc)
+ self.db = plugins.DB(("github-secret"), {'flat': self.DB})()
+ globals.secretDB = self.db
+
+ def set(self, irc, msg, args, channel, secret):
+ """[<channel>] secret
+
+ Sets a Github secret for a channel to a specific value.
+ <channel> is only necessary if the message isn't sent in the channel itself.
+ """
+ self.db.set(channel, 1, secret)
+ # record = Github.secret.DB.DB.Record(secret = sec)
+ # self.db.set(channel, 1, secret)
+ irc.replySuccess()
+ set = wrap(set, ['channel', 'text'])
+
+ def reset(self, irc, msg, args, channel):
+ """[<channel>]
+
+ Removes a Github secret for a channel.
+ <channel> is only necessary if the message isn't sent in the channel itself.
+ """
+ self.db.remove(channel, 1)
+ irc.reply("Channel %s no longer has a secret." % channel)
+ reset = wrap(reset, ['channel'])
+
+ def generate(self, irc, msg, args, channel):
+ """<channel>
+
+ Generates a Github secret for a channel.
+ <channel> is only necessary if the message isn't sent in the channel itself.
+ """
+ secret = Utility.randomString(40)
+ irc.reply("Setting secret for %s to: %s" % (channel, secret))
+ self.db.set(channel, 1, secret)
+ generate = wrap(generate, ['channel'])
Class = Github

© 2014-2024 Faster IT GmbH | imprint | privacy policy