How to make chatbot application in Android using Openfire and XMPP - java

I want to make on Android application in which i can create one user which acts like chatbot. On chat window when user type any thing and send then instead of other user reply to that question my custom function on open-fire reply static message. I am new to openfire. Not sure how to achieve this. So far i have installed XMPP server and openfire server on my system and i am able to do one to one chat using Pigdin and Spark.
To achieve what i need should i make android application in which i write some custom function or do i have to make custom plugin for openfire. I was doing some RND on this got below some reference :-
https://community.igniterealtime.org/docs/DOC-1130
But reading this i am still confuse what to do and how to do. Can any one please help me out here, and thanks in advance.

One possibility can be:
User A is using your android application, User B is logged-in on Openfire using any server side XMPP library (for example: smack).
Now whenever User A sends message to User B, it will be routed to User B and there you can respond to it from code.
Or
Instead of implementing User B part, you can write an Openfire plugin which will be checking every message packet, if recipient is User B, you can respond to that message from there.
Regarding your posted link of Botz, first of all it's too old. Secondly it seems like it does almost same thing which i wrote above when writing a plugin.

Related

How to send regular(not via bot) message in telegram knowing chatId

I develop a telegram bot in Java. One of the wanted function in my bot I want to see is the opportunity to invite users by other ones. I tried to make it works next way: the user sends forwarded message from the user he wants to invite to bot, program extract chat id of invited user by:
update.getMessage().getForwardFrom().getId();
and then send a message for invited user. But Telegram doesn't allow to start a conversation with a user before he tapped to "/start" button, and after user has done this, described function stops having any sense.
So what I'm looking is some way to send message to user from regular(not bot) account by using, for example, json request such as we can use in bot api. Is there some way to do it?
Yes, there is the MTProto Protocol which allows you to build a custom Telegram application, There are several libraries that implemented it.
It basically lets you program a user-bot, which gets triggered by particular commands/events and responds correspondingly.
A java library I found is telegram-s/telegram-mt but it doesn't seem to be active at all.
I suggest you implement it easily in Python with libraries such as Pyrogram.

Mqtt Check if a client is online or offline

I am using mqtt and mosquito broker to build a simple instant chat for an android platform. Now I wanted to implement a condition where any client can check if another client is online.
I know about Last will and testament but I wanted a user to be detected offline only wen the application is inactive or the user is not currently using the app.
I actually dnt need any code, buh wanted an idea as to how to implement this and I would be much grateful.
You can do this without relying on MQTT internals which is much easier in my view. With this approach, you have much more control over what is going on:
The client can periodically send a message within another topic to inform the server of its availability. In case the server does not receive that message after a specified amount of time, it can assumed that it is offline.
The client can also send another message if the user logs out and inform the server a well.
If you insist on using MQTT internal structure, you may find this question useful:
How to Find Connected MQTT Client Details

Java Server for Android Application

I need to write a server in java that will store integers that are used as stats for my android app. My app has an SQLite database that is already setup that would be useful if I could just pass those contents to the server. I need to do this so that in my multiplayer feature, a player's app will contact the server to know what level their opponent is. (This is not real time). So far I only have a TCP server that opens a client and server socket. Other than that I am not positive what I need to do to make it possible for the server to do what I need. Anyone have suggestions or good tutorials to help me with my problem?
Thanks.
One thing you need to keep track of:
Your SQLite DB has to be used as a player session, until the player logs in as another user. To do this, you have to have one instance of the current logged in player. If you prefer other methods, here's a good list.
I don't think you would need a TCP connection to view the stats, instead implement a REST API in PHP or any other language for back-end that would save, update and look up for a particular player. This is a recommended method. If you are familiar with PHP, this tutorial will give you an idea and full details of what I mean.
Indeed, building a server has many methods. For example, You can use either socket programming or app-server. If you are familiar with web programming, jsp/php/asp.net, you can communicate between your app and server with HTTP requset, which is easy to do.
To be more specific, someone (neme:abc,password:pwd) logging in with your mutiplayer app, when he or she leaves, send the data to server with HTTP request. Then when he or she logging in with other device, you can get the data from status and continues to play. Of course, you can save the data in local with SharedPrefence in Android, too.
By the way, the apache HTTPClient is recommend when using http connection with server.

Java How to send an email/sms from a Users computer

I want to send a User an email or SMS to his SmartPhone when an Alert happens on his desktop App.
How can I send an email WITHOUT supplying my log-in credentials within the App?
using smtp I need to provide my credentials, but as this is for a published application that does not sound like a good idea.
I understand this is a very general question, but I am having trouble finding a solution on the web.
I'm sorry, but you will not be able to do this, as the smtp server requires some sort of authentication, from which to send from

Sending email programmatically on a Mac using Java (through Mac Mail Client)

I've done quite a bit of research on this matter and I can't seem to come up with a solid solution to my problem.
I am developing a Java client application that (should) allow users to import their contacts from Mac Address Book by fetching them in a list format and allowing the user to select a subset/all and click a button that would send an "invitation" to these users.
I was able to grab contacts using the Rococoa Java framework but I am uncertain as to how to send email or if it is even possible. I realize there are security concerns with this, but I was able to accomplish this same task on Outlook for PC.
It seems that I may have to call an Applescript from my Java that manually opens Mac Mail Client and sends email using their default mail account setup.
I could be totally off-base here... should I even bother sending mail through the user's default Mail account? I wanted to avoid using a different mail server to avoid spam etc.
Any help would be appreciated, thank you for your time.
Matt
Here's an applescript to use Mail...
set emailSender to "sender#email.com>"
set emailTo to "recipient#email.com"
set theSubject to "The subject of the mail"
set theContent to "message body"
tell application "Mail"
set newMessage to make new outgoing message with properties {sender:emailSender, subject:theSubject, content:theContent, visible:true}
tell newMessage
make new to recipient at end of to recipients with properties {address:emailTo}
send
end tell
end tell
Another option, if you know the smtp information, is to use python. I made a command line program you can use. Find it here. There's example code to use it on the web page.

Categories

Resources