Esempio n. 1
0
import telebot
from telebot import apihelper
from dbconnector import Dbconnetor
from bot_user import Botuser

logging.basicConfig(
    filename='errors_aggr.log',
    level=logging.INFO,
    format='%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
logger = telebot.logger
#apihelper.proxy = {'https': 'https://*****:*****@77.83.185.165:8000'}

telebot.logger.setLevel(logging.INFO)
dbconnector = Dbconnetor()
TOKEN = dbconnector.get_config_parameter('api_token', 'aggr_bot')
bot = telebot.TeleBot(TOKEN, threaded=True)


@bot.message_handler(commands=['start'])
def handlestart(m):
    try:
        user = Botuser(uid=m.chat.id, bot=bot)
        last_name = m.from_user.last_name
        first_name = m.from_user.first_name
        username = m.from_user.username
        user.join_aggrbot(last_name=last_name, first_name=first_name, username=username, ref_key='Notset', lang='rus' )
        bot.send_message(chat_id=m.chat.id, text='Привет. Чат бот находится в разработке, скоро все будет готово')
    except:
        logging.exception(str(m))
        logging.exception('Got exception on main handler')
Esempio n. 2
0
from bot_user import Botuser
from dbconnector import Dbconnetor
import starting_helper
import time

logging.basicConfig(
    filename='errors.log',
    level=logging.INFO,
    format=
    '%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
logger = telebot.logger

telebot.logger.setLevel(logging.INFO)
dbconnector = Dbconnetor()
use_proxy = dbconnector.get_config_parameter('proxy', 'global')
if use_proxy:
    apihelper.proxy = {'https': 'https://{}'.format(use_proxy)}
TOKEN = dbconnector.get_config_parameter('api_token', 'test_bot')
bot = telebot.TeleBot(TOKEN, threaded=True)


@bot.message_handler(commands=['start'])
def handlestart(m):
    user = Botuser(uid=m.chat.id, bot=bot)
    try:
        if user.isauth():
            max_count_questions = dbconnector.count_questions()
            max_count_additional_questions = dbconnector.count_additional_questions(
            )
            question_to_send = user.select_question_number_to_send()
Esempio n. 3
0
from dbconnector import Dbconnetor
import starting_helper
from notificator import Notificator
from post_helper import enter_post_index, enter_custom_post_index

logging.basicConfig(
    filename='errors.log',
    level=logging.INFO,
    format='%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
logger = telebot.logger



telebot.logger.setLevel(logging.INFO)
use_proxy = Dbconnetor.get_config_parameter('proxy', 'global')
if use_proxy:
    apihelper.proxy = {'https': 'https://{}'.format(use_proxy)}
TOKEN = Dbconnetor.get_config_parameter('api_token', 'aggr_bot')
bot = telebot.TeleBot(TOKEN, threaded=True)
notificator = Notificator(bot=bot)


@bot.message_handler(commands=['start'])
def handlestart(m):
    user = Botuser(uid=m.chat.id, bot=bot)
    try:
        starting_helper.stating_handler(user=user, message=m)
    except:
        logging.exception(str(m))
        logging.exception('Got exception on main handler')