K
K
kirzhq2021-06-16 01:32:04
Python
kirzhq, 2021-06-16 01:32:04

The bot does not start, gives a bunch of errors. what to do?

import telebot
from telebot import types

bot = telebot.TeleBot('токен')

@bot.message_handler(commands='start', func = lambda m: True)
def welcome(message):
    buttons = types.ReplyKeyboardMarkup(resize_keyboard=True)
    but_reg = types.KeyboardButton('/reg')
    but_hm = types.KeyboardButton('/help')
    buttons.add(but_reg, but_hm)
    bot.send_message(message.chat.id, 'Привет', reply_markup=buttons)

@bot.message_handler(func = lambda m: True)
def reg_reg(message):
    if message.text == '/reg':
        bot.send_message(message.from_user.id, "Для того что бы зарегистрироваться. Напишите мне ваше имя и фамилию")
        bot.register_next_step_handler(message, name_reg)

def name_reg(message):
    global name
    name = message.text
    bot.send_message(message.from_user.id, "Теперь напишите как мне к вам обращаться")
    bot.register_next_step_handler(message, login_reg)

def login_reg(message):
    global login
    login = message.text
    bot.send_message(message.from_user.id, "И наконец напишите мне ваш возраст")
    bot.register_next_step_handler(message, age_reg)

def age_reg(message):
    global age
    while age == 0:
        try:
            age = int(message.text)
        except Exception:
            bot.send_message(message.from_user.id, "Для того что бы я вас понял нужно ввести целое, натуральное число.")
bot.polling()


Traceback (most recent call last):
File "C:\Users\kirzh\PycharmProjects\pythonProject\bot.py", line 41, in
bot.polling()
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 514, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 573, in __threaded_polling
raise e
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 535, in __threaded_polling
polling_thread.raise_exceptions()
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\util.py", line 87, in raise_exceptions
raise self.exception_info
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\util.py", line 69, in run
task(*args, **kwargs)
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 325, in __retrieve_updates
self.process_new_updates(updates)
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 394, in process_new_updates
self.process_new_messages(new_messages)
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 420, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 2235, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 2201, in _test_message_handler
if not self._test_filter(message_filter, filter_value, message):
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 2222, in _test_filter
return test_cases.get(message_filter, lambda msg: False)(message)
File "C:\Users\kirzh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\telebot\__init__.py", line 2218, in
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in ' requires string as left operand, not NoneType

Answer the question

In order to leave comments, you need to log in

10 answer(s)
M
Mikhail Krostelev, 2021-06-16
@ kir1g

Leave only
@bot.message_handler(commands=['start'])
Remove func = lambda m: True in the first handler

S
Stefan, 2021-06-16
@MEDIOFF

@bot.message_handler(commands=['start'], func = lambda m: True)

Send commands as a list

D
Denis, 2012-04-09
@uscr

To go as an enikey worker to a place where there are a lot of bearded guys in sweaters, to run for a year with a common fund in hand, to gain experience in real situations, to become higher professionally, to grow in position, and then do whatever you want? That's what everyone does.

D
da0c, 2012-04-09
@da0c

In a nutshell - to switch from admins to progers, offhand I see several options.
- As already mentioned, you can try PHP freelance, according to the experience of my friend, it does not let the brain dry out, but only for a while.
- You can slowly get into another proger - Android / iPhone - especially under iOS, freelancers with their hands are torn off there and the prices are more interesting than in php and the “brain load” is better.
- Another option is to start mastering 1C - first simple tasks, update the configuration, fix the printing plate, and then more difficult.
- The most romantic option is to start picking something open source yourself, whatever you like, at least add modules for Mantis, at least start writing patches for postgresql. This is certainly closer to poetry, but the money will be much later.

B
Bakotiinii, 2012-04-09
@Bakotiinii

Lyrical digression. Why do you need growth and development?
- Do you want to work in a large company and do the same, only to "I work in a super-duper company"?
- Do you want to get a managerial position and manage people?
- Do you want ... Salvage?
I think that the most valuable person is the one who knows how to do his job. That is, narrow specialization and “indispensability” - and then download the rights and ask for what you need.
Therefore, first figure out what you yourself want, and only then decide which path to choose.
Good luck and thanks for your attention.

A
atreen, 2012-04-09
@atreen

If you want to stay in this direction, then “polish” - AD, Exchange, and so on. Or look for more interesting networks where there is little CCNA knowledge.
By the way, I also consider the idea with 1C promising.

M
Maxim, 2012-04-09
@Maxim_ka

Perhaps the concept of “bearded guys in sweaters” meant a small IT company, something like a small integrator, where you can gradually grow from ordinary projects to more serious ones, where again you will have someone to consult with. Or work in the banking IT department, they also have a lot of problems there, of course you won’t earn a lot of money, but there will be more than enough “fun” in terms of sawing something.

I
ipadm, 2012-04-09
@ipadm

Servers are at best terminal access, but in fact they are file dumps.
The answer that immediately came to mind based on the question: master Alfresco - just a system for combing file storage and creating a budget EDMS for medium-sized businesses.

E
egorinsk, 2012-04-09
@egorinsk

Here are the options:
Study and master different software products, including in practice. Linux, for example, can be studied for months. Maybe after that it will turn out that many tasks can be made easier, better or automated. Learn to use virtualization where it's beneficial.
Under Windows (if you want to be a Windows admin) study AD, policies, configuration, correct configuration with access rights and installation of IIS, Exchange, Sharepoint, 1C (who else will add something?). deploying a local server for updating Windows and products. Antiviruses.
Study network and telephone pieces of iron (for this you need to work where they are). A good administrator should be able to design, purchase and extend, for example, a network of N workstations in 3 remote offices + telephony + firewall it all + set up mail without spam and without getting into spam. Plus, set up DNS and BGP peering.
In addition to the vindoadmin, linuxadmin, and network-telephone admin, there are also other areas of development. For example, a web admin: the ability to deploy a cluster of web servers with a failover (what is it called? when one data center, for example, falls, but the system continues to work), automated backup, VPN, load balancer. Such a web admin knows how to optimize, find bottlenecks, configure apache, macula, postgres, oracle, nginx (for example, enable caching on nginx so that dynamic pages remain dynamic, and static pages are cached for anonymous users), node.js, ruby, redis, memcache. Knows how to save on new servers by optimizing and overclocking old ones. Ability to use monitoring systems.
Or do you already know all this and know how?

P
Puma Thailand, 2012-04-10
@opium

move to Thailand as a freelancer like me, there you are at least SP at least not SP, and that’s all.
pumainthailand.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question