示例#1
0
def _post_to_slack(channel_name, tweets, twitter_username):
    """Twitter Slack app unfurls URLs in Slack to show tweet details"""
    url = "https://twitter.com/{username}/statuses/{id}"
    for tweet in tweets:
        tweet_url = url.format(username=twitter_username, id=tweet.id)
        chipy_slack.post_message(tweet_url, channel=channel_name)
        kv_store.put_int(LAST_TWEET_KEY, tweet.id)
示例#2
0
 def save_and_post_video(self, video):
     video_title = video["snippet"]["title"]
     video_id = video["id"]["videoId"]
     video_url = f"https://www.youtube.com/watch?v={video_id}"
     msg = f"[Busy Beaver] YouTube Video Poll -- posting {video_title}"
     logger.info(msg)
     youtube_video = YouTubeVideo(
         youtube_id=video_id,
         title=video_title,
         published_at=video["snippet"]["publishedAt"],
         description=video["snippet"]["description"],
     )
     db.session.add(youtube_video)
     db.session.commit()
     slack_msg = f"A new video has been released: {video_url}"
     chipy_slack.post_message(slack_msg, channel=self.channel)
    def post(self):
        data = request.json
        logger.info("[Busy Beaver] Received event from Slack",
                    extra={"req_json": data})

        verification_request = data["type"] == "url_verification"
        if verification_request:
            logger.info("[Busy Beaver] Slack -- API Verification")
            return jsonify({"challenge": data["challenge"]})

        # bot can see its own DMs
        event = data["event"]
        msg_from_bot = event.get("subtype") == "bot_message"
        if event["type"] == "message" and msg_from_bot:
            return jsonify(None)

        dm_to_bot = event["channel_type"] == "im"
        if event["type"] == "message" and dm_to_bot:
            chipy_slack.post_message(HELP_TEXT, channel_id=event["channel"])
        return jsonify(None)
示例#4
0
def _post_to_slack(message):
    chipy_slack.post_message(message=message, channel="busy-beaver-meta")
示例#5
0
def post_upcoming_events_message_to_slack(channel: str, group_name: str,
                                          count: int):
    blocks = generate_upcoming_events_message(group_name, count)
    chipy_slack.post_message(blocks=blocks, channel=channel)