Skip to content

Instantly share code, notes, and snippets.

@svdgraaf
Created June 20, 2018 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svdgraaf/52a92190c1ab9a48363e583fa7bb497d to your computer and use it in GitHub Desktop.
Save svdgraaf/52a92190c1ab9a48363e583fa7bb497d to your computer and use it in GitHub Desktop.
@plusplus karma automater
#!/usr/bin/env python
import os
import time
from slackclient import SlackClient
slack_token = os.environ["SLACK_API_TOKEN"]
sc = SlackClient(slack_token)
stuff = {
"<@U8Q1UCGPM>": 243, # This is the slack user id
"@whatever": 2, # Regular stuff also works
}
for what, karma in stuff.items():
current = 0
while current != karma:
print(" %s != %s" % (current, karma) )
if karma > 0:
msg = "%s++ karmasync" % what
current += 1
if karma < 0:
msg = "%s-- karmasync" % what
current -= 1
print(msg)
# msg = "@platypus++"
sc.api_call(
"chat.postMessage",
as_user=True,
link_names=True,
username='svdgraaf',
parse='none',
channel="plusplus-sync",
text=msg
)
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment