How to open multiple rtmbots on the server?
Well, I am trying to have a server that have multiple rtmbots. Each one will have it's own websocket that connects to one team/client. However in the main loop, I see that you can only open one websocket to the client specified in the .conf token. Is there a way to open multiple RTM connection dynamically at runtime?
I would love to see an answer to this question. I am going through the same thing.
mtermoul - did you figure this out?
I have multiple running on one server. Each one gets its own socket on start up. I put them all into different folders (rtm1, rtm2, etc) and daemonize them so that they run under different pids.
No, it's not possible, we rewrote RTMbot to allow multiple teams from one python process. Do be aware that RTMbot crashes hard when a team removes the bot from slack.
Yes, you can do that, no problem. First, to run a bot programmatically (instead of command line) you do this:
from rtmbot import RtmBot
config = {
"SLACK_TOKEN": "xoxb-xxxxxxxx-jhgasjhgajhsska",
"ACTIVE_PLUGINS": [],
}
bot = RtmBot(config)
bot.start()
After that, it's simple to make it multi-threaded:
import time
import threading
from rtmbot import RtmBot
SLACK_TOKEN = "xoxb-111111111-nnnnnnnnnnnnnn"
def start_bot(slack_token):
config = {
"SLACK_TOKEN": slack_token,
"ACTIVE_PLUGINS": [],
}
bot = RtmBot(config)
bot.start()
#running the bot in a thread. You can make an array of threads and tokens to run the bot for multiple teams
bot_thread = threading.Thread(target=start_bot, args=(SLACK_TOKEN,))
bot_thread .daemon = True # we need this to CTRL+C
bot_thread .start()
# running a loop that prevents from the main process ending
while True:
time.sleep(1)
print("slept")
@MeLight nice! Want to add those instructions to the README?
@Roach opened a pull request with README changes