def start_bot(token): print("Starting bot for token: {}".format(token)) config = { "DEBUG": True, "SLACK_TOKEN": token, "ACTIVE_PLUGINS": ["plugins.runner.FeedsparqPlugin"], "FeedsparqPlugin": {"DEBUG": True} } print("The config file: {}".format(config)) bot = RtmBot(config) bot.start()
def main(): logging.basicConfig(filename='slackbot.log', level=logging.DEBUG) logger = logging.getLogger() bot = RtmBot(rtmbot_config) try: bot.start() except KeyboardInterrupt: sys.exit(0) except Exception as e: logger.error('Error when run bot', exc_info=True)
def main(args=None): # load args with config path if not specified if not args: args = parse_args() config = yaml.safe_load(open(args.config or 'rtmbot.conf', 'r')) bot = RtmBot(config) try: bot.start() except KeyboardInterrupt: sys.exit(0)
def main(args=None): # load args with config path if not specified if not args: args = parse_args() config = yaml.load(open(args.config or 'rtmbot.conf', 'r')) config['SLACK_TOKEN'] = os.environ['SLACK_TOKEN'] bot = RtmBot(config) try: bot.start() except KeyboardInterrupt: sys.exit(0)
def main(args=None): # load args with config path if not specified if not args: args = parse_args() if os.environ.get('DEBUG'): DEBUG_MODE = str2bool(os.environ.get('DEBUG')) else: DEBUG_MODE = args.debug config = { 'DEBUG': DEBUG_MODE, 'SLACK_TOKEN': os.environ.get('SLACK_TOKEN') or args.slack_token, 'LOGFILE': os.environ.get('LOG_PATH') or args.log_path, 'ACTIVE_PLUGINS': ['plugins.tagger.Tagger'], 'Tagger': { 'BOT_DEFAULT_USERNAME': os.environ.get('BOT_DEFAULT_USERNAME') or args.bot_default_username, } } if config['SLACK_TOKEN'] is None: print( 'SLACK_TOKEN is not set! Define it in environment variable or provide as run argument --slack_token=YOUR_SLACK_TOKEN' ) sys.exit(1) if config['Tagger']['BOT_DEFAULT_USERNAME'] is None: print( 'BOT_DEFAULT_USERNAME is not set! Define it in environment variable or provide as run argument --bot_default_username=default_username' ) sys.exit(2) bot = RtmBot(config) try: bot.start() except KeyboardInterrupt: sys.exit(0)
from rtmbot import RtmBot from rtmbot.core import Plugin # secret라는 module에 있는 SLACK_TOKEN을 불러오는 코드 import secret # chatlogic이라는 module에 있는 Reply의 logic pattern을 불러오는 코드 import menulogic class HelloPlugin(Plugin): def process_message(self, data): answer = menulogic.reply(data["text"]) if answer is None: pass else: self.outputs.append([data["channel"], answer]) config = { "SLACK_TOKEN": secret.SLACK_TOKEN, "ACTIVE_PLUGINS": ["main.HelloPlugin"] } bot = RtmBot(config) bot.start()
def init(config): global slack_client bot = RtmBot(config) slack_client = bot.slack_client return bot
from rtmbot import RtmBot from os import path from constants import path_conf_file from logic.exceptions import NoConfFile import yaml """ This python script is responsible for starting process of instant and periodical messages replay by our bot. """ if __name__ == '__main__': try: if not path.exists(path_conf_file): raise NoConfFile with open(path_conf_file, 'r') as conffile: conf = yaml.load(conffile) bot = RtmBot(conf) bot.start() except NoConfFile: raise NoConfFile( 'There is no configuration file at the provided path.')
def main(): """ Run the bot, (run this function only if you want to run the bot without the web wedpoints) """ bot = RtmBot(config) bot.start()
def run(): bot = RtmBot(config) bot.start()
def parse_args(): parser = ArgumentParser() parser.add_argument( '-c', '--config', help='Full path to config file.', metavar='path' ) return parser.parse_args() # load args with config path args = parse_args() config = yaml.load(open(args.config or 'rtmbot.conf', 'r')) bot = RtmBot(config) try: bot.start() except KeyboardInterrupt: sys.exit(0) import json import os import sys import time import logging from slackclient import SlackClient def dbg(debug_string): if debug:
from rtmbot import RtmBot import yaml from config import rtmbot_config from clients.sentry import create_client import logging from raven.handlers.logging import SentryHandler from raven.conf import setup_logging slack_client = RtmBot(rtmbot_config).slack_client sentry_client = create_client() # Manually specify a client _handler = SentryHandler(sentry_client) _handler.setLevel(logging.ERROR) setup_logging(_handler)