how to find telegram channel messages count using telegram API - api

I want to get a message's views but I don't know which method should I use.
Here is the telegram API. I have the channel ID and the message_id,(I got them from my telegram bot). I know that telegram bot API doesn't have access to views so I want to use the main telegram API but I don't know which method should I use.

you can follow this steps:
create a post link (https://t.me/channel_username/post_id)
example: https://t.me/tehrandb/93
open the link with PHP or Python or other languages
Extract the field value with the ‍‍tgme_widget_message_views class

by python and telethon you can access to a certain message
and that message object have an attribute 'view':
m = Message(id=4864, to_id=PeerUser(user_id=818906659), date=datetime.datetime(2019, 6, 25, 4, 47, 57, tzinfo=datetime.timezone.utc), message=':reminder_ribbon:تک فیلم آموزش پروژه محور \n:man:\u200d:computer:پیاده سازی Responsive Menu \n:point_left: 0 تا 100\n:round_pushpin:با css & html\n#web\n#stepbysteplearn', out=False, mentioned=False, media_unread=False, silent=False, post=False, from_scheduled=False, legacy=False, from_id=818906659, fwd_from=MessageFwdHeader(date=datetime.datetime(2019, 6, 24, 20, 29, 53, tzinfo=datetime.timezone.utc), from_id=None, from_name=None, channel_id=1023032463, channel_post=11711, post_author=None, saved_from_peer=PeerChannel(channel_id=1023032463), saved_from_msg_id=11711), via_bot_id=None, reply_to_msg_id=None, media=MessageMediaDocument(document=Document(id=5803386688260540004, access_hash=5193338638774407914, file_reference=b'\x01\x00\x00\x13\x00]\x18l:\xb7\xd5\r&\xe8\xb5j\xa65*\xea\x01\xdc\xe2Py', date=datetime.datetime(2019, 6, 24, 20, 29, 52, tzinfo=datetime.timezone.utc), mime_type='video/mp4', size=16955767, dc_id=4, attributes=[DocumentAttributeVideo(duration=668, w=1280, h=720, round_message=False, supports_streaming=True), DocumentAttributeFilename(file_name='Responsive_Menu_With_Media_Queries.mp4')], thumbs=[PhotoStrippedSize(type='i', bytes=b'\x01\x16(\xc5\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x00\xa2\x8a(\x03'), PhotoSize(type='m', location=FileLocationToBeDeprecated(volume_id=455132553, local_id=24511), w=320, h=180, size=644)]), ttl_seconds=None), reply_markup=None, entities=[MessageEntityHashtag(offset=90, length=4), MessageEntityMention(offset=95, length=16)], views=6276, edit_date=None, post_author=None, grouped_id=None)
m.views will return a specific message views
full information of a message object in telegram.

Related

Increase number of assignments for old batch in Mechanical Turk

I have several projects created on the web interface, each has several batches that are already ended. The max assignment per task is 3. I need to add 2 more assignments for each HIT, is it possible?
I've tried using the API on a in-progress batch:
mturk.create_additional_assignments_for_hit(HITId=HIT_ID,NumberOfAdditionalAssignments=2)
and the response :
{'ResponseMetadata': {'RequestId': '.....some id ...',
'HTTPStatusCode': 200,
'HTTPHeaders': {'x-amzn-requestid': '.....some id ...',
'content-type': 'application/x-amz-json-1.1',
'content-length': '2',
'date': 'Thu, 20 Jan 2022 12:20:02 GMT'},
'RetryAttempts': 0}}
But I can't see any update on the web for +2 extra assignments..
Found the answer.
First, the Requester UI (RUI) and the API are not fully connected, such that not all changes in the API will be visible in the RUI.
Here is my answer using the python API
To "revive" old HITs and add a new assignments to them you need to:
mturk = boto3.client('mturk',
aws_access_key_id='xxxxxxxxxxxx',
aws_secret_access_key='xxxxxxxxxxxxx',
region_name='us-east-1',
endpoint_url='https://mturk-requester.us-east-1.amazonaws.com')
Extend the expiration date for the HIT (even if its already passed):
mturk.update_expiration_for_hit(HITId=HIT_ID_STRING,ExpireAt=datetime.datetime(2022, 1, 23, 20, 00, 00))
Then, increase max assignments, here we add +2 more:
mturk.create_additional_assignments_for_hit(HITId=HIT_ID_STRING,NumberOfAdditionalAssignments=2)
That's it, you can see that the total number of NumberOfAssignmentsAvailable increased by 2 and that MaxAssignments increased as well:
mturk.get_hit(HITId=HIT_ID_STRING)
'MaxAssignments':5,
'NumberOfAssignmentsPending': 0,
'NumberOfAssignmentsAvailable': 2,
'NumberOfAssignmentsCompleted': 3

How to decode response from Glucose Measurement Characteristic (Bluetooth)

I have an react-native application and im trying to get Glucose Measurements from Accu-Chek Guide device.
I have limited knowledge on BLE and this stackoverflow question helped me a lot to understand bluetooth and retrieving glucose measurements.
Reading from a Notify Characteristic (Ionic - Bluetooth)
so, what im doing in my code:
1, connect to BLE Peripheral
2, monitor characteristic Glucose Feature & Record Access Control Point
3, send 0x0101 (Report stored records | All records) to Record Access Control Point
4, decode response
So far i have 1-3 working but i dont know how to decode the response from Glucose Feature:
Notification response of Glucose Measurement
[27, 4, 0, 195, 164, 7, 7, 14, 11, 6, 5, 90, 2, 119, 194, 176, 195, 184, 0, 0]
Notification of Record Access Control Point
[6, 0, 1, 1]
I am assuming this is the Bluetooth SIG adopted profile of Continuous Glucose Monitoring Service (CGMS) the specification of which is available from:
https://www.bluetooth.com/specifications/gatt/
Looking at the XML for the Glucose Measurement characteristic, gives more detail on how the data is structured.
https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.glucose_measurement.xml
There will be a little bit of work to do to unpack the data.
For example, the first byte stores the information for the first field named flags. However you need to look at the first 5 bits for those various flags.
The next field is "Sequence Number" which is a uint16 so will take two bytes. Worth noting here that Bluetooth typically uses little endian.
Next is the Base Time field which refers to https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.date_time.xml which will take the next 7 bytes.
Because some of the 9 fields in the characteristic take more than one byte, this is why you are seeing 20 bytes for the 9 fields.

Azure Queue Send Message Method Expiry

New to Azure and testing Azure Queues . I attempted sending a message to the Queue with the Python SDK . Here is the method that I'm calling
from azure.storage.queue import QueueServiceClient, QueueClient, QueueMessage
connectionstring=os.environ.get("connection_string")
queue_client = QueueClient.from_connection_string(connectionstring,queue_name)
msg_content={"MessageID":"AQ2","MessageContext":"This is a test Message"}
#set the visibility timeout to 10 seconds and time-to-live to 1 day (3600 minutes)
#The documentation seems to say its an integer . Is it day , minutes ,hours ,seconds ?
queue_client.send_message(msg_content,visibility_timeout=10,time_to_live=3600)
and the output I get as a response from the queue is
{'id': '90208a43-15d9-461e-a0ba-b12e02624d34',
'inserted_on': datetime.datetime(2020, 6, 9, 12, 17, 57, tzinfo=<FixedOffset 0.0>),
'expires_on': datetime.datetime(2020, 6, 9, 13, 17, 57, tzinfo=<FixedOffset 0.0>),
'dequeue_count': None,
'content': {'MessageID': 'AQ2',
'MessageContext': 'This is a test Message'},
'pop_receipt': '<hidingthistoavoidanydisclosures>',
'next_visible_on': datetime.datetime(2020, 6, 9, 12, 18, 7, tzinfo=<FixedOffset 0.0>)}
Now if you observe the expires_on its clearly an hour from the insert date which is fine . But for some reason the message instantly moved to the poison queue ( which should normally happen after an hour if the message is untouched . I don't get where I'm going wrong . Request help on how to set the expiry time right and why its instantly moving the message to poison queue
The time to live is in seconds.
Here's the doc for queue send message

SoftLayer API: Missing active preset values for package 200 hourly bare metal servers

We noticed we got the error from SoftLayer API when trying to get categories from
product package 200 ( hourly bare metal server) preset Id=64 starting 10/18.
The following API query
https://<apiuser>:<apikey>#api.softlayer.com/rest/v3/SoftLayer_Product_Package/200/getActivePresets.json?objectMask=mask
[id,packageId,description,name,keyName,isActive,categories.id,categories.name, categories.categoryCode]
now returns presetId as 103, 97, 93,95,99,101,105,151,147,149, 143, 157
It used to return the following additional active presetIds:
64,66,68,70,74,76 , 78 before 10/17/2016.
I don't find these changes from SoftLayer release note
https://softlayer.github.io/release_notes/
Why are the previous active preset Ids 64,66,68,70,74,76 , 78 no longer available? Will they be added back ?
Thanks.
You are right, these presets are not longer available since 10/17/2016, because the DCs are no longer building the configurations and have moved to the Haswell and Broadwell configurations.
For Haswell:
Presets: 93, 95, 97, 99, 101, 103, 105
For Broadwell:
Presets: 147, 149, 151, 153, 157.

Gmail API generating time stamp report

I am curious if I could get a report of messages sent and received that includes time stamps and email addresses.
I looked at the Gmail API documentation and I did not see anything that directly mentioned anything like that.
Thank you.
Here's the relevant function maybe u can see it http://imapclient.readthedocs.org/en/latest/index.html#imapclient.IMAPClient.fetch
>> c.fetch([3293, 3230], ['INTERNALDATE', 'FLAGS'])
{3230: {b'FLAGS': (b'\Seen',),
b'INTERNALDATE': datetime.datetime(2011, 1, 30, 13, 32, 9),
b'SEQ': 84},
3293: {b'FLAGS': (),
b'INTERNALDATE': datetime.datetime(2011, 2, 24, 19, 30, 36),
b'SEQ': 110}}