You can either use the Activities API and specify an @mention argument, or use a manual RealTimeEventListener. The User ID is contained within the event but you'll need an additional call to obtain other user attributes like email address.
Activities API
activities = bdk.activities()
@activities.slash(command = "/hello1 {@user}", mention_bot = False)
async def hello(context: CommandContext):
user_id = context.arguments.get_mention('user').user_id
email = (await bdk.users().list_users_by_ids(user_ids=[ user_id ])).users[0].email_address
await bdk.messages().send_message(context.stream_id, f"User ID is {user_id} {email}")
RealTimeEventListener
datafeed_loop = bdk.datafeed()
class MessageListener(RealTimeEventListener):
async def on_message_sent(self, initiator: V4Initiator, event: V4MessageSent):
msg = message_parser.get_text_content_from_message(event.message)
mentions = message_parser.get_mentions(event.message)
if (msg.startswith('/hello2') and len(mentions) > 0):
user_id = mentions[0]
email = (await bdk.users().list_users_by_ids(user_ids=[ user_id ])).users[0].email_address
await bdk.messages().send_message(event.message.stream.stream_id, f"User ID is {user_id} {email}")
datafeed_loop.subscribe(MessageListener())