Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
import json
except ImportError:
import simplejson as json
from karmabot.client import thing
from karmabot.thing import facet_classes, presenters, ThingFacet
from karmabot import command
from karmabot.utils import Cache
@facet_classes.register
class GitHubFacet(ThingFacet):
name = "github"
commands = command.thing.add_child(command.FacetCommandSet(name))
def __init__(self, thing_):
ThingFacet.__init__(self, thing_)
self.get_info = Cache(self._get_info, expire_seconds=10 * 60)
@classmethod
def does_attach(cls, thing):
return False
@commands.add(u"forget that {thing} is on github",
help=u"unset {thing}'s github username",
exclusive=True)
def unset_github_username(self, thing, context):
del self.data
self.thing.detach_persistent(self)
import urllib
from xml.sax.saxutils import unescape as unescape_html
try:
import json
except ImportError:
import simplejson as json
from karmabot import thing
from karmabot import command
from karmabot.utils import Cache
@thing.facet_classes.register
class TwitterFacet(thing.ThingFacet):
name = "twitter"
commands = command.thing.add_child(command.FacetCommandSet(name))
def __init__(self, thing_):
thing.ThingFacet.__init__(self, thing_)
self.get_info = Cache(self._get_info, expire_seconds=10*60)
@classmethod
def does_attach(cls, thing):
return False
@commands.add(u"forget that {thing} is on twitter",
help=u"unset {thing}'s twitter username",
exclusive=True)
def unset_twitterer(self, thing, context):
del self.data
self.thing.detach_persistent(self)
import urllib
try:
import json
except ImportError:
import simplejson as json
from karmabot import thing
from karmabot import command
from karmabot.utils import Cache
@thing.facet_classes.register
class RedditorFacet(thing.ThingFacet):
name = "redditor"
commands = command.thing.add_child(command.FacetCommandSet(name))
def __init__(self, thing_):
thing.ThingFacet.__init__(self, thing_)
self.get_info = Cache(self._get_info, expire_seconds=10 * 60)
@classmethod
def does_attach(cls, thing):
return False
@commands.add(u"forget that {thing} is a redditor",
help=u"unset {thing}'s reddit username",
exclusive=True)
def unset_redditor(self, thing, context):
del self.data
self.thing.detach_persistent(self)
"You may rely on it",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"]
@thing.facet_classes.register
class EightBallFacet(thing.ThingFacet):
name = "eightball"
commands = command.thing.add_child(command.FacetCommandSet(name))
@classmethod
def does_attach(cls, thing):
return thing.name == "eightball"
@commands.add("shake {thing}", help="shake the magic eightball")
def shake(self, thing, context):
context.reply(random.choice(predictions) + ".")
from karmabot import thing
from karmabot import command
from karmabot import ircutils
@thing.facet_classes.register
class NameFacet(thing.ThingFacet):
name = "name"
commands = command.thing.add_child(command.FacetCommandSet(name))
@classmethod
def does_attach(cls, thing):
return True
@commands.add(u"{thing}\?*", help=u"show information about {thing}")
def describe(self, thing, context):
context.reply(thing.describe(context))
@thing.presenters.register(set(["name"]), order=-10)
def present(thing, context):
return u"{name}".format(name = ircutils.bold(thing.name))