Closed ghost closed 7 years ago
Have you tried reconnecting ? When a user joins Slack the bot won't reply to him/her unless the slackbot run.py is restarted. There is an open issue about automatically reconnecting the slack client when a user joins Slack.
Hey hey!
I helped solve a similar issue in limbot. The issue there was how the underlying slackrtm library was handling events. I can see the similar thing happening here.
In particular it's happening due to this code:
def loop(self):
while True:
events = self._client.rtm_read()
for event in events:
if event.get('type') != 'message':
continue
self._on_new_message(event)
time.sleep(1)
Because you're ignoring every event that doesn't have the type attribute message
you're not able to update the user base. Of particular use to the issue that was happening in limbo, were the group_joined
events, when the bot is added to a new group, and the team_joined
event, when a new member is added to the team.
I'll have a look at the codebase and see if I can figure out how to solve this here to. Any pointers you can provide to the following would be great help to me!
@TetraEtc,
Dear our saviour, I have no idea how to help you because I'm kind of a noob but rest assured I'll cheer and root for your endeavour. Thank you very much!
Hey @TetraEtc,
About your questions:
Where does it create the list of groups it is upon start up? Where does it create the list of users in the team upon start up?
Yes to both questions, when it connects to the rtm endpoint it will get all the initial data (https://github.com/lins05/slackbot/blob/develop/slackbot/slackclient.py#L54). That function is called from https://github.com/lins05/slackbot/blob/develop/slackbot/slackclient.py#L42.
Thanks for taking the time!! :)
No response from original reporter, but this does sound like a dupe of #61.
Hi,
I'm developing a simple chatbot using slackbot toolkit. However, my bot only response to some people (about 3 people) in the channel. When other people send messages to the bot, nothing received at the respond_to function. My function is this:
@respond_to('(.*)')
def process_message(message, text):
logger.info(text)
text = text.lower()
if (text.startswith('hello')):
message.reply('Hi, how can I help?')
else:
reply = TFIDF.predict(text)
message.reply(reply)
Do you have any suggestion? Thanks.