def scheduled_message(): # Unix Epoch time client = WebClient(token=os.environ.get("SLACK_BOT_TOKEN")) try: time_to_post = 1609290542 channel_id = os.environ.get("CHANNEL_ID") client.chat_scheduleMessage(channel=channel_id, post_at=time_to_post, text="Hello this is a scheduled message") except SlackApiError: print("Some error occured")
def test_missing_text_warnings_chat_scheduleMessage(self): client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test") resp = client.chat_scheduleMessage(channel="C111", post_at="299876400", text="", blocks=[]) self.assertIsNone(resp["error"])
token = config.get('token') qotd_hook = config.get('qotd_hook') hello_hook = config.get('hello_hook') if args.verbose: print("Token: {}".format(token)) print("QOTD: {}".format(qotd_hook)) print("Hello: {}".format(hello_hook)) pokemon = Pokemen.select_pokemon(number=args.pokemon) print("Pokemon: {}".format(pokemon.display_name())) if token and len(token) > 0: client = WebClient(token=token) name, png = pokemon.png() client.users_setPhoto(image=png) client.users_profile_set( profile={'status_text': pokemon.display_name()}) client.chat_postMessage(channel='#pokecards', text=pokemon.display_name(), blocks=get_card_blocks(pokemon)) client.chat_scheduleMessage(channel='#dev-ios', post_at=get_time_in_future(), text=get_greeting()) if qotd_hook and len(qotd_hook) > 0: webhook = WebhookClient(qotd_hook) if not args.dryrun: webhook.send(blocks=get_qotd_blocks(pokemon))