Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Symphony Bot with selenium web driver?

I am writing to ask for your advice on whether I can achieve the following with Symphony API.

When there is a message on symphony group chat, for example, “/re” + “sth”, I'd like a selenium web driver to conduct some automated actions based on that "sth".

May I ask if you could please advise whether this would be possible or not?

  
  
Posted one year ago
Votes Newest

Answers 2


So below is an example in Python on how your bot can extract arguments from a Symphony chat message.

@activities.slash("/echo {first_string_argument} {second_string_argument}")
async def on_echo_string_arguments(context: CommandContext):
#Get string argument with get_string
first_string_argument = context.arguments.get_string("first_string_argument")
# Get string argument with get_as_string
second_string_argument = context.arguments.get_as_string("second_string_argument")
message = f"Received arguments: {first_string_argument} and {second_string_argument}"
await messages.send_message(context.stream_id, f"<messageML>{message}</messageML>")

In the example we are just returning the values back to the user in the form of a Symphony message. But you could invoke your own business logic (including a Selenium web driver class) to carry out another action.

1
1
Posted one year ago
Vinay Mistry
23 × 2 Administrator

Here is a full example which may help also referenced from the same page shared previously.

from symphony.bdk.core.activity.command import CommandContext
from symphony.bdk.core.config.loader import BdkConfigLoader
from symphony.bdk.core.symphony_bdk import SymphonyBdk


async def run():
    async with SymphonyBdk(BdkConfigLoader.load_from_symphony_dir("config.yaml")) as bdk:
        activities = bdk.activities()
        messages = bdk.messages()

        @activities.slash("/buy {$ticker} {quantity}")
        async def on_echo_mention(context: CommandContext):
            ticker = context.arguments.get_cashtag("ticker").value # can also be retrieved with context.arguments.get("ticker").value
            quantity = context.arguments.get_string("quantity")
            
            message = f"Buy ticker {ticker} with quantity {quantity}"

            await messages.send_message(context.stream_id, f"<messageML>{message}</messageML>")
  
  
Posted one year ago
Vinay Mistry
23 × 2 Administrator
  
  

May I ask a follow-up question?

If the case is:
Person A has said /buy {$ticker} {quantity} 1 minute ago and 1 hour ago respectively, and I want to open this bot to execute only the command for the request 1 minute ago (since I have executed the command for the 1 hour ago request already), can this be done?

Thank you

CY Wong   one year ago Report
2K Views
2 Answers
one year ago
one year ago
Tags
api