Last active
November 28, 2017 18:43
-
-
Save MatejMecka/153c0bbb79e70bd33323fea6c06a781f to your computer and use it in GitHub Desktop.
GCI17 CCExtractor Development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# To start bot install SlackClient from pip. Make sure bot joins #general only! Leave it to run. Use supervisor i'd recommmend | |
from slackclient import SlackClient | |
import time | |
slack_token = "" #token for slack | |
sc = SlackClient(slack_token) | |
messagetosend = "" #message to great | |
if sc.rtm_connect(): | |
while True: | |
for slack_message in sc.rtm_read(): | |
print(slack_message) | |
message = slack_message.get("type") | |
user = slack_message.get("user") | |
if not message or not user: | |
continue | |
if message == "member_joined_channel": | |
sc.api_call("chat.postMessage",channel=user,as_user=True,text=messagetosend) | |
time.sleep(2) | |
else: | |
print("There is a problem connecting to Slack. Check your Internet connection or you might have problems with the API key.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can start the bot by installing slackclient using
pip install slackclient
Get a Slack token by creating a bot user.(https://my.slack.com/services/new/bot)
Modify the messagetosend variable to include the greeting message to dm a user.
python bot.py