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.
Related
I am subscribed to a private telegram bot, how can I redirect messages to my bot in Java?
somewhere I read that in python there is a teleton class, but how to do it in java.
Telegram used to allow communications between bots, and then decided to revoke it afterwards.
So I would tell you to subscribe to the bot using your bot and read the updates that way, but that is no longer possible...
Bots simply don't catch updates from other bots...
But... if you really desire this functionality you could build a web scraper that reads your private messages and handles them as you please.
Or you could contact the creator of the said private bot and ask them to send the data via some other interface, other than telegram.
See:
https://core.telegram.org/bots/faq#what-messages-will-my-bot-get
Why doesn't my bot see messages from other bots?
Bots talking to each other could potentially get stuck in unwelcome loops. To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.
I think what you said is Telethon. If so, you are right that it can read bot messages because it is using Telegram client API instead of Telegram bot API.
Telegram client API is available for many different languages including Java. It supports both bot account or normal telegram account.
But Tdlib is not easy to use and you need to compile the library for your platform. You can find it here:
https://github.com/tdlib/td
Some people use TDLib as service/server and receive requests from bot.
I created chat bot and wrote a simple java application to send https request to
https://api.telegram.org/bot(botcredentials)/sendMessage?chat_id={chatid}&text="+telegramMessage
and it works for my telegram account, I tried to connect some more users to this bot and they can't see any updates (I mean I receive message for myself, but no one else could see them).
Perhaps I should make my bot ?public?
Or every user has its own chat_id with my bot?
Every chat with your bot has its own id. You can get the chat id of your bot with another user as soon as someone interacts with your bot through the Update object received either through getUpdates method or a Webhook.
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.
I am looking to send a facebook message from my application server without
the need to prompt the user for input each time.
I have been looking over the facebook chat API but it only works with facebook UI
which means that the user must be prompted every time I want to use the chat.
Is there a workaround or am I missing something?
I am using JAVA on my server.
I am writing a chat application on app engine using xmpp. My idea is to allow users to chat to one another. I can get messages to send to a google talk account, by taking the logged in user and removing the #gmail.com part of the address and replacing it with #appid.appspotchat.com )so for example if the logged in user is bob#gmail.com, the jid used to send from will be bob#appid.appspotchat.com). You can then send messages to an google talk account, e.g. jeff#gmail.com.
My problem is in receiving the messages back again. The developer pages show how the app itself can receive messages to the appid#appspot.com jid, but how do you get it to receive messages to the appid.appspot.com jid, and then present these messages tp the logged in user? The overall idea is when a user logs in, I will retrieve thri contact list, get the presence of their contacts (replacing gmail.com with appid.appspotchat.com) then present the available contacts to the user.
If this is not possible, is there a way to let the logged in user chat to other users in a different way? Ive briefly looked at the channel api but i don't think this is suitable?
You could use the Channel API to send a message down to a client when your server gets a message intended for that user. There's no facility to direct a XMPP message directly to a user on your own page; the XMPP API is used to send messages to users signed in to XMPP clients (such as Gmail, Pidgin, etc).
You can't use anything#your_app_id.appspot.com. Instead you must use anything#your_app_id.appspotchat.com as described in XMPP Addresses.