def tell_leaderboard(self, msg: Message): logging.error(f'tell_leaderboard, {msg}') # test for a while from_time = get_this_monday() text = _get_leaderboard_msg_text('本周排行榜', self.users, from_time=from_time) msg.say(text)
def blocks(self, msg: Message): """blocks: show some rich messaging magic""" bx = [ blocks.SectionBlock( text="*Markdown formatted* text with _italics_ if we want", fields=["*Left*", "*Right*", "line 2 left", "line 2 right"], accessory=elements.ImageElement( image_url="http://placekitten.com/700/500", alt_text="cute kitten")) ] msg.say("fallback", blocks=bx)
def respond_to_command(self, msg: Message, arg: str): arg = arg or '' args = list(filter(None, [a.strip() for a in arg.split()])) try: arguments = docopt(self.__doc__, args) except DocoptExit as e: msg.say(e.usage, msg.thread_ts) return if arguments.get('-h') or arguments.get('--help'): msg.say(self.__doc__, msg.thread_ts) self.process_arguments(msg, arguments)
def subcommand_invite(self, msg: Message, arguments: dict): msg.say('正在申请注册链接,请耐心等候...', msg.thread_ts) c = delegator.run('python commands/yuque.py invite', cwd=os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) if c.ok: msg.say(f'注册链接为: {c.out}', msg.thread_ts) else: msg.say(f'error: {c.err}', msg.thread_ts)
def subcommand_add(self, msg: Message, arguments: dict): name = arguments.get('<name>') c = delegator.run(f'python commands/yuque.py add-to-tech-team {name}', cwd=os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) if c.ok: msg.say(f'已加入语雀技术组', msg.thread_ts) else: msg.say(f'加入语雀技术组出错', msg.thread_ts) msg.say(c.err, msg.thread_ts)
def blocks_raw(self, msg: Message): """blocks raw: show some rich messaging magic. Uses raw dict for specifying blocks""" bx = [{ "type": "section", "text": { "type": "mrkdwn", "text": "Hello, Assistant to the Regional Manager Dwight! *Michael Scott* wants to know where you'd like to take the Paper Company investors to dinner tonight.\n\n *Please select a restaurant:*" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Kin Khao*\n:star::star::star::star: 1638 reviews\n The sticky rice also goes wonderfully with the caramelized pork belly, which is absolutely melt-in-your-mouth and so soft." }, "accessory": { "type": "image", "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/korel-1YjNtFtJlMTaC26A/o.jpg", "alt_text": "alt text for image" }, "fields": [{ "type": "mrkdwn", "text": "*Priority*" }, { "type": "mrkdwn", "text": "*Type*" }, { "type": "plain_text", "text": "High" }, { "type": "mrkdwn", "text": "String" }] }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Farmhouse Thai Cuisine*\n:star::star::star::star: 1528 reviews\n They do have some vegan options, like the roti and curry, plus they have a ton of salad stuff and noodles can be ordered without meat!! They have something for everyone here" }, "accessory": { "type": "image", "image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/c7ed05m9lC2EmA3Aruue7A/o.jpg", "alt_text": "alt text for image" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Ler Ros*\n:star::star::star::star: 2082 reviews\n I would really recommend the Yum Koh Moo Yang - Spicy lime dressing and roasted quick marinated pork shoulder, basil leaves, chili & rice powder." }, "accessory": { "type": "image", "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/DawwNigKJ2ckPeDeDM7jAg/o.jpg", "alt_text": "alt text for image" } }, { "type": "divider" }, { "type": "actions", "elements": [{ "type": "button", "text": { "type": "plain_text", "text": "Farmhouse", "emoji": True }, "value": "click_me_123" }, { "type": "button", "text": { "type": "plain_text", "text": "Kin Khao", "emoji": True }, "value": "click_me_123" }, { "type": "button", "text": { "type": "plain_text", "text": "Ler Ros", "emoji": True }, "value": "click_me_123" }] }, { "type": "section", "text": { "type": "mrkdwn", "text": "You can add an image next to text in this block." }, "accessory": { "type": "image", "image_url": "https://api.slack.com/img/blocks/bkb_template_images/plants.png", "alt_text": "plants" } }] msg.say("fallback", blocks=bx)
def reply_help(self, msg: Message): msg.say(trim_doc(self.__doc__), msg.thread_ts)