Example #1
0
def activate_task_by_id(id, chat_id):
    rez = get_task_by_id(id)
    if rez:
        rez.set_active()
        send_html_message(chat_id, get_list_task_message(chat_id))
    else:
        send_html_message(chat_id, 'Заявка с номером %s не найдена!' % id)
def set_sub_category(chat_id, subcat_id):
    tsk = get_last_telegramm_task(chat_id)
    subcat = SubCategory.objects.get(pk=int(subcat_id))
    tsk.subcategory = subcat
    tsk.save()
    send_html_message(
        chat_id, 'Выбрана подкатегория: <strong>%s</strong>' % subcat.title)
    send_what_content(chat_id)
    return tsk
def set_category(chat_id, cat_id):
    tsk = get_last_telegramm_task(chat_id)
    cat = Category.objects.get(pk=int(cat_id))
    tsk.category = cat
    tsk.save()
    send_html_message(chat_id,
                      'Выбрана категория: <strong>%s</strong>' % cat.title)
    send_sub_category_menu(chat_id, cat)
    return tsk
def finish_task(tsk, msg, chat_id):
    tsk.content = msg
    tsk.is_done_from_telegramm = True
    tsk.set_title()
    tsk.save()
    tsk.export()
    msg = get_new_task_message(tsk)
    menu = get_main_menu(tsk)
    send_html_message(chat_id, msg, reply_markup=menu)
    ws_update_list()
Example #5
0
def set_category_handler(update: Updater, context: CallbackContext):
    if update.callback_query.data == 'list_task':
        send_html_message(update.callback_query.message.chat_id, get_list_task_message(update.callback_query.message.chat_id))
    if update.callback_query.data == 'add_new_task':
        add_new_task(update.callback_query.message.chat_id)
    arr = update.callback_query.data.split('-')
    if len(arr)==2:
        if arr[1] == 'category':
            set_category(update.callback_query.message.chat_id,arr[0])
        if arr[1] == 'subcategory':
            set_sub_category(update.callback_query.message.chat_id, arr[0])
Example #6
0
def create_client(login,chat_id):
    try:
        ClientTelegramm.objects.get(chat_id=chat_id)
    except:
        c = ClientTelegramm()
        c.login = login
        c.chat_id = chat_id
        c.save()
        msg = 'Создан новый аккаунт логин: <strong>(%s)</strong> id комнаты: <strong>%s</strong> \n Для продолжения регистрации скажите как к вам обращаться?' % (login,chat_id)
        send_html_message(chat_id,msg)
        return c
def add_comment(tsk, text, chat_id):
    tclient = ClientTelegramm.objects.get(chat_id=chat_id)
    c = Comment()
    c.task = tsk
    c.content = text
    c.author = tclient.name
    c.user = tclient.user
    c.is_support = tclient.user.profile.is_support
    c.save()
    task_export_comment_to_trello.delay(c)
    msg = 'Коментарий был добавлен к задаче %s' % tsk.title
    send_html_message(chat_id, msg)
    ws_update_task(tsk.id)
Example #8
0
def add_file_to_active_task(chat_id, file):
    tsk = get_last_telegramm_task(chat_id)
    if not tsk:
        send_html_message(chat_id, 'Ошибка! Активной задачи не найдено!')
        #import pdb; pdb.set_trace()
    else:
        c = Comment()
        c.user = tsk.user
        c.task = tsk
        c.content = ''
        c.save()
        extar = file.split('.')
        filename = '%s.%s' % (c.id, extar[len(extar) - 1])
        #import pdb; pdb.set_trace()
        with open(file, 'rb') as doc_file:
            c.file.save(filename, File(doc_file), save=True)
        c.save()
        send_html_message(chat_id, get_add_file_message())
        task_export_file_to_trello(c)
Example #9
0
def start(update: Updater, context: CallbackContext):
    print('got message!')
    is_reg = check_registration(update.message.from_user.username,update.message.chat_id,update.message.text)
    if is_reg:
        bot.send_message(update.message.chat_id, text="Выберите действие:", reply_markup=get_main_menu())
    return True
    username = update.message.from_user.username
    #logging.warning('dasdasdasdasdas')
    bot.send_message(update.message.chat_id, text="Подождите, идет настройка для логина %s." % username)
    try:
        profile = Profile.objects.get(telegram_login = username)
        profile.telegram_room = update.message.chat_id
        profile.save()
        bot.send_message(update.message.chat_id, text="Операция прошла успешно!\n Чтобы добавить новую заявку наберите команду /add.")        
    except:
        msg = "Логин %s не найден. Укажите его на <a href='%s/account/profile' >странице профайла </a>!" % (username, SITE_URL)
        send_html_message(update.message.chat_id,msg)

    send_help_message(update.message.chat_id)
Example #10
0
def process(client,input):


    if not client.name:
        client.name = input
        client.save()
        print('Save name %s' % input)
        msg = 'Спасибо %s! \n Теперь введите контактный email пожалуйста!' % client.name
        send_html_message(client.chat_id,msg)
        return True

    if not client.email:
        client.email = input
        client.save()
        print('Save email %s' % input)
        msg = 'Теперь введите Ваш номер телефона!'
        send_html_message(client.chat_id,msg)
        return True

    if not client.phone:
        client.phone = input
        client.save()
        print('Save phone %s' % input)
        msg = 'Отлично! \n Для завершения регистрации введите адрес сайта.'
        send_html_message(client.chat_id,msg)
        return True

    if not client.domain:
        input = input.replace('http://','')
        input = input.replace('https://','')
        input = input.replace('/','')
        client.domain = input
        client.is_done = True
        client.save()
        user = register_user(client)
        client.user = user
        client.save()
        bind_tclient_toclient(client)
        print('Save domain %s' % input)
        msg = 'Благодарим за регистрацию! Для добавления новой заявки нажмите кнопку'
        #send_html_message(client.chat_id,msg)
        button_list = []
        button_list.append(InlineKeyboardButton('Добавить заявку', callback_data='add_new_task'))
        #for c in Category.objects.all().order_by('id'):
        #    button_list.append(InlineKeyboardButton(c.title, callback_data='%s-%s' %(c.pk,'subcategory')))
        #print(button_list)
        menu = build_menu(button_list, n_cols=1)
        reply_markup = InlineKeyboardMarkup(menu)
        print(menu)
        
        #button_list=[[InlineKeyboardButton('Добавить заявку')]]
        #reply_markup = InlineKeyboardMarkup(button_list)
        bot.send_message(client.chat_id, msg, reply_markup=reply_markup)
        return True


    '''
Example #11
0
def list(update: Updater, context: CallbackContext):    
    send_html_message(update.message.chat_id, get_list_task_message(update.message.chat_id))
def want_to_add_file_task(tsk, chat_id):
    msg = get_want_file_message()
    print(msg)
    #menu = get_main_menu()
    #send_html_message(chat_id,msg,reply_markup=menu)
    send_html_message(chat_id, msg)
def send_change_status_message(task):
    cl = ClientTelegramm.objects.get(user=task.user)
    send_html_message(cl.chat_id, get_change_status_message(task))