def post_message(self, channel_name):
# self.channels_history(channel_name)
os.system("echo '\u001b[1m\u001b[31m To mention a user write @ while chatting \u001b[0m'")
text = prompt("your message > ", completer=WordCompleter(users))
channel_id = self.find_channel_id(channel_name)
url = "https://slack.com/api/chat.postMessage?token={token}&channel={channel_id}&text={text}&as_user=true&link_names=1".format(
token=settings.token,
text=text,
channel_id=channel_id)
response = requests.get(url).json()
# TODO : retrieve message history and print to screen while chatting
if response["ok"]:
os.system("figlet 'Sent' | lolcat")
time.sleep(2)
os.system("clear")
else:
print "something goes wrong :( (\u001b[1m\u001b[31m " + response["error"] + "\u001b[0m)"
评论列表
文章目录