Skip to content

Commit

Permalink
add keep active so that the bot would not be displayed as away
Browse files Browse the repository at this point in the history
This only applies to real user api. For bot user it's not needed.
https://api.slack.com/docs/presence
  • Loading branch information
lins05 committed Feb 21, 2015
1 parent 7535b5b commit 1626ba5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
addopts = -s -v --doctest-modules --ignore=setup.py
addopts = -s -v --doctest-modules --ignore=build --ignore=dist --ignore=slackbot.egg-info --ignore=setup.py
9 changes: 9 additions & 0 deletions slackbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import os
import re
import sys
import thread
import time

from slackbot import settings
from slackbot.slackclient import SlackClient
Expand All @@ -25,9 +27,16 @@ def run(self):
self._plugins.init_plugins()
self._dispatcher.start()
self._client.rtm_connect()
thread.start_new_thread(self._keepactive, tuple())
logger.info('connected to slack RTM api')
self._dispatcher.loop()

def _keepactive(self):
logger.info('keep active thread started')
while True:
time.sleep(30 * 60)
self._client.ping()

class PluginsManager(object):
commands = {}

Expand Down

0 comments on commit 1626ba5

Please sign in to comment.