Esempio n. 1
0
def main():
    pid = os.getpid()
    f = open(os.getcwd() + '/slackbot.pid', 'w')
    f.write(str(pid))
    f.close()
    bot = Bot()
    bot.run()
Esempio n. 2
0
def main():
    bot = Bot()

    slack = Slacker(slackbot_settings.API_TOKEN)
    slack.chat.post_message('bot', 'Run SlackBot!!', as_user=True)

    bot.run()
Esempio n. 3
0
def main():
    logging.basicConfig(level=logging.INFO)
    logging.info("Running")

    createStorageObject()  # exception if no storage
    bot = Bot()
    bot.run()
Esempio n. 4
0
 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()
Esempio n. 5
0
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()
Esempio n. 6
0
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')
Esempio n. 7
0
def slackbot_init():
    """
    Thread target for initializing slackbot
    """
    logger.info('Initializing slackbot')
    bot = Bot()
    bot.run()
Esempio n. 8
0
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()
Esempio n. 10
0
class SlackBot(object):
    def __init__(self):
        self.bot = Bot()

    def main(self):
        self.bot.run()
        return
Esempio n. 11
0
def main():
    Motor.setup()
    bot = Bot()
    try:
        bot.run()
    except KeyboardInterrupt:
        Motor.finish()
        sys.exit()
Esempio n. 12
0
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()
Esempio n. 13
0
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()
Esempio n. 14
0
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()
Esempio n. 15
0
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()
Esempio n. 16
0
def main():
    executor = concurrent.futures.ProcessPoolExecutor(max_workers=2)
    bot = Bot()
    # bitbank.bitbankstart()
    tast = [
        executor.submit(bot.run()),
        executor.submit(bitbank.bitbankstart())
    ]
    executor.shutdown()
Esempio n. 17
0
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)
Esempio n. 18
0
def main():
    # BOTの生成
    bot = Bot()

    try:
        # BOT実行
        bot.run()
    except KeyboardInterrupt:
        logging.info('catch KeyboardInterrupt')
Esempio n. 19
0
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()
Esempio n. 20
0
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()
Esempio n. 21
0
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)
Esempio n. 22
0
def main():
    Database.initialise()
    try:
        file = File()
        file.create_table()
    except:
        pass

    bot = Bot()
    bot.run()
Esempio n. 23
0
def main():
    print("running")
    try:
        bot = Bot()
        bot.run()
        print("run")
    except Exception as e:
        print(str(e))
        traceback.print_exc()
        exit(1)
Esempio n. 24
0
    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')
Esempio n. 25
0
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()
Esempio n. 26
0
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()
Esempio n. 27
0
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)
Esempio n. 28
0
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()
Esempio n. 29
0
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()
Esempio n. 30
0
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)
Esempio n. 31
0
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()
Esempio n. 32
0
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())
Esempio n. 33
0
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()
Esempio n. 34
0
File: bot.py Progetto: vzhong/vvbot
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)
Esempio n. 35
0
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()
Esempio n. 36
0
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()
Esempio n. 37
0
def main():

    we = WithdrawalExecutor()
    we.start()
    rp = ReportPublisher()
    rp.start()

    bot = Bot()
    bot.run()

    we.request_stop()
    we.join()
    rp.request_stop()
    rp.join()
Esempio n. 38
0
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()
Esempio n. 39
0
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()
Esempio n. 40
0
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()
Esempio n. 41
0
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()
Esempio n. 42
0
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()
Esempio n. 43
0
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()
Esempio n. 44
0
    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()
Esempio n. 45
0
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)
Esempio n. 46
0
File: bot.py Progetto: vzhong/vvbot
 def __init__(self):
   logging.info('initializing')
   self.bot = Bot()
   self.dispatcher = Dispatcher()
   logging.info('initialization finished')
Esempio n. 47
0
def main():
    bot = Bot()
    bot.run()
Esempio n. 48
0
def main():
    bot = Bot()
    print("*running*")
    bot.run()
Esempio n. 49
0
File: elsa.py Progetto: Horgix/elsa
def main():
    bot = Bot()
    print('Bot initialized')
    bot.run()
Esempio n. 50
0
def main():
    bot = Bot()
    led = LedService()
    led.run()
    bot.run()
Esempio n. 51
0
#coding: utf-8
#仮想通貨の価格をお知らせするslackbot
from slackbot.bot import Bot

bot = Bot()
bot.run()
Esempio n. 52
0
def main():
    logging.basicConfig(level=logging.DEBUG)
    bot = Bot()
    bot.run()
Esempio n. 53
0
def main():
    bot = Bot()
    # get_all_channel_messages()
    bot.run()
Esempio n. 54
0
def main():
    bot = Bot()
    print "Bot now running"
    bot.run()
Esempio n. 55
0
def main():
    bot = Bot()
    print "Carebot is running. Invite it to a channel to begin."
    bot.run()
Esempio n. 56
0
def main():
    bot = Bot()

    announcethread.start_announce_thread(bot._client)

    bot.run()