python_tutorial | For a current sample , see https
kandi X-RAY | python_tutorial Summary
kandi X-RAY | python_tutorial Summary
For a current sample, see
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handles GET requests
- Make an API call
- Gets a token from an authorization code
- Get the details about the current user
- View function
- Get an access token
- Get a list of mail folders
- Get a token from a refresh token
- List all events
- Gets the list of the events
- List all contacts
- Gets the list of all contacts
- View of the tutorial
- Generate the signin URL
python_tutorial Key Features
python_tutorial Examples and Code Snippets
Community Discussions
Trending Discussions on python_tutorial
QUESTION
import random
user = "Jude"
file = ["do not lie", "do not cheat", "do not be bitter in anger", "do love all, is the greatest commandment"]
task = (input(f"There are four task in the task menu \nHow many task do wish to complete today {user}: "))
options1, options2, options3, options4 = file
for task in [random.randrange(*sorted([options1, options2, options3, options4])) for i in range(3)]:
while True:
if task == "1":
print(options1)
break
elif task == "2":
print(options1)
print(options2)
break
elif task == "3":
print(options1)
print(options2)
print(options3)
break
elif task == "4":
print(options1)
print(options2)
print(options3)
print(options4)
break
else:
print("No task to be done today")
break
...ANSWER
Answered 2021-Aug-30 at 17:48random.randrange
picks a random number between two integers. You want random.choice
, which picks an element from the list. In case you want more than just one, you can use random.choices
.
In case you want to avoid the duplicates, use random.sample
QUESTION
I have a question about a Microsoft Teams Python bot. If the bot has been added to some personal chats and group chats and I restart the bot, sometimes the bot needs to be added to the chats again. So I want to make bot sessions.
Is it possible to make a bot session in Microsoft Teams? I want to store session information on the local disk, and then have the bot load that data when it starts.
My bot code is very similar to this sample.
Thank you for your help.
Updated:
Like I said my bot code is very similar to this sample, but a bit different. Because of this I created an example for this question. First of all I create a bot in Azure and set up it.
After this, in my bot's config.py
file I set up the port and Microsoft app ID and password (generated by clicking the "Manage" button).
ANSWER
Answered 2021-Feb-09 at 14:52There is an option inside a bot to save a transcript of the conversation, but that's kind of unrelated. Basically, the important thing to know is that you don't need to store anything your side - from the user perspective, the entire conversation history is preserved in the Teams client, and from the perspective of your bot, storing the entire conversation history doesn't really gain you anything - user state is more relevant than conversation history. This would be storing an object in a persistence you choose (e.g. database, nosql store, azure blobs, whatever), but it would be state you choose to store for the user (basically whatever properties make sense to store for your app, in a kind of "User" collection). This is definitely a possible and often necessary concept, and this link will be useful for you: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-state?view=azure-bot-service-4.0
It's important to know though that this is a separate idea from sending a message on a defined schedule (e.g. Cron) to a user. For this to work, you need to read up on a concept called "Proactive Messaging". I have a sample on the Teams PnP gallery specifically dealing with it (code only in Node and Dotnet - no python I'm afraid, but hopefully it's useful for you). See here for that. Note that at the bottom of this link is a list of further reading on the topic as well.
Where the two above ideas come together is that you need to store certain state about the user to be able to send the proactive message later. In the sample I link to, I show how to get the settings you need to send the proactive message, but I've not included the concept of saving them to a data store - that's up to your own implementation inside your bot (e.g. SQL Azure, MongoDb, blob, whatever).
Also important to note (and I think part of the confusion and in fact part of why I wrote the sample) - your proactive code does not need to live in the same set of code as your bot! Your bot could be a web service running somewhere, and your proactive code an Azure Function/Lambda/similar.
QUESTION
I have registered a new app, copied tenant
, client_id
, and client_secret
. I can access https://graph.microsoft.com/v1.0 with Bearer
, and access token
- works fine. But I can't get anything else. Tried to grant scopes to this app - w/o luck.
ANSWER
Answered 2020-Mar-16 at 05:37You were using client credential flow which request an access token with application permissions. However, managed device apis are not supported with application permissions.
Reference:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python_tutorial
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page