def main(): pid = os.getpid() f = open(os.getcwd() + '/slackbot.pid', 'w') f.write(str(pid)) f.close() bot = Bot() bot.run()
def main(): bot = Bot() slack = Slacker(slackbot_settings.API_TOKEN) slack.chat.post_message('bot', 'Run SlackBot!!', as_user=True) bot.run()
def main(): logging.basicConfig(level=logging.INFO) logging.info("Running") createStorageObject() # exception if no storage bot = Bot() bot.run()
def __init__(self): threading.Thread.__init__(self) slackbot.settings.API_TOKEN = slack_token slackbot.settings.DEFAULT_REPLY = 'Ko?' slackbot.settings.BOT_EMOJI = slack_bot_icon #slackbot.settings.BOT_ICON = slack_bot_icon self.bot = Bot()
def main(): """設定ファイルをparseして、slackbotを起動します 1. configparserで設定ファイルを読み込む 2. 設定ファイルに `alembic` セクションが設定されているかチェック 3. 設定ファイルの情報でDB周りの設定を初期化 4. slackbotの処理を開始 """ parser = get_argparser() args = parser.parse_args() conf = ConfigParser() conf.read_file(args.config) # 環境変数で指定したいため ini ファイルでなくここで追記 conf["alembic"]['sqlalchemy.url'] = SQLALCHEMY_URL conf["alembic"]['sqlalchemy.echo'] = SQLALCHEMY_ECHO if SQLALCHEMY_POOL_SIZE: conf["alembic"]['sqlalchemy.pool_size'] = SQLALCHEMY_POOL_SIZE if not conf.has_section('alembic'): raise NoSectionError('alembic') init_dbsession(conf['alembic']) bot = Bot() bot.run()
def main(): logger.info('bot:pre_initialize') bot = Bot() logger.info('bot:post_initialize') logger.info('bot:pre_run') bot.run() logger.info('bot:post_run')
def slackbot_init(): """ Thread target for initializing slackbot """ logger.info('Initializing slackbot') bot = Bot() bot.run()
def start_slack_processing(): sender = threading.Thread(target=ss.SlackSender) sender.daemon = True print("Starting Slack Sender") sender.start() #slack_uploader = threading.Thread(target=slackUpload.SlackUploader) #slack_uploader.daemon = True #print("Starting Slack file uploader") #slack_uploader.start() #imagebinUploader = threading.Thread(target=imagebinUpload.ImagebinUploader) #imagebinUploader.daemon = True #print("Starting Imagebin Uploader") #imagebinUploader.start() imgurUploader = threading.Thread(target=imgurUpload.ImgurUploader) imgurUploader.daemon = True print("Starting imgur Uploader") imgurUploader.start() bot = Bot() print("Starting Slack bot") user_manager = um.UserManager() user_manager.set_users(bot._client.users) bot.run()
def main(): channel="競プロ" slack = Slacker(slackbot_settings.API_TOKEN) if datetime.datetime.today().weekday()==0: info(channel,slack) bot = Bot() bot.run()
class SlackBot(object): def __init__(self): self.bot = Bot() def main(self): self.bot.run() return
def main(): Motor.setup() bot = Bot() try: bot.run() except KeyboardInterrupt: Motor.finish() sys.exit()
def run(): # run setup setup() # run bot from slackbot.bot import Bot bot = Bot() LOG.info('Starting bot...press CTRL+C to stop') bot.run()
def main(): ok = create_table() if not ok: print("Resource table is not created!", file=sys.stderr) sys.exit(1) bot = Bot() print("start resource keeper at {}".format(datetime.now())) bot.run()
def main(): ssl._create_default_https_context = ssl._create_unverified_context # https://qiita.com/shutokawabata0723/items/9733a7e640a175c23f39 #export SSL_CERT_FILE = 'C:\\Users\\mnahira\\anaconda3\\lib\\site-packages\\certifi\\cacert.pem' # ボットの起動 bot = Bot() bot.run()
def main(): from slackbot import settings from slackbot.bot import Bot from .plugins.weather import OpenWeatherMap settings.open_weather_map = OpenWeatherMap() bot = Bot() bot.run()
def main(): executor = concurrent.futures.ProcessPoolExecutor(max_workers=2) bot = Bot() # bitbank.bitbankstart() tast = [ executor.submit(bot.run()), executor.submit(bitbank.bitbankstart()) ] executor.shutdown()
def main(): bot = Bot() th_me = threading.Thread(target=check_lux, name="th_check_lux") th_me.setDaemon(True) th_me.start() try: bot.run() except Exception as e: print(e)
def main(): # BOTの生成 bot = Bot() try: # BOT実行 bot.run() except KeyboardInterrupt: logging.info('catch KeyboardInterrupt')
def main(): """Then main Bot application""" if not conf.API_TOKEN or not conf.SPEAKER_IP: print('Slack API token or Sonos speaker IP not set.\n' 'Please add configure it before running Sonlack. Exiting...') sys.exit(0) bot = Bot() print('Sonlack is rocking now. Enjoy your favorite music...') bot.run()
def main(): logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) bot = Bot() # make @respond_to receive multi-line messages bot._dispatcher.AT_MESSAGE_MATCHER = re.compile( bot._dispatcher.AT_MESSAGE_MATCHER.pattern, re.S | re.M ) bot.run()
class sbot(threading.Thread): def __init__(self): threading.Thread.__init__(self) slackbot.settings.API_TOKEN = slack_token slackbot.settings.DEFAULT_REPLY = 'Ko?' slackbot.settings.BOT_EMOJI = slack_bot_icon #slackbot.settings.BOT_ICON = slack_bot_icon self.bot = Bot() def run(self): self.bot.run() @listen_to('.help$', re.IGNORECASE) def help(message): msg = 'Available commands:\n *.help* --- Display help\n' msg += ' :black_small_square: *.status* --- Display all monitored currency status\n' msg += ' :black_small_square: *.stats* --- Display short stats (current price)\n' msg += ' :black_small_square: *.price <coin>* --- To display current stats for a specific coin\n' message.send(msg) @listen_to('.stats$', re.IGNORECASE) def stats(message): msg = 'Current prices: \n' for c in symbols.keys(): msg += ' :black_small_square: :%s: %s -- *$%s*\n' % \ (symbols[c][0].lower(), symbols[c][0], vstore.now[c]) message.send(msg) @listen_to('.status$', re.IGNORECASE) def status(message): for c in symbols.keys(): msg = ':%s: %s current price: *$%s*\n' % \ (symbols[c][0].lower(), symbols[c][0], vstore.now[c]) msg += ' --- :black_small_square: Hourly: $%s-$%s [Delta: *$%s*]\n' % \ (vstore.hmin[c], vstore.hmax[c], round_it(vstore.hmax[c] - vstore.hmin[c])) msg += ' --- :black_small_square: Daily: $%s-$%s [Delta: *$%s*] [`%s%%`]\n' % \ (vstore.min24[c], vstore.max24[c], round_it(vstore.max24[c] - vstore.min24[c]), vstore.percent24[c]) msg += ' --- :black_small_square: Notificaiton threshold: $%s-$%s\n' % \ (vstore.cmin[c], vstore.cmax[c]) message.send(msg) @listen_to('.price (.*)', re.IGNORECASE) def price(message, cur): currency = cur.upper() + 'USDT' if currency in symbols.keys(): msg = ':%s: *%s* current price *$%s*\n' % ( cur.lower(), cur.upper(), vstore.now[currency]) msg += ' --- :black_small_square: Hourly stats $%s-$%s [Delta: *$%s*]\n' % \ (vstore.hmin[currency], vstore.hmax[currency], round_it(vstore.hmax[currency] - vstore.hmin[currency])) msg += ' --- :black_small_square: Daily stats $%s-$%s [Delta: *$%s*] [`%s%%`]' % \ (vstore.min24[currency], vstore.max24[currency], round_it(vstore.max24[currency] - vstore.min24[currency]), vstore.percent24[currency]) message.send(msg)
def main(): Database.initialise() try: file = File() file.create_table() except: pass bot = Bot() bot.run()
def main(): print("running") try: bot = Bot() bot.run() print("run") except Exception as e: print(str(e)) traceback.print_exc() exit(1)
def test_slack_command_car_lookup(self, mock_car_owners, mock_rdw_client, mock_finnik): mock_car_owners.lookup.return_value = None mock_rdw_client.get_rdw_details.return_value = None mock_finnik.get_car_details.return_value = None bot = Bot() bot.car_owners = mock_car_owners bot.rdw_client = mock_rdw_client bot.finnik_client = mock_finnik r = bot.command_car('@user1', '12-AAA-4') mock_car_owners.lookup.assert_called_with('12AAA4') mock_rdw_client.get_rdw_details.assert_called_with('12AAA4') mock_finnik.get_car_details.assert_called_with('12AAA4') assert r == messages.lookup_no_details_found("12AAA4") r = bot.command_car('@user1', 'tag 1234') assert r == messages.command_invalid_licence_plate('1234') # Invalid.. r = bot.command_car('@user1', 'tag $$-^^^-4') assert r == messages.command_invalid_licence_plate('$$-^^^-4') # Happy Flow r = bot.command_car('@user1', 'tag 12-AAA-4') assert r == 'Added 12AAA4 to <@user1>' mock_car_owners.tag.assert_called_with('12AAA4', slackid='@user1')
def main(): kw = { "format": "[%(asctime)s] %(message)s", "datefmt": "%m/%d/%Y %H:%M:%S", "level": logging.DEBUG if settings.DEBUG else logging.INFO, "stream": sys.stdout, } logging.basicConfig(**kw) logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(logging.WARNING) bot = Bot() bot.run()
def main(): """Then main Bot application""" if not conf.API_TOKEN or not conf.SPEAKER_IP: print( "Slack API token or Sonos speaker IP not set.\n" "Please add configure it before running Sonlack. Exiting..." ) sys.exit(0) bot = Bot() print("Sonlack is rocking now. Enjoy your favorite music...") bot.run()
def main(): bot = Bot() image_thread = threading.Thread(target=check_img_file) image_thread.setDaemon(True) image_thread.start() try: bot.run() except Exception as e: print(e)
def main(): kw = { 'format': '[%(asctime)s] %(message)s', 'datefmt': '%m/%d/%Y %H:%M:%S', 'level': logging.DEBUG if settings.DEBUG else logging.INFO, 'stream': sys.stdout, } logging.basicConfig(**kw) logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARNING) bot = Bot() bot.run()
def main(): bot = Bot() # ボタン監視用のスレッドを起動する th_me = threading.Thread(target=check_button, name="th_check_button") th_me.setDaemon(True) th_me.start() try: slacker.chat.post_message(c_name, '起動しました。', as_user=True) # botを起動する bot.run() except Exception as e: print(e)
def main(): import dotenv import logging logging.basicConfig(level=logging.DEBUG) # update API_TOKEN dotenv.load_dotenv() settings.API_TOKEN = os.environ["SLACKBOT_API_TOKEN"] bot = Bot() bot.run()
def run(): # 基本的に止めるつもりはない # ログを出して、続行するただし、前回の停止から1分いないなら、終了する bef_time = 0 while time.time() - bef_time > BORDER_END_TIME: bef_time = time.time() try: logger.debug("run!") bot = Bot() bot.run() except: import traceback logger.warning(traceback.format_exc())
def main(): print('-- main --') # Botを動かす前にそのチャンネルにBotアプリケーションを追加することを忘れずに channel = "test" # slack api token 設定 slack = Slacker(slackbot_settings.API_TOKEN) print('-- info --') # 月曜であることの確認 (テスト用に削除) if datetime.datetime.today().weekday() == 0: info(channel, slack) bot = Bot() bot.run()
class VBot(object): def __init__(self): logging.info('initializing') self.bot = Bot() self.dispatcher = Dispatcher() logging.info('initialization finished') def run(self): logging.info('starting bot') self.bot.run() def answer(self, message, query): self.dispatcher.dispatch(message, query)
def main(): try: settings.zendesk_class = Zendesk( settings.ZENDESK_APP, settings.ZENDESK_USER, settings.ZENDESK_PASS, ) except AttributeError: print('Missing SLACKBOT_ZENDESK_APP, SLACKBOT_ZENDESK_USER or SLACKBOT_ZENDESK_PASS environment variable') sys.exit(1) print("starting bot...") bot = Bot() bot.run()
def main(): bot = Bot() schedule.every().sunday.at("22:00").do(send_statistics, bot=bot) schedule.every().monday.at("10:00").do(send_statistics, bot=bot) schedule.every().tuesday.at("10:00").do(send_statistics, bot=bot) schedule.every().wednesday.at("10:00").do(send_statistics, bot=bot) schedule.every().thursday.at("10:00").do(send_statistics, bot=bot) schedule.every().friday.at("10:00").do(send_statistics, bot=bot) schedule.every().saturday.at("22:00").do(send_statistics, bot=bot) ScheduleThread().start() print('bot start') bot.run()
def main(): we = WithdrawalExecutor() we.start() rp = ReportPublisher() rp.start() bot = Bot() bot.run() we.request_stop() we.join() rp.request_stop() rp.join()
def main(): if settings.API_TOKEN is not None: kw = { 'format': '[%(asctime)s] %(message)s', 'datefmt': '%m/%d/%Y %H:%M:%S', 'level': logging.DEBUG if settings.DEBUG else logging.INFO, 'stream': sys.stdout, } logging.basicConfig(**kw) logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARNING) bot = Bot() bot.run() else: print('Your Slack API_TOKEN is not set, please add it to your environment variables..') sys.exit()
def main(): global snakebot_config logging.basicConfig() curr_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(curr_dir) snakebot_config = ConfigParser.ConfigParser() snakebot_config.read("config.ini") settings.API_TOKEN = snakebot_config.get("slack", "API_TOKEN") settings.PLUGINS = ["snakebot"] #Overwrites other plugins. Don't need upload for instance. bot = Bot() print "[[ Snakebot online ]]" bot.run()
def main(): logger = logging.getLogger() handler = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) sys.path.append("plugins") if 'SLACKBOT_API_TOKEN' not in os.environ: print "'SLACKBOT_API_TOKEN' environment variable not set. Exiting..." exit(1) bot = Bot() bot.run()
def main(): try: settings.jira_class = JiraWrapper( settings.JIRA_SERVER, settings.JIRA_PROJECTS, settings.JIRA_USERNAME, settings.JIRA_PASSWORD, ) settings.ALLOWED_PROJECTS = settings.JIRA_PROJECTS.split(',') settings.ALLOWED_PROJECTS = [project.upper() for project in settings.ALLOWED_PROJECTS] except AttributeError: print('Missing JIRA_SERVER, JIRA_PROJECTS, JIRA_USERNAME or JIRA_PASSWORD environment variable') sys.exit(1) print("starting bot...") bot = Bot() bot.run()
def main(): global lunchotron_config logging.basicConfig() curr_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(curr_dir) lunchotron_config = ConfigParser.ConfigParser() lunchotron_config.read("config.ini") settings.API_TOKEN = lunchotron_config.get("slack", "API_TOKEN") settings.gPlaces = GooglePlaces(lunchotron_config.get("google-places", "API_TOKEN")) settings.gmaps = googlemaps.Client(lunchotron_config.get("google-places", "API_TOKEN")) settings.location = lunchotron_config.get("google-places", "location") settings.PLUGINS = ["lunchotron"] #Overwrites other plugins. Don't need upload for instance. bot = Bot() print "[[ lunchotron online ]]" bot.run()
def main(): try: settings.jira_class = JiraWrapper( settings.JIRA_SERVER, settings.JIRA_USERNAME, settings.JIRA_PASSWORD, ) settings.ALLOWED_PROJECTS = settings.JIRA_PROJECTS.split(',') settings.ALLOWED_PROJECTS = [project.upper() for project in settings.ALLOWED_PROJECTS] except AttributeError: print('Missing JIRA_SERVER, JIRA_PROJECTS, JIRA_USERNAME or JIRA_PASSWORD environment variable') sys.exit(1) # Jira allows a limited number of queries, but jira module we are using is # not giving us that info. So we cache. settings.CACHE = ExpiringDict(max_len=500, max_age_seconds=30) print("starting bot...") bot = Bot() bot.run()
def __init__(self): logging.basicConfig(level=logging.INFO) self.muted_rooms = set() self.handlers = {} self.plugins = [] if 'PLUGINS' in os.environ: self._load_plugins(map( str.strip, os.environ['PLUGINS'].split(',') )) self.bot = Bot()
class Creep(): def __init__(self): logging.basicConfig(level=logging.INFO) self.muted_rooms = set() self.handlers = {} self.plugins = [] if 'PLUGINS' in os.environ: self._load_plugins(map( str.strip, os.environ['PLUGINS'].split(',') )) self.bot = Bot() # for k, v in self.bot._client.channels.iteritems(): # if 'name' in v and v['name'] == 'creep': # self.bot._client.send_message( # k, 'Creep reporting for duty!' # ) def mute(self, room_id, timeout=10): def unmute_room(): self.unmute(room_id) self.muted_rooms.add(room_id) Timer(timeout, unmute_room).start() def unmute(self, room_id): # TODO if room_id in self.muted_rooms: self.muted_rooms.remove(room_id) self.bot._client.send_message( room_id, "I'm back baby!" ) def run(self): self.bot.run() def handle_message(self, message): body = message.body['text'] command = body.split(' ')[0] if ' ' in body else body params = body[body.find(" ")+1:] if ' ' in body else None logging.info("incoming message '%s'" % body) if command in self.handlers: handler = self.handlers[command] try: try: chan = message.channel except KeyError: chan = None result = handler(message=params, origin=chan) message.reply(result) except Exception: logging.exception("Couldn't handle command '%s': " % command) message.reply("Sorry, I got into trouble") else: message.reply( "Unknown command: '%s'. " 'Run "help" for more info on available commands.' % body ) def shutdown(self): for plugin in self.plugins: plugin.shutdown() def _load_plugins(self, names): for name in names: try: self._load_plugin(name) except Exception: logging.exception("Couldn't load plugin '%s':" % name) def _load_plugin(self, name): ''' assumes there's only one class per plugin ''' plugin = __import__('plugins.%s' % name, fromlist=['plugins', ]) plugin_instance = None for attribute in dir(plugin): item = getattr(plugin, attribute) if (inspect.isclass(item) and issubclass(item, Plugin) and not item == Plugin): plugin_instance = item(self) for handler_name in item.provides: if handler_name in self.handlers.keys(): raise Exception("Can't load '%s': handler already " "registered for '%s'" % (name, handler_name)) self.handlers[handler_name] = _get_handler(handler_name, plugin_instance) self.plugins.append(plugin_instance) logging.info("Finished loading '%s' plugin" % plugin_instance)
def __init__(self): logging.info('initializing') self.bot = Bot() self.dispatcher = Dispatcher() logging.info('initialization finished')
def main(): bot = Bot() bot.run()
def main(): bot = Bot() print("*running*") bot.run()
def main(): bot = Bot() print('Bot initialized') bot.run()
def main(): bot = Bot() led = LedService() led.run() bot.run()
#coding: utf-8 #仮想通貨の価格をお知らせするslackbot from slackbot.bot import Bot bot = Bot() bot.run()
def main(): logging.basicConfig(level=logging.DEBUG) bot = Bot() bot.run()
def main(): bot = Bot() # get_all_channel_messages() bot.run()
def main(): bot = Bot() print "Bot now running" bot.run()
def main(): bot = Bot() print "Carebot is running. Invite it to a channel to begin." bot.run()
def main(): bot = Bot() announcethread.start_announce_thread(bot._client) bot.run()