trying to get a bot to send a photo using pytelegrambotapi but i keep do it just once - py-telegram-bot-api

I want my telegram bot written on Python using pyTelegramBotAPI to send a picture on command /photo
If i try this code I will recive photo just once, no matter how many times I trigger ths command
photo = open('all_path/sudoku_1.png', 'rb')
#bot.message_handler(commands=['photo'])
def send_photo(message):
bot.send_photo(message.chat.id,photo)
To receive it once more I have to restart the bot or do like that
#bot.message_handler(commands=['photo'])
def send_photo(message):
bot.send_photo(message.chat.id, open('all_path/sudoku_1.png', 'rb'))
This is uncomfortable, can I do something else?
And I'm new to Python and don't know much yet
Help please

I don't see all your code, but maybe you didn't use bot.infinity_polling()??
It runs your bot until force stop, like while(True) loop.

Related

Agora.io - How to share video timestamps using mediaPlayer? - iOS

Here's what I'm trying to do: Using Agora.io's MediaPlayer API, I want to be able to publish video to a channel (which I can do using RtcChannelPublishPlugin), but I need to be able to then receive the media's current timestamp on the non-publishing device. Then, I will be able to "re-publish" the video from the other user starting at the same timestamp.
I've tried using AgoraRtm, but I don't think messages sent using rtm can be saved as variables.
I've found a way to get the timestamp and print it out, but the trouble is getting it to the other users in the channel and using it as a variable.
Has anyone experienced something like this? Any help would be greatly appreciated.
I'm using Agora's API example project as a base.
I would recommend the use of meta data that goes with the video stream. See the following API:
https://docs.agora.io/en/Interactive%20Broadcast/API%20Reference/oc/Classes/AgoraRtcEngineKit.html#//api/name/setMediaMetadataDataSource:withType:

Using codemirror to execute code on server

Novice to Codemirror.
I have codemirror running on my server I have it set to Python mode. Can someone please suggest how I go about executing the code and showing the result on the page where I have written the python code
Thanks
Without knowing much about your setup, here's a general idea:
Use the getValue() method to get the code from your CodeMirror instance.
Assuming the code is a run-able Python script, you can either
(1) send the code to your back end with AJAX or a POST request and run it there. Or (2) you could run the Python script in the browser with a library like one discussed here.
If you ran it on the back end, you can send the result of running the code back as text or JSON with your preferred protocol. If you ran it on the browser, you should probably follow the guidelines for the specific library you used.

Having trouble using Mechanize

So I'm new to using mechanize, and I'm trying to write a program in python 2.7 to log me into my campus wifi.
So I've written some code using mechanize that should log me in. The names of each field are accurate, as is the form name. However, whenever i run the program, nothing seems to happen. it doesn't submit the data, and the program stays running, so i have to force close it.
am i missing anything? i've been hunting over the web, and what i'm doing seems to be okay.
mechbrowse=mechanize.Browser()
mechbrowse.open(login_page)
mechbrowse.select_form(name='frmHTTPClientLogin')
mechbrowse.form['username'] = login_username
mechbrowse.form['password'] = login_password
mechbrowse.submit(name='btnSubmit')
do i need to write anything so that all this gets executed?

Javamail to receive emails; whats wrong?

I am trying to create a very simple (text based for now) email app for receiving emails. So far i have used this code :
http://www.javaer.org/j2ee/3-javamail/8-javamail-connecting-gmail-using-pop3-with-ssl
The problem is that i when i run this code i am able to get the new emails, only for once. For example if i have a new message in inbox the first time i will this code it will show it but then it wont. Also it seems that i cant see the body contents of the emails which is strange. I was told that it should be better to use imap protocol but i am not entirely sure how.
Specified example really starts once and scans folder and exits (and see answer on POP that removes mail). From description you need some loop that periodically checks catalog and extracts new mails. Look at some swing examples in your JDK how to write window-based program with event loop. You can start dedicated thread that once per minute checks POP server catalog

Live Stream Issue

I am getting the following error on my facebook app with the facebook live stream widget, but only at random times:
Live Stream Box configuration error
Live Stream Box couldn't be loaded at this time. Please try again later. For more detailed information on the Live Stream Box please visit the Developer Wiki.
Any ideas? It is really strange because it works sometimes and doesn't work other times. I would have thought that if there was really a configuration issue that it would work 0 times?
Try putting the at the bottom of the page, right before the "< body>".
It worked for me.
http://www.codecheetah.com/solution-facebook-live-stream-box-configuration-error/