Get user id and user name from balebot [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Please explain how to get user.id and user.name of client who talking with my bot in balebot. There is a peer class, but i don't know how exactly it works?

its a simple way to use get_effective_user() function to get peer_id or accesshash, see:
user_peer=update.get_effective_user()
user_id = user_peer.peer_id
But if you need more you can get name and other feilds of user from an Update Json. like this :
def text_received(bot, update):
for user in update.users:
print(user.get_json_object())
....

Related

How to check if user input is an url? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm currently working on a small side project using the steam api, I want to check if the user inputs an url or not.
Could not find anything to this specific problem so if anyone knows that help!
Use regex
Sample Code Below:
import re
regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\"., <>?«»“”‘’]))"
def is_url(input_string):
return re.match(regex, input_string):

How can I remove "[{}]" from sql strings? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
For example, when I tried to get the user's username, this happens: Hello, [{'users': 'username'}]
How can I remove the rest, and get only the username?
appreciate the help!
Your question isn't clear
So, in order to get the username. First we need to iterate. Like this:
val = [{'users': 'username'}]
for values in val:
print(values["users"])
So this prints the 'username' in the dictionary.

How to request an address within a Django project [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
this is my view
def mydate(request):
date = datetime.datetime.strptime(request.GET.get('date'),"%Y-%m-%d")
return HttpResponse(data)
and i want call this view in another method in the django project
how to deal with this problem ?
yup you can do it
like this
def other_view(request):
item = mydate()
// now do what you need to do

How to get Admin name and password from Django? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to get the admin and its password, what i want to do, is authentificate everything with its credentials.
How to do it instead of hardcoding it by:
user = authenticate(username='me', password='12345')
login(request, user)
You can't get password from database, it's only an hashed fingerprint. Django password documentation

How to edit record in google datastore in AppEngine? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I was create one app which have model and it was created but i facing problem how to edit data in google data store using python or Django. Please Help me.
Fetch the record you want to edit (by key , id or any filter) , modify the field you want to edit and then put() it.

Categories

Resources