Size: a a a

pyTelegramBotAPI.talks.ru

2020 August 28

GF

George Forse in pyTelegramBotAPI.talks.ru
𝕡𝕔𝕚𝕩𝕆𝕫𝕫 ❌
{first_name = message.from_user.first_name} типо так
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
𝕡𝕔𝕚𝕩𝕆𝕫𝕫 ❌
{first_name = message.from_user.first_name} типо так
{first_name = message.from_user.first_name + ' ' +  message.from_user.last_name if message.from_user.first_name and message.from_user.last_name else 'у вас не указаны фамилия или имя, пожалуйста укажите и только потом продолжайте пользоваться этим ботом' }
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
лучше так
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
Ты про pep8 забыл
Я пофиксил, не благодари
источник

𝕡

𝕡𝕔𝕚𝕩𝕆𝕫𝕫 ❌... in pyTelegramBotAPI.talks.ru
Wifelly
{first_name = message.from_user.first_name + ' ' +  message.from_user.last_name if message.from_user.first_name and message.from_user.last_name else 'у вас не указаны фамилия или имя, пожалуйста укажите и только потом продолжайте пользоваться этим ботом' }
А если просто здравствуйте и first name?
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
Language:
py3


Source:
import this


Result:
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
𝕡𝕔𝕚𝕩𝕆𝕫𝕫 ❌
{first_name = message.from_user.first_name} типо так
таким образом не ок
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
ダーリン (Darling)
first_name = message.from_user.first_name
если до этого указать, то ок
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
а ещё лучше - распарсить в отдельном классе
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
Wifelly
а ещё лучше - распарсить в отдельном классе
Что?
источник

𝕡

𝕡𝕔𝕚𝕩𝕆𝕫𝕫 ❌... in pyTelegramBotAPI.talks.ru
@bot.message_handler(commands=['start'])
def send_start(message):
   print(message.chat.id)
   bot.send_message(message.chat.id, text='Здравствуйте! ')


И куда его впихнуть
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
@bot.message_handler(commands=['start'])
def send_start(message):
   bot.send_message(message.chat.id, text=f'Здравствуйте, {message.from_user.first_name}')
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
𝕡𝕔𝕚𝕩𝕆𝕫𝕫 ❌
А как сделать чтоб при старте бота писалось типо здравствуйте и ник твой

text=f' Здравствуйте {first_name} ')

Так не получается
написать класс, при инициализации объекта которого, из message будут вытягиваться вся  необходимая инфа:

class User:
   def __init__(self, message):
       self.id = message.from_user.id
       self.first_name = message.from_user.first_name

Таким образом это:
bot.send_message(message.from_user.id, f' Здравствуйте {message.from_user.first_name}')
сократиться до:
user = User(message)
bot.send_message(user.id, f' Здравствуйте {user.first_name}')
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
Wifelly
написать класс, при инициализации объекта которого, из message будут вытягиваться вся  необходимая инфа:

class User:
   def __init__(self, message):
       self.id = message.from_user.id
       self.first_name = message.from_user.first_name

Таким образом это:
bot.send_message(message.from_user.id, f' Здравствуйте {message.from_user.first_name}')
сократиться до:
user = User(message)
bot.send_message(user.id, f' Здравствуйте {user.first_name}')
И с хуя ли это сокращение?
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
George Forse
И с хуя ли это сокращение?
Language:
py3


Source:
import this


Result:
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
источник

W

Wifelly in pyTelegramBotAPI.talks.ru
Wifelly
Language:
py3


Source:
import this


Result:
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
с этого
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
Wifelly
Language:
py3


Source:
import this


Result:
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Ну да, оно ведь следую зену
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
Какой-то непонятный User
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
Который ты должен будешь идти смотреть, что это за херня
источник

GF

George Forse in pyTelegramBotAPI.talks.ru
Вместо просто прямого обращения
источник