How to get the list of latest chats that I have in telegram - bots

I want to write a program that gets the list of the latest chats that I had in telegram and their not in my contacts. I tried telethon but I couldn't do it for the users that are not in my contacts

If by "latest chats" you refer to "recent open conversations with other users, groups, or channels you've joined", then you're looking for client.iter_dialogs:
# Print all dialog IDs and the title, nicely formatted
async for dialog in client.iter_dialogs():
print('{:>14}: {}'.format(dialog.id, dialog.title))

Related

How I can create a log channel for my discord bot and how I can get records on the log channel?

I have some disсord servers and I need the bot to create a log channel into which my bot is able to write the data I will indicate in the code.
If you search on discord.py docs you would find this from guild's object.
await create_text_channel(name, *, overwrites=None, category=None, reason=None, **options)
Example:
guild = client.get_guild(ID)
await guild.create_text_channel('logs')
If you want the bot for everyone to use, you would need a database to save channels' id.
About the type of logs that you want to send to each guild it really depends. If it is only logs that you write by your own then just loop all channel's id that you saved and send each one a message.
If it is some discord logs given by discord API then you would have to search in discord.py docs for more info.

How to send an automated message to a skype group chat using python

Even though i am able to send messages to an individual skype contact using skpy module. i am unable to send to a group chat.
Below is the simple code i've used to send:
from skpy import Skype
sk = Skype("myskypeID", "pwd") # connect to Skype
content="the message i wanna send"
ch = sk.contacts["SkypeID_in_contacts"].chat
ch.sendMsg(content)
I cannot find any skype group ID for my group chats. Is there anyway of finding a skype group ID or some other method to append with python code i have used.
Please help
All Group Chart in Skype have an ID like
19:<random>#thread.skype
Here you can find a simple script to found all your groups IDs
How to get Skype Group Chat ID
End then you can found your chat with that id
ch = sk.chats["19:0b85483d2d634415993bb9daf58e7891#thread.skype"]
ch.sendMsg(msg)

how can I ask my telegram bot user to share his contacts with bot?

how can I ask my telegram bot user to share his contacts with bot ?
any inline keys or commands?
I want the output to be contacts chat id
$keyboard = json_encode([
'resize_keyboard'=>true,
'keyboard'=>[
[['text'=>"request contact",'request_contact'=>true]]
]
]);
there is a way to get contact of bot user (not user`s contact) with KeyboardButton (request_contact=True)
(is used it in python-telegram-bot v13.13 library)
you can read more in
telegram core bots KeyboardButton

How can send the telegram bot location to users?

I want to send location of the bot to users, I very searched about it in google , but i find just this case"send location of users to the bot" I want versa case that mean:"send location of the bot to the users".
this is my idea: the owner of the bot is a driver who that want to share his location with the users of the bot,in the bot i put a button,when the users click on that button, the bot tell them location of driver.the location of bot is variable and it isn't constant
Sample request for send location from Bot to user with URL:
https://api.telegram.org/bot[botToken]/sendlocation?chat_id=[UserID]&latitude=51.6680&longitude=32.6546
Requirement for execute URL:
[botToken], e.g:399684XXX:AAH_NiVFtLXVmh4XXX-XXXEZo3yO6XXX
[UserID], e.g:64326XX
latitude , e.g:51.6680
longitude, e.g:32.6546
You can use sendVenue or sendLocation method to do it.
use sendLocation and not a web request to telegram api, to get the longitude and latitude you can use messageEventArgs.Message.Location.Latitude and messageEventArgs.Message.Location.Longitude with telegram c# bot api

How to add a bot to a Telegram Group?

I've been trying to add a bot to my Telegram group in Android Device but I am not able to do so. I tried #bot_name, /bot_name, but it doesn't work.
Is it possible to add a bot to the group or should I create a new bot using Telegram API (not bot API) so that I can add the contact number to the group?
Edit: now there is yet an easier way to do this - when creating your group, just mention the full bot name (eg. #UniversalAgent1Bot) and it will list it as you type. Then you can just tap on it to add it.
Old answer:
Create a new group from the menu. Don't add any bots yet
Find the bot (for instance you can go to Contacts and search for it)
Tap to open
Tap the bot name on the top bar. Your page becomes like this:
Now, tap the triple ... and you will get the Add to Group button:
Now select your group and add the bot - and confirm the addition
You have to use #BotFather, send it command: /setjoingroups
There will be dialog like this:
YOU: /setjoingroups
BotFather: Choose a bot to change group membership
settings.
YOU: #YourBot
BotFather: 'Enable' - bot can be added to groups. 'Disable' - block
group invitations, the bot can't be added to groups. Current status
is: DISABLED
YOU: Enable
BotFather: Success! The new status is: ENABLED.
After this you will see button "Add to Group" in your bot's profile.
Another way :
change BOT_USER_NAME before use
https://telegram.me/BOT_USER_NAME?startgroup=true
In my case the 2 steps worked:
Added bot to a group as a regular member
Made Bot an admin.
The second step was needed to let Bot respond and sent messages to Group chat.
The response event.postData.contents looked like this:
{
"ok":true,
"result":{
"message_id":31,
"from":{
"id":1234567890,
"is_bot":true,
"first_name":"bot for custom alerts",
"username":"mybotname1_bot"
},
"chat":{
"id":-1234567890,
"title":"group name",
"type":"group",
"all_members_are_administrators":true
},
"date":1624860599,
"text":"hi"
}
}
I needed to receive the chat id (negative number from response) to send messages to the group by Bot.

Resources