| Windows Live Ag... 的个人资料Windows Live Agents照片日志列表 | 帮助 |
|
6月30日 It's all about context!
Today we're going to talk a bit about contexts and what wonderful things you can do with them. Well, maybe not "Wall-E opening sequence" wonderful, but they sure come in handy to control what your agent is doing in an easy and trouble-free way. With the help of contexts you can separate clearly your routines according to any condition, without having to worry about micro-managing their scores or doing systematic checks. We're going to take a closer look at a few different uses and related buddyscript features, from the very simple to... the wee bit advanced. Tomorrow we'll explore another use for them, and discuss public variables and performance issues.
Here is how, for example, you could make sure that only users on MSN get access to the activity window features:
context MSN_Only {out-of-context="0" in-context="100" condition="SYS.User.Service eq \"MSN\""} // out-of-context: score adjustment for the queries inside the context that don't verify the condition (here, 0 = no match) // in-context : score adjustment for the queries inside the context that do verify the condition (here, 100 = no adjustment)
start context MSN_Only
? Start the activity. - Sending you an invitation...
end context MSN_Only
An interesting thing to note is that you don't have to end the context at the end of our file. If you were to start the context in a package, then every domain including this package, directly or indirectly, would be within that context and abide by its rules. So here you could have all domains related to Activity Window include this package, and be protected automatically. You could apply this principle to restrict certain features or queries based on any condition, like age, country, market, number of visits or what the user's high-score is at your quizz game.
You can also restrict access to the agent even though it's launched and live on Messenger, while it's in development or beta phase:
// This table lists the screennames of authorized users // Using "exact" as an index method will help make searches more performant datatable AuthorizedUsers load ScreenName {index="exact"} from mememe@hotmail.com uberbetatester@live.com popaandmoma@live.com mygloriousboss@live.com
function UserIsAuthorized() if ShellMode() // Shellmode() returns true if we're in the SDK return true SN = get ScreenName in AuthorizedUsers where ScreenName is SYS.User.ScreenName // Found the screename: access granted! return true return false
// Here the in-context is set to 1000 to make sure that any other routine is overruled. context Unauthorized {out-of-context="0" in-context="1000" condition="!UserIsAuthorized()"}
start context Unauthorized
+ =AnythingStrong - Sorry, I'm in closed beta phase and can't talk to you yet. No peeping!
// Within a context, regular matching still happens as they're all subject to the same adjustment. ? But I am a Very Important Person! - The Boss said: no exceptions.
end context Unauthorized
Another use, very similar in implementation, is to restrict certain debug or testing queries to a set of super-users, listed this time in a text file. The textfile-based table is easier to maintain independently from the code, and can be changed without having to restart the agent: all you need is to set an expire date for the file to be reloaded.
datatable SuperUsers {expire="in one day"} // The list will be timed out and reloaded once a day from the file. load ScreenName {index="exact"} from file superusers.txt
function IsSuperUser() if ShellMode() return true SN = get ScreenName in SuperUsers where ScreenName is SYS.User.ScreenName return true return false
context RestrictedStrings {out-of-context="0" in-context="100" condition="IsSuperUser()"}
start context RestrictedStrings
// This topic is only accessible to the right people: + debug all variables - As you wish. dbg_display STORED_USER_VARIABLES
That’s it for today. See you tomorrow for another round of goodies!
6月26日 5.0 Transition Update!Hello Developers and Partners of Windows Live Agents,
We are very excited that 5.0 is here! We have received many questions from all of you regarding the transition from 4.3 to 5.0. Windows Live Agents Partner Support is no longer accepting projects developed in 4.3. All agent projects should be developed in 5.0 using our SDK in Visual Studio and submitted through our Partner hosting site at http://phi.agents.live.com. If you send us a new project developed in 4.3 or 5.0 via email, we will unfortunately not be able to accept it. If you have not already downloaded the 5.0 SDK in Visual Studio, you can do so here. For instructions on getting started with hosting, please click here.
If we are currently hosting an agent of yours that was developed in 4.3, please continue to send us updates in 4.3 via email. We will let you know when we are ready to migrate your project from 4.3 to 5.0.
Thanks, Windows Live Agents Team 6月23日 Messenger Screen Name Parameters UpdaterQuite often we hear from partners who complain that the screen name, personal status message, or display picture of their agent has disappeared from the Messenger client, and ask us to fix it. Strictly speaking, the display of these parameters in the client is subject to forces outside the control of the Windows Live Agents group, however we continue to work with those in charge of the Messenger network to resolve issues like this.
In the meantime, here is the code we use to "fix" the problem. If you are not already doing so, you should be using Method 3 from this blog post about changing friendly names, icons, and status messages. Updates to these Messenger parameters via edits to the BFG are no longer supported after 4.3!
To add the screen name parametes updater, simply include these lines in your project:
call WLMSetUpScreenNameParameters()
6月2日 Scripting tips: conversations 4/4 Using actionsGreetings,
We often design dialogs in BuddyScript to answer to user queries in a specific context. We will see today how by using actions, we can have initiate and notify to answer dialogs, and what can be the use. A dialog is a set of dialog entries that leaves in your script. A dialog entry is some matching information and a script block associated with. The matching information part usually contains patterns, but can contain actions. An action has a name and potentially parameters. The first example is a trivia with timer. // Trivia with timer
? Play trivia - Let's play trivia in what year was the Eiffel Tower built ? in 1889 {action=Right()} in 1943 {action=Wrong()} in 2001 {action=Wrong()} You have 30 seconds to answer NID = notify in 30 seconds: action TimeOut() ? 1889 action Right() - That is correct! ? 1943 ? 2001 action Wrong() - Nope, the correct answer is 1889. action TimeOut() - Too late, the correct answer is 1889.
At first, you can see a common use of actions, and that is with an enumeration. Typing 1 will trigger the action Right, typing 2 or 3 will trigger the action Wrong. Or you can fully type the date and match one of the three patterns. Then, you will notice the action in the notify. After 30 seconds, the notification will answer the dialog for you. If you do respond before the notification triggers, it would be wise to cancel the notification, but if you don’t, that’s ok because when the notification will trigger, no dialog with a TimeOut action will be active and the notification will simply be ignored. Initiates can also use actions, but through the respond statement. The syntax is: RID = respond SOURCE: action MyAction(PARAMS) The SOURCE is an object that contains the user identity (screenname, service and UID), the buddy id and the conversation id to send the action to. Most of the time, you are coming from an initiate and you simply pass the object from SYS.ConversationSource. Don’t forget to save that object in a variable if you have a dialog, because this variable won’t survive the dialog. A typical use for this statement is to get information from another user’s profile. In the following example, I have altered the “Do you know my friend” example to display a friendly name that the friend may have provided. // Do you know my friend(oh you mean Jacky ?)
stored variable PREFERRED_NAME = ""
? Call me NAME=AnythingRaw PREFERRED_NAME = NAME - Ok, for now on, I will call you PREFERRED_NAME
procedure GetPreferredName() if PREFERRED_NAME = "" NAME = SYS.User.ScreenName else NAME = PREFERRED_NAME CID = respond SYS.ConversationSource: action SetName(NAME)
? Do you know EMAIL=AnEMailAddress ? RESULT_NOLOAD = initiate EMAIL, "MSN": GetPreferredName() {createprofile=false loadprofile=false} if RESULT_NOLOAD.Delivered IN_SESSION = true else IN_SESSION = false RESULT_LOAD = initiate EMAIL, "MSN": GetPreferredName() {createprofile=false loadprofile=true} if !RESULT_LOAD.Delivered - Sorry, I can't say that I do exit action SetName(NAME) if NAME != EMAIL - Oh, you mean NAME ? \c - Yes, I know that guy\c if IN_SESSION - , and he/she's talking to me right now. else - .
This script calls GetPreferredName under the friend’s profile, this procedure will respond by sending the preferred name. The script will wait in a dialog to get that answer.
You can also constantly exchange information back and forth between users with respond. You just need one initiate to initiate the dialog. Here is another example that lets two users chat through the agent. // Chatter
declare procedure InviteToChat(NAME) declare procedure Chat(SRC)
? I want to chat with EMAIL=AnEMailAddress - Ok, let me invite your friend over CID = initiate EMAIL, "MSN": InviteToChat(SYS.User.NickName) {createprofile=false loadprofile=true} action Accept() - Ok, your friend has accepted, you may chat now. call Chat(SYS.ConversationSource) action Reject() - Sorry, your friend has declined the offer. action NoResponse() - Hmm, nobody replied...
procedure InviteToChat(NAME) - Hey, your friend NAME would like to chat with you, do you want to accept ? set user conversation SRC = SYS.ConversationSource NID = notify in 30 seconds: action TimeOut() ? Yes - Great, let's start chatting... RID = respond SRC: action Accept() call Chat(SRC) ? No - Fine. RID = respond SRC: action Reject() action TimeOut() - Hmm, you must not be here... RID = respond SRC: action NoResponse() insist: Please, say Yes or No.
procedure Chat(SRC) - Type "quit" to quit the chat. ? TEXT=AnythingRaw RID = respond SRC: action SendText(TEXT) restart dialog action SendText(TEXT) - TEXT restart dialog ? Quit RID = respond SRC: action Quit() - You have terminated the conversation action Quit() - Your friend has terminated the conversation
Have fun with all that.
damien |
|
|