I want to built a custom Telegram client for android with a function to save messages into file. As a base project, I'm using official source code: https://github.com/DrKLO/Telegram
And I can't find a way to actually get a message. In Documentation for Telegram mentioned method getChatHistory https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1get_chat_history.html
But I don't see any usage of the API in their code. Instead, they are used custom classes somehow similar to API. And the general class for any actions with messages is MessageObject. I can get the text content of this object by using this
message.messageText.toString();
where message is object of class MessageObject, but how I can create this object?
The supposed workflow is: when interested chat is opened, besides already existed common buttons, custom button for save message is appearing, after tapping this button, begins a cycle in which we create object of class MessageObject start with id of last message in chat, we extrating a text from this message, and saves it a file.
Related
using Wit.ai HTML api.
Posting /converse message I get the response of type:action with action name, then I execute some my own code. How then make POST with context-key to wit API to get an answer from the robot?
Also how to trigger robot message when user do not need to say anything?
Your own code (the action you need to run) is responsible for updating the context (e.g. adding a key "forecast" with value "sunny"). In your Wit.ai /converse calls, you provide the context in the body.
See the example in the documentation: https://wit.ai/docs/http/20160526#post--converse-link
You can call your send action when you want to trigger a robot message.
I'm using facebook sdk to share details to facebook and it works fine. Now my question, is there a way to set description to "What's on your mind?" text field.
Feed Dialogs (deprecated) used to have a message parameter earlier, but facebook removed. Also, there's no way to pre-populate the message in the Share Dialog.
They have removed this purposely in the UI Dialogs. If you are posting a feed using the API (not dialog), then only you can populate the message with message parameter.
The abcd text is the description of the link that you (or the link admin) have provided; but the message is related to user and in case of dialogs, facebook expects that the user himself should give any message if he wants to, it should not be app-written.
I'm a beginner java user, and beginning streamer on Twitch.tv. I have been working on developing an IRC bot all night that would streamline moderation on my channel (I want to have that level of customization that using a cookie cutter IRC bot can't give).
One thing that is stumbling me is poll creation. I have looked through the Pirc javadocs and there is no command as far as I can see that checks for messages sent by a channel op, which is crucial to keeping trolls from creating polls, and with my limited knowledge I do not know how to grab extra parameters from a message.
What I want is this:
!poll <question> <c1> <c2> <c3> <seconds>
Any help here? I will add you to my thanks screen on my outro for each stream.
From my quick look through the PIRC javadocs, it looks like the method you want is #onMessage(String channel,
String sender,
String login,
String hostname,
String message)
From here, you can get any information required. Now depending on how you're handling incoming messages, all you need to do it search for the command, which in this case is "!poll" which you'll receive from the message string. From there, you can further parse the information, and do what you want with it.
If you haven't been using them already, the javadocs for pirc are location here: http://www.jibble.org/javadocs/pircbot/index.html
As Jdsfighter said, you need to use the onMessage(...) method from the PircBot superclass. This method is called whenever a message is sent to your channel. I kinda assume you have understood this by now, as making the bot react to chat is alpha and omega when making an IRC bot.
When concerned with Moderators (Operators in IRC terms), the Twitch IRC servers behave in a way that isnt completely understood by PircBot, and I have not been successfull with the User.isOp(...) method from the User class. What I've found successfull is to include the following in my Bot class (not the main class):
Set<String> OPs = new HashSet<String>();
protected void onUserMode(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient) {
recipient = recipient.split(" ")[2];
OPs.add(recipient);
}
This Method is called whenever you see a line begining with MODE in the console, like this one:
jtv MODE #channel +o moderatorName
Now, you need to make a method that is called whenever the message recieved starts with "!poll", and checks if the sender of the message is in the OPs Set.
Here's an outline for you, to be placed in the onMessage() method
if (message.toLowerCase().startsWith("!poll") {
if (OPs.contains(sender)) {
//TODO Add body
}
}
Now you just have to make some code that catches the rest of the line after "!Poll" and posts a message back to the channel about the different poll options.
You obviously need somewhere to store your alternatives and how many votes they get each, I suggest simply two arrays, one String[] and one int[].
Here is what I am trying to do:
Add a special button to attach files to Notes "New message" window. If files were attached using this button, when email sent, they should be uploaded to the server and link to them added to the email.
My question - is it possible (and how) to capture "send mail" event in the plugin for Lotus Notus?
I don't know how an Eclipse plugin would do this. Furthermore, since Notes can be used off-line -- when it would be impossible to upload files to a server -- it would be better to have code running on the Domino server intercept the mail messages and perform the upload.
Most products that hook mail operations on the server use the Lotus Notes C API's Extension Manager functions to hook the EM_BEFORE notification for the EM_NSFNOTEUPDATE event and check whether the NSFNoteUpdate operation occurred within the server's mail.box files, and then check whether the the message requires special processing (i.e., in your case that would be by looking for a special NotesItem that your button code has inserted into the message). The usual coding method for this is to immediately change the status of the message to put it on hold, preventing the Domino router from attempting to send the message while your code is still working on it. Many products actually have two components - the EM hook DLL and a separate server task that receives a signal from the hook DLL, processes the message, and then releases it from on hold status. This approach keeps your code from tying up router threads while processing large files.
(Note: Newer versions of the Domino server have the ability to use OSGI plugins written in Java instead of using the Notes C API for operations like this. I've not looked into the details of how this might work for operations that process mail messages. )
I sort of figured it out. There is a very nice extension point provided in 8.5 - "com.ibm.notes.mailsend.MailSendAttachmentsDialog", that is specifically exists for custom handling of attachments. You can see it in plugin.xml, in IBM\Lotus\Notes\framework\shared\eclipse\plugins\com.ibm.notes.mailsend_8.5.*.jar.
The only problem is - it handles just attachments and does not have access to anything else. So if somebody figured how to get subject line and the message text from there, please reply.
Update: got it.
NotesUIElement elem = (new NotesUIWorkspace()).getCurrentElement();
if (elem instanceof NotesUIDocument) {
NotesUIDocument doc = ((NotesUIDocument) elem);
String to = doc.getField("EnterSendTo").getText();
String cc = doc.getField("EnterCopyTo").getText();
String bcc = doc.getField("EnterBlindCopyTo").getText();
String subject = doc.getField("Subject").getText();
String body = doc.getField("Body").getText();
....
}
I am working on application that reads input from email and do action according to it.
My application should listen for any new emails and parse it to get attachment file and data inside the body.
My question is: How can I do that in java? how to do that listener in java?
I have an email that I will use to parse received from, but what I want how to listen to any new email and parse data from it.
You probably want to take a look at JAMES. This offers all the functionality you require.