import telebot
import config
from telebot.apihelper import ApiTelegramException
import datetime
import traceback
from telebot import types
from array import *
from telegram.ext import Updater, CallbackContext
bot = telebot.TeleBot(config.TOKEN)
u = Updater(config.TOKEN, use_context=True)
j = u.job_queue
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id, '...')
j.run_once(callback_1, 10, context=message.chat.id)
def callback_1(context: CallbackContext):
context.bot.send_message(chat_id=context.job.context, text='...')
bot.polling(none_stop=True)
import telebot
import config
from telebot.apihelper import ApiTelegramException
import datetime
import traceback
from telebot import types
from array import *
from telegram.ext import Updater
from db import DateBase
db = DateBase('users_datebase.db')
bot = telebot.TeleBot(config.TOKEN)
u = Updater(config.TOKEN, use_context=True)
j = u.job_queue
chat_user_id = 2030153931
@bot.message_handler(commands=['start'])
def welcome(message):
... #Там запись пользователя в бд
j.run_once(callback_1, 10)
def callback_1(context):
context.bot.send_message(chat_user_id, text='...')
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1477, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Admin/Desktop/GameSportBet/bot.py", line 38, in <module>
def callback_1(context: telegram.ext.CallbackContext):
NameError: name 'telegram' is not defined
from telegram.ext import Updater
u = Updater(config.TOKEN, use_context=True)
j = u.job_queue
...
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id, ...)
j.run_once(callback_1, 10)
def callback_1(context): #На context: telegram.ext.CallbackContext компилятор ругается
context.bot.send_message(chat_user_id, text='...')