Telegram and Python - python

I'v searched almost two days but had not found anything relevant...
Basically every article and post talks about how to use a bot sending message as itself, but how I could send messages as the user?
I will create a GUI using tkinter with a entry and a button, where the button command function will send the entry as a message of the user.
I know that I can automate it using selenium, but there's any best solution?

Related

Sending requests to Midjourney from my website

I need to send requests from my website to Midjourney on Discord. The user will attach a photo and text with information about the image he wants to get. Then this information needs to be sent to midjourney in discord. After midjourney generates the image, it must be sent back to the website. How can I do this? I couldn't find a way to send the command /imagine to midjourney with python. Is this even possible?
Yes, it is, and by the way, this is a duplicate of my question I think...
anyway try this https://github.com/Wildric-Auric/MidJourney-Wrapper
It's a wrapper, it is a bot that can call the /imagine command, I'm currently having problems with it on my other questions in StackOverflow.
you can add functionality to it and make it send its commands automatically

Telegram bot: how do I make an in-line button to send messages

I need a telegram bot that sends you inline button with some information bellow and when you press that button, it sends information (not an URL or something) I need a message with an image for example, when I search for tutorials it only shows me to put URLs, if someone can help me I would be so gratefull
A quick search reveals that you are searching for a keyboard and if you look into the python-telegram-bot library, you can find examples like inlinekeyboard2.py. Once you understand how it works, you can move on to sending a message. I suggest you take a look at the resources section in the same library, since you tagged python.
If you try this and fail at a clear definable problem, then you might ask a question here (in a new thread), so that you can get an exact solution.

How to use telebot module to create an inline button in bot window, which if clicked will work very similar to 'Create poll' button found in groups?

I am relatively new to python and I am trying to create a telegram bot using telebot, which will create a quiz-like game, and each user can create their own quiz-like game also. During the step by step process of creating this quiz by the user, at one point, I need them to send me a poll, just like how they create a new poll in a group. But there is no create poll button inside telegram bot as these buttons are generally found in groups and not in one-one chats.
So I need to create an inline keyboard button, which upon clicking will let the users create a poll and send it to the bot. I have gone through the documentation in github and couldn't find anything useful for this.
This similar thing is implemented by telegram's own "Quizbot". I'll attach the screenshots from that bot for clarity. Please help me identify how to implement it in my bot.
If 'Create question" button is clicked:
I am a noob to python and coding, so please help me with this problem.
edit: I can send a poll to the bot if I am using telegram desktop and not from the phone. I want to know how to enable to use it in the phone.
By using telebot we can do this. This gives us the opportunity to create poll from phone apps also.
import telebot
from telebot.types import ReplyKeyboardMarkup,KeyboardButton,
KeyboardButtonPollType,ReplyKeyboardRemove
bot=telebot.Telebot(token='your bot token')
poll_markup=ReplyKeyboardMarkup(one_time_keyboard=True)
poll_markup.add(KeyboardButton('send me a poll',
request_poll=KeyboardButtonPollType(type='quiz')))
#from my experience, only quiz type and regular type polls can be send.
remove_board=ReplyKeyboardRemove()
bot.send_message(chat_id,text,reply_markup=poll_markup)
#some other code here
#this can be used to remove the replykeyboard when you no longer need it.
bot.send_message(chat_id,text,reply_markup=remove_board)

Telegram bot creating survey (poll)

how do i create automatic polls on telegram with python? I need to create a poll every 3 days and I need to automate this task. Is it possible to do this with a telegram robot or via script? I can't create a vote with my robots.
I know it is possible to send messages by the robot with the following code:
import telegram
bot = telegram.Bot(token='104014195************dew')
bot.sendMessage(-3251xx743, 'hello')
or by post method:
https://core.telegram.org/bots/api#message
but I can't do it that way.
My question is how to make a poll with post method or by python
I need an example code as there is not much information on the internet
As you has tag python-telegram-bot, I guess you are using this library:
https://github.com/python-telegram-bot/python-telegram-bot
In this case you should use this method to send a poll:
https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot.sendPoll
Next step is to start your script regularly: you can do it by using crontab, for instance.

How does multiplexing in Django sockets work?

I am new at this part of web developing and was trying to figure out a way of creating a web app with the basic specifications as the example bellow:
A user1 opens a page with a textbox (something where he can add text or so), and it will be modified as it decides to do it.
If the user1 has problems he can invite other user2 to help with the typing.
The user2 (when logged to the Channel/Socket) will be able to modify that field and the modifications made will be show to the user1 in real time and vice versa.
Or another example is a room on CodeAcademy:
Imagine that I am learning a new coding language, however, at middle of it I jeopardize it and had to ask for help.
So I go forward and ask help to another user. This user access the page through a WebSocket (or something related to that).
The user helps me changing my code and adding some comments at it in real time, and I also will be able to ask questions through it (real time communication)
My questions is: will I be able to developed certain app using Django Channels 2 and multiplexing? or better move to use NodeJS or something related to that?
Obs: I do have more experience working with python/django, so it will more productive for me right know if could find a way working with this combo.
This is definitely possible. They will be lots of possibilities, but I would recommend the following.
Have a page with code on. The page has some websocket JS code that can connect to a Channels Consumer.
The JS does 2 simple things. When code is updated code on the screen, send a message to the Consumer, with the new text (you can optimize this later). When the socket receives a message, then replace the code on screen with the new code.
In your consumer, add your consumer to a channel group when connecting (the group will contain all of the consumers that are accessing the page)
When a message is received, use group_send to send it to all the other consumers
When your consumer callback function gets called, then send a message to your websocket

Categories

Resources