Enter ConversationHandler ignoring entry_points - telegram

I'm using python-telegram-bot wrapper to create NLP based chatbot and I want users to have an option how to use the bot:
InlineKeyboardButton menus
natural language conversation
For the first option I am having several ConversationHandlers defined, most of them are having entry_points defined as single CallbackQueryHandler:
location_handler = ConversationHandler(
entry_points=[
CallbackQueryHandler(
callback=nearest,
pattern=NEAREST_CB
)]
And for the second option I am using MessageHandler:
text_message_handler = MessageHandler(Filters.text & (~Filters.command), call_model)
I wanna enter one of those ConversationHandlers whenever my model (call_model function) returns an appropriate tag, but have no idea on how to do it.

text_message_handler = MessageHandler(Filters.text & (~Filters.command), call_model)
I wanna enter one of those ConversationHandlers whenever my model (call_model function) returns an appropriate tag, but have no idea on how to do it.
call_model is your handler callback, though, right? The callback can't determine whether or not the handler is executed.
That is the job of the handler. So you should probably implement either a custom filter to use with MessageHandler or just a custom handler and put your NLP logic in there. Please see this page for details on custom filters and this page for the abstract Handler class that you'd need to implement for a custom handler.
Disclaimer: I'm currently the maintainer of python-telegram-bot

Related

Subclass INObject?

Can one subclass INObject?
I ask because I have an Intents Handler Extension for Siri Shortcuts. I attempted to create a subclass for INObject because I want to add an extra property. Seems like it works just fine here.
However, I also have an Intents Handler UI Extension. When my response object gets to this point, I have a handle on the INObject and its identifier and display string. But, when I try to cast it to my custom INObject sublcassed type, the result is nil and therefore I cannot access my custom property.
Does anyone know how to pass custom properties from the Intents Extension to the Intents UI Extension using the custom INObject?
Apple Engineering got back to me that this is not supported.

Why does the error occurs then I try to utilize pzRDExportWrapper in Pega 7.1.8?

I have a task to export a repeat grid's content to Excel. I have read an
article, but I still can't realize how to properly use it. I tried to repeat article's steps to provide pzRDExportWrapper, but after I click "Save" button I get the error:
Method: Rule-Obj-Activity instance not found:
Sb-FW-CTrackFW-Work.pzRDExportWrapper. Details: Invalid value for
Activity name passed to ActivityAssembler.
Could anybody give me any suggestions? Thank you.
You invoke activity from another activity which applies to class Sb-FW-CTrackFW-Work. Rule Resolution use primary context Sb-FW-CTrackFW-Work class and try invoke activity pzRDExportWrapper from it and you get error (because rule resolution can't found invoked activity in this class).
Activity pzRDExportWrapper applies to Rule-Obj-Report-Definition class. Try invoke from it.
Try activity step as below:
Call Rule-Obj-Report-Definition.pzRDExportWrapper
Or use step page for this step which defined as applies to Rule-Obj-Report-Definition class(you can declare it on Pages&Classes tab)
Okay. I have resolved the issue (thank you njc). I have two sections on a lone web page.
A context of the first section is my custom data page Co-Name-FW-Data-Search. The Search page has some single value properties which are initialized by an user via an UI.
The second section is a repeat grid section, a report definition as a source. My Search page pointed out in a Pages and Classes tab. Also there is a Page, which is created by report definition and contains results. The report definition takes Search’s values as parameters.
So, I have created an activity and passed the Search page and a Cods-Pega-List MyResultList as parameters. There are some steps in the activity:
Check if Search is null. If true- skip step; else - transfer Search properties into Params props with Data Transform.
Set Param.exportmode = "excel"
Call pzRDExportWrapper with Step Page MyResultList.pyReportDefinition. Pass current parameter page.
P.S.: If it doesn’t work try to play with report definition’s settings.
P.P.S.: An only minus of pzExportWrapper is that it invokes report definition again.

How to get the form name in class?

I have a form which is used for automatic journal postings.
On that form I have a Ok command button and in closeOk method of the form I call the method from my datasource table.
In the JournalCheckPost class's infoResult() method I want to determine if the method is called from my form. I know that it can be done with caller methods but I don't know how exactly it should be done technically.
It is bad practice to make a method depend on where it is called from.
What you can do is to pass an extra parameter to the LedgerJournalCheckPost and infoResult can then check that. This can be done by introducing a boolean flag and a parm method.
I think, there can be many situations:
You want to pass some parameters from form
You want to manipulate the form (for example refresh datasource after action is complete)
Something other
But in all the cases depending on particular form is not a very good idea.
In first case you can set parameters from code using parm methods, or, better pass parameters using the Args class
In the second you can cast Args.caller to some interface that contain all the methods you want and manipulate the form using that methods (see \Classes\SysFormRun_doRe usages for example)

Set highlighted record on a list page through code on called object

On the CustListPage I have added functionality on the ribbon which opens a popup/dialog form from where you can see related Customers.
How do I, on selection of one of the related customers on my dialog, jump to that customer on the listpage?
What I’ve tried so far:
I’ve added a method (lets call it setActiveRecord) on the CustTableListPageInteraction class that should set the activeRecord on the listpage to the record I’m passing to this method. I’m passing the CustTableListPageInteraction class to the dialog form, using a parm method. Now on my dialog form I can see that I receive the CustTableListPageInteraction class. However, I’m unable to execute my method setActiveRecord on the CustTableListPageInteraction, because I get a “object not initialized”.
What is the best route to follow to update a ListPage from a called object? Because the listpage is driven by the class, I find it very difficult to pass parameters back.

Logging method name , input parameters , date and time with using Attribute

i just want to make a class that inherited from Attribute class to put attribute tags in every method in my project to write the method name , Class name that have this method , date and time of calling , parameters and method's return ( if it's return something ).
i create a table in SQL Server that will receive all log information and sign it ..
i have done all the methods & query that interact with my database ( except Date & Time method) , the only problem is i don't know how to use it with Attribute way to get the information i have mention.
If you want logging with attributes, you may use PostSharp that modifies IL during compilation of your code and puts your logging codes before/after the method that you put your custom attribute derived from PostSharp's attributes (aspects)(AOP).
I think you can not do this only by use of custom attributes, because as I know custom attributes are instantiated only when Type.GetCustomAttributes() is called. So you may have to do some reflection business for sending your logs through your attributes that I don't recommend.
Instead of attributes, you can simply use AOP through a third party tool. You can use Castle Dynamic Proxy 's interceptor.
You can also log with attributes by using Interception in Castle Windsor.
To do this, you create a class that inherits from IInterceptor, register it with your container, then you can add an attribute to any class or method you want to add the logging behaviour to.
I've written an explanation here:
http://www.paulsodimu.co.uk/Post/Aspect-Oriented-Programming-Using-Castle-Windsor
And I've created a sample on GitHub to show how its done:
https://github.com/PaulSodimu/LoggingAopCastle

Resources