def __init__(self, debug=False, verbose=False, slackbot_injected=None, slacker_injected=None): self.debug = debug self.verbose = verbose self.config = config.Config() slackbot_token = os.getenv(self.config.slackbot_api_token_env_varname) api_token = os.getenv(self.config.api_token_env_varname) self.slackbot = slackbot_injected or slackbot.Slackbot( config.SLACK_NAME, token=slackbot_token) self.logger = logging.getLogger(__name__) utils.set_up_logger(self.logger, log_level_env_var='DESTALINATOR_LOG_LEVEL', log_to_slack_env_var='DESTALINATOR_LOG_TO_CHANNEL', log_channel=self.config.log_channel, slackbot=self.slackbot) self.destalinator_activated = False if os.getenv(self.config.destalinator_activated_env_varname): self.destalinator_activated = True self.logger.debug("destalinator_activated is %s", self.destalinator_activated) self.slacker = slacker_injected or slacker.Slacker( config.SLACK_NAME, token=api_token, logger=self.logger) self.ds = destalinator.Destalinator( slacker=self.slacker, slackbot=self.slackbot, activated=self.destalinator_activated, logger=self.logger)
def archive(): sb = slackbot.Slackbot("rands-leadership", slackbot_token_file="sb_token.txt") ds = destalinator.Destalinator("rands-leadership", slackbot=sb, api_token_file="api_token.txt") ds.safe_archive_all(60)
def warn(): sb = slackbot.Slackbot("rands-leadership", slackbot_token_file="sb_token.txt") ds = destalinator.Destalinator("rands-leadership", slackbot=sb, api_token_file="api_token.txt") ds.warn_all(30)
def __init__(self, slackbot_injected=None, slacker_injected=None): self.slackbot = slackbot_injected or slackbot.Slackbot( self.config.slack_name, token=self.config.sb_token) set_up_slack_logger(self.slackbot) self.logger.debug("activated is %s", self.config.activated) self.slacker = slacker_injected or slacker.Slacker( self.config.slack_name, token=self.config.api_token) self.ds = destalinator.Destalinator(slacker=self.slacker, slackbot=self.slackbot, activated=self.config.activated)
def __init__(self, debug=False, verbose=False): self.debug = debug self.verbose = verbose self.config = config.Config() slackbot_token = os.getenv(self.config.slackbot_api_token_env_varname) api_token = os.getenv(self.config.api_token_env_varname) self.sb = slackbot.Slackbot(config.SLACK_NAME, token=slackbot_token) self.slacker = slacker.Slacker(config.SLACK_NAME, token=api_token) self.ds = destalinator.Destalinator(slacker=self.slacker, slackbot=self.sb)
def __init__(self, debug=False, verbose=False): self.debug = debug self.verbose = verbose self.config = config.Config() slackbot_token = os.getenv(self.config.slackbot_api_token_env_varname) api_token = os.getenv(self.config.api_token_env_varname) self.destalinator_activated = False if os.getenv(self.config.destalinator_activated_env_varname): self.destalinator_activated = True print("destalinator_activated is {}".format( self.destalinator_activated)) self.sb = slackbot.Slackbot(config.SLACK_NAME, token=slackbot_token) self.slacker = slacker.Slacker(config.SLACK_NAME, token=api_token) self.ds = destalinator.Destalinator( slacker=self.slacker, slackbot=self.sb, activated=self.destalinator_activated)
def mocked_slackbot_object(): obj = mock.MagicMock(wraps=slackbot.Slackbot(get_config().slack_name, token='token')) obj.say = mock.MagicMock(return_value=True) return obj
def setUp(self): self.slacker = SlackerMock("testing", "token") self.slackbot = slackbot.Slackbot("testing", "token")
def mocked_slackbot_object(): obj = mock.MagicMock( wraps=slackbot.Slackbot(config.SLACK_NAME, token='token')) obj.say = mock.MagicMock(return_value=True) return obj
import json import BaseHTTPServer import threading import faceapp import collections import re import faceapp import urllib import slackbot import traceback import params server_shutdown = threading.Event() server_sem = threading.Semaphore(0) msg_queue = collections.deque() slack = slackbot.Slackbot(params.token, params.channel) class SlackRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version = "SlackBotHTTP/" + "0.1" def do_POST(self): global msg_queue,server_sem r = json.loads( self.rfile.read(int(self.headers["Content-Length"]))) if r["token"] != params.id_token: self.send_response(400) return msg_queue.appendleft(r) server_sem.release()