Handling Place (location) content type - python

I have been using the PyTelegramBotAPI to handle current location with the content handler:
#bot.message_handler(content_types=['location'])
I am able to get the latitude and longitude which is really great.
However, below the current location option, I can send the bot a place. (seems that it does not have lat/lon data but it is an address) Which content handler should I use to handle it? I tried finding some documentation on https://pypi.org/project/pyTelegramBotAPI/0.3.0/ but i cant find any :(
Many thanks if you could point me in the right direction :)
Attached a picture of the send current location/place option:

Solved! Use
#bot.message_handler(content_types=['venue'])
to handle places sent by users.

Related

Automatically open a file send via email

I am currently in the position where one of my home devices sends the data of each day in form of a .csv file via email.
Thereby I can tell the device to whatever email (also multiple) it should send this file at the end of the day.
The email only contains this one file attached to it.
So, this is what I am working with.
I now would like to create my own statistics of the data using python, where I could add the data every day and calculate, plot etc.
The question is, how can I automatically download a file which is sent to me via email? I simply have no idea where to start. I was thinking about setting up an raspberry pi with some sort of email adress, but as you can tell I simply have no idea...
It would be great if someone would have a suggestion, or also maybe a link or documentation on stuff like this where I can teach it myself.
Thank you very much
Here is a link to medium article that has instructions how to download attachments that came with the email
The program could read the csv file with Pandas library. You can do all sorts of data manipulation and also some plotting with pandas. But If you want to have really good plots you could use matplotlib and seaborn
All this you could run in cloud maybe? I have zero experience with running projects in cloud so I can't really tell, but I've heard that you can do this. Maybe you could use AWS to do this?
That's how I would do it.
Googling any of the keywords such as pandas or AWS gives you tons and tons of tutorials.

Python use API to get data

I am kind of stucked in trying to solve following issue: I try to access a web-page in order to get some data for a supplier (need to do it for work) in an automated way, using an api
The API is called https://wl-api.mf.gov.pl and shall provide information stored in json for supplier which can be found over their tax ID.
I use the request package and I am able to manage to get positive response:
import requests
nip=7393033097
response=requests.get("https://wl-api.mf.gov.pl")
print(response) --> Response [200]
If I click on the link and scroll until I find the specific part for the tax information, I find the following line
GET /api/search/nip/{nip}
So what I did is to add this line into my response variable, since this is how I understood it - and there is the point where I think I am wrong
response=requests.get("https://wl-api.mf.gov.pl/search/7393033097/{7393033097}")
However, I cannot access it.
Am I doing something wrong - I do believe yes - and can anyone give me a little help :)
Update: If I check the requirements / documentation I find following information where I need a bit support to implement it
GET /api/search/nip/{nip}
(nip?date)
Single entity search by nip
**Path parameters**
nip (required)
*Path Parameter — Nip*
**Query parameters**
date (required)
*Query Parameter — format: date*
**Return type**
EntityResponse
Example data
Content-Type: application/json
I think this line:https://wl-api.mf.gov.pl/search/7393033097/{7393033097} should be like this:
https://wl-api.mf.gov.pl/search/nip/7393033097

escpos printer image not getting align to center

I am using escpos for printing the Token in our Queue managment system python. I need to put the company logo in header of the token. I am trying to do the same as below.
printer.set(align='center')
#printer.qr("You can readme from your smartphone")
printer.image("index/index_statics/img/brand/Webp.net-resizeimage.png")
But the image is always alignef to left. I have seen many links on the same. but nothing that I can understant. I am very new it. Please help to understand the issue and please help me to resolve the same. The printer is ZKTeco (ZKP8008) termal printer
This is not an ESC/POS question. Just that the printer can interpret ESC/POS does not mean that escpos is the good category for a framework/library question.

Can I send images back to API.AI?

I've been working on something using API.AI to create a Google Action that will send random web comics when asked. I have tried and tried, but so far it doesn't seem like there is a good way to put the image's bytes into the JSON response required for API.AI. I might have missed something along the way, but if anyone knows how this can be accomplished that would be of great help. I have been using python if that helps.
You can get or put images as a response from Api.ai just put url of that image . Here is some useful docs link :
https://docs.api.ai/docs/rich-messages#image
https://docs.api.ai/docs/query#section-message-objects

Python Telegram pytg post content to a channel

I am trying to post some messages on a channel using the pytg library which is also using the vysheng telegram-cli. I tried some options like
sender.send_msg("ChannelName", "Message")
sender.fwd("ChannelName", msg.id)
From these lines I am getting this error message
pytg.exceptions.FailException: Error 71: 'RPC_CALL_FAIL 400: CHANNEL_MESSAGES_DISABLED'
Searching inside Google/GitHub I did find this vysheng issue # 1033 that mentions that we need to send a post to a channel and not a message. But the pytg help(Sender) does not mention anything similar.
I have looked into the possibility of using a bot or other libraries but it's not really what I want.
Is there somebody familiar with pytg that can direct me in the proper direction?
Thx in advance
I was able to achieve this by using the raw command inside pytg, I guess there's a better solution out there but for the moment this one works!
sender.raw("post #nameOfChannel " + msg.text)

Categories

Resources