Slackbotを起動させたい
「(任意の文字列)++」と打ったら,++を抜いた「(任意の文字列)」のみを返すようなSlackのBotをPythonで作ろうと思っています.
ファイル構造は以下の通りです.
親ディレクトリ(karma)
・run.py (実行のトリガーとなるスクリプト)
・slackbot_settings.py (botの設定を記述するファイル)
pluginsディレクトリ
・hello.py (botを実行するプロジェクト)←今回の問題はここ
・init.py (空ファイル)
このエラーが出る原因に関して皆目検討がつかないのですが,ご存知の方がいらっしゃいましたら解決法と合わせてご教示いただけますと幸いです.
宜しくお願いします.
エラー
starting slackbot Failed to import plugins.hello Traceback (most recent call last): File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/site-packages/slackbot/manager.py", line 60, in _load_plugins import_module(module) File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Users/macuser/Workspaces/jxpress/karma/plugins/hello.py", line 10, in <module> @respond_to('(.*)++') File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/site-packages/slackbot/bot.py", line 53, in wrapper re.compile(matchstr, flags)] = func File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/re.py", line 234, in compile return _compile(pattern, flags) File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/re.py", line 286, in _compile p = sre_compile.compile(pattern, flags) File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/sre_compile.py", line 764, in compile p = sre_parse.parse(p, flags) File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/sre_parse.py", line 930, in parse p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0) File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/sre_parse.py", line 426, in _parse_sub not nested and not items)) File "/Users/macuser/Workspaces/jxpress/karma/.direnv/python-3.7.3/lib/python3.7/sre_parse.py", line 654, in _parse source.tell() - here + len(this)) re.error: multiple repeat at position 5
コード
run.py
1#run.py 2#!/usr/bin/python 3# -*- coding: utf-8 -*- 4from slackbot.bot import Bot 5 6def main(): 7 bot = Bot() 8 bot.run() 9 10if __name__ == "__main__": 11 print('starting slackbot') 12 main()
slackbot_settings.py
1#slackbot_settings.py 2#!/usr/bin/python 3# -*- coding: utf-8 -*- 4 5API_TOKEN = “xxx” 6DEFAULT_REPLY = "I dont't understand you." 7PLUGINS = ['plugins']
hello.py
1#hello.py 2#!/usr/bin/python 3# -*- coding: utf-8 -*- 4 5from slackbot.bot import respond_to 6 7@respond_to('(.*)++') 8def reply_id(message, arg): 9 message.reply(arg)
補足情報(FW/ツールのバージョンなど)
iOS 10.15, Python 3.7.4, Atom
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/11/13 05:08