Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def unfurl(event, context):
session = requests.Session()
session.headers = {"PRIVATE-TOKEN": GITLAB_TOKEN, "User-Agent": "GitLab Unfurly"}
slack = SlackClient(SLACK_TOKEN)
request_json = json.loads(event["body"])
# handle Slack url verification
if request_json["type"] == "url_verification":
return {
"statusCode": 200,
"body": request_json["challenge"],
"headers": {"content-type": "text/plain"},
}
# handle unfurl
for link in request_json["event"]["links"]:
raw_url = link["url"]
url = urlparse(raw_url.replace("\\", ""))
log.bind(url=url)
def __init__(self, config=None):
self.config = Config() if config is None else config
self.sc = SlackClient(self.config.slack.api_token)
self.slackUser = "hammer"
def __init__(self, args):
self.params = args
self.channel = self.params['channel']
self.token = self.params['token']
self.client = SlackClient(self.token)
def __init__(self, workspaces, config):
self.workspaces = workspaces
slack_token = workspaces[0][1]
self.slack_token = slack_token
self.slack = SlackClient(slack_token)
self.state = State()
self.cache = Cache()
self.config = config
import os
from slackclient import SlackClient
from archived.creds import TOKEN
BOT_NAME = 'testopcode'
slack_client = SlackClient(TOKEN)
if __name__ == '__main__':
api_call = slack_client.api_call('users.list')
if api_call.get('ok'):
# retrieve all users so we can find our bot
users = api_call.get('members')
for user in users:
if 'name' in user and user.get('name') == BOT_NAME:
print(f"Bot ID for {user['name']} is {user.get('id')}")
else:
print(f"Could not find bot user with the name {BOT_NAME}")
self.single = single
self.metadata=[]
self.asin = asin
self.lprice = 0
self.flag = 0
self.count=0
self.msgcount=0
self.prime=prime
if price:
self.a_price = float(price)
if prime:
self.stat_url = "https://www.amazon.in/gp/offer-listing/" + asin + "/ref=olp_prime_new?ie=UTF8&condition=new&shipPromoFilter=1"
else:
self.stat_url = "https://www.amazon.in/gp/offer-listing/" + asin + "/ref=olp_tab_new?ie=UTF8&condition=new"
global TOKEN
self.sc = SlackClient(TOKEN)
def start(self):
"""Run the Slack network connection."""
self.client = slackclient.SlackClient(self.api_token)
self.client.rtm_connect()
q = queue.MessageQueue()
q.watch(self)
count = 0
while True:
try:
for response in self.client.rtm_read():
self.log.debug(response)
if all(x in response for x in ("text", "channel", "user")):
if count == 0:
# NOTE(jk0): rtm_read() often times comes back with
# old messages after reconnecting. Let's attempt to
# ignore them here.
def create_client(self, channel=None, chan_id=None, as_bot=False):
chan_id = (chan_id or (
self.config['SLACK_CHANNEL_NAME_TO_ID'][channel] if channel
else first(self.config.channels)))
chan_cfg = self.config.channels[chan_id]
token = chan_cfg['oauth_token' if not as_bot else 'bot_oauth_token']
return SlackClient(token=token)
def _fetch_slack_client(config, secrets):
try:
slack_token = config.slack.token
slack_token = slack_token.strip()
except AttributeError:
return None
else:
if not slack_token:
return None
return slackclient.SlackClient(slack_token)