예제 #1
0
def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    print content_type, chat_type, chat_id

    if content_type != 'successful_payment':
        sent = bot.sendInvoice(
            chat_id,
            "Nick's Hand Cream",
            "Keep a man's hand like a woman's",
            payload='a-string-identifying-related-payment-messages-tuvwxyz',
            provider_token=PAYMENT_PROVIDER_TOKEN,
            start_parameter='abc',
            currency='HKD',
            prices=[
                LabeledPrice(label='One Case', amount=987),
                LabeledPrice(label='Package', amount=12)
            ],
            need_shipping_address=True,
            is_flexible=True)  # required for shipping query
        # 'Pay' button appears automatically

        pprint(sent)
        print Invoice(**sent['invoice'])

    else:
        print 'Successful payment RECEIVED!!!'
        pprint(msg)
        print SuccessfulPayment(**msg['successful_payment'])
예제 #2
0
def on_shipping_query(msg):
    query_id, from_id, invoice_payload = telepot.glance(
        msg, flavor='shipping_query')

    print 'Shipping query:'
    print query_id, from_id, invoice_payload
    pprint(msg)
    print ShippingQuery(**msg)

    bot.answerShippingQuery(
        query_id,
        True,
        shipping_options=[
            ShippingOption(id='fedex',
                           title='FedEx',
                           prices=[
                               LabeledPrice(label='Local', amount=345),
                               LabeledPrice(label='International', amount=2345)
                           ]),
            ShippingOption(id='dhl',
                           title='DHL',
                           prices=[
                               LabeledPrice(label='Local', amount=342),
                               LabeledPrice(label='International', amount=1234)
                           ])
        ])
예제 #3
0
def _send_invoice(chat_id):
    TelegramBot.sendMessage(chat_id,
                            render_to_string('agreements.md'),
                            parse_mode='Markdown')
    TelegramBot.sendInvoice(
        chat_id,
        "Gaming console PS4(USED)",
        "Greates gaming console in the world",
        payload='a-string-identifying-related-payment-messages-tuvwxyz',
        provider_token=settings.PAYMENT_PROVIDER_TOKEN,
        start_parameter='abc',
        currency='RUB',
        prices=[
            LabeledPrice(label='One Case', amount=1800000),
        ],
        photo_url='http://perevozchikov.online/static/PS4-1024x576.jpg',
        need_shipping_address=True,
        is_flexible=True)  # required for shipping query
    TelegramBot.sendInvoice(
        chat_id,
        "Сабвуфер Kixx ICQ250(USED)",
        "Активный сабвуфер",
        payload='a-string-identifying-related-payment-messages-tuvwxyz',
        provider_token=settings.PAYMENT_PROVIDER_TOKEN,
        start_parameter='abc',
        currency='RUB',
        prices=[
            LabeledPrice(label='One Case', amount=450000),
        ],
        photo_url='http://perevozchikov.online/static/kixx250.jpeg',
        need_shipping_address=True,
        is_flexible=True)  # required for shipping query

    return None
예제 #4
0
    def on_shipping_query(self, msg):
        query_id, from_id, invoice_payload = telepot.glance(
            msg, flavor="shipping_query")

        print("Shipping query:")
        pprint(msg)

        bot.answerShippingQuery(
            query_id,
            True,
            shipping_options=[
                ShippingOption(id='fedex',
                               title='FedEx',
                               prices=[
                                   LabeledPrice(label='Local', amount=345),
                                   LabeledPrice(label='International',
                                                amount=2345)
                               ]),
                ShippingOption(id='dhl',
                               title="DHL",
                               prices=[
                                   LabeledPrice(label='Local', amount=345),
                                   LabeledPrice(label='International',
                                                amount=2345)
                               ])
            ])
예제 #5
0
    def on_shipping_query(self, msg):
        query_id, from_id, invoice_payload = telepot.glance(
            msg, flavor='shipping_query')

        print('Shipping query:')
        pprint(msg)

        bot.answerShippingQuery(
            query_id,
            True,
            shipping_options=[
                ShippingOption(
                    id='self_collection',
                    title='Self Collection',
                    prices=[LabeledPrice(label='self_collection', amount=0)]),
                ShippingOption(
                    id='delivery',
                    title='Delivery',
                    prices=[LabeledPrice(label='delivery', amount=390)])
            ])
예제 #6
0
def send_invoice(seed_tuple):
    msg = seed_tuple[1]

    content_type, chat_type, chat_id = telepot.glance(msg)

    if content_type == 'text':
        sent = bot.sendInvoice(chat_id,
                               "Nick's Hand Cream",
                               "Manly hands with a feminine touch",
                               payload='something',
                               provider_token=PAYMENT_PROVIDER_TOKEN,
                               start_parameter='abcdefg',
                               currency='USD',
                               prices=[
                                   LabeledPrice(label='One Case', amount=456),
                                   LabeledPrice(label='Multiple', amount=667)
                               ],
                               need_shipping_address=True,
                               is_flexible=True)

    print("Invoice sent:")
    pprint(sent)
예제 #7
0
def send_invoice(seed_tuple):
    msg = seed_tuple[1]

    content_type, chat_type, chat_id = telepot.glance(msg)

    if content_type == 'text':
        sent = bot.sendInvoice(
            chat_id,
            "Nick's Hand Cream",
            "Keep a man's hand like a woman's",
            payload='a-string-identifying-related-payment-messages-tuvwxyz',
            provider_token=PAYMENT_PROVIDER_TOKEN,
            start_parameter='abc',
            currency='HKD',
            prices=[
                LabeledPrice(label='One Case', amount=987),
                LabeledPrice(label='Package', amount=12)
            ],
            need_shipping_address=True,
            is_flexible=True)  # required for shipping query

        print('Invoice sent:')
        pprint(sent)
예제 #8
0
 def invoice(self, package):
     """
     :param package: 1 = 1 session 2 = 5 sessions 3 = 10 sessions
     :return:
     """
     payloads = Payloads.objects.get(name=package)
     if TelePot.sendInvoice(
             self.user.telegram.chat_id, "Buy coins", "1 coin = 1 session",
             payload=payloads.name,
             provider_token=settings.PAYMENT_PROVIDER_TOKEN,
             start_parameter='test-parameter',
             currency='NZD', prices=[
                 LabeledPrice(label=payloads.label, amount=payloads.amount)]): # required for shipping query
         self.response = ['Invoice sent', None]
     else:
         self.response = ['Sorry, payment system is currently not working', None]
예제 #9
0
def send_invoice(seed_tuple):
    msg = seed_tuple[1]

    pprint(msg)
    content_type, chat_type, chat_id = telepot.glance(msg)
    print(content_type, chat_type, chat_id)

    if content_type == 'text':
        if msg['text'] in ('/help', '/start'):
            bot.sendMessage(
                chat_id,
                parse_mode='HTML',
                text=emojize(
                    ":hamburger: Hi! You can now order food from <b>NUS McDonald's</b>! \n"
                    ":backhand_index_pointing_down: Below is the list of commands and what they do\n\n"
                    ":white_heavy_check_mark: <b>User's command</b>\n"
                    "/menu - Display menu and their prices\n"
                    "/cart - Show items in cart\n"
                    "/clearCart - Empty your cart\n"
                    "/order - Checkout items in cart\n"
                    "/orderStatus - Check status of pending orders\n\n"
                    ":credit_card: Use credit card number <b>4242 4242 4242 4242</b> if you do not have one"
                    " and would want to test out the bot\n\n"))
        elif msg['text'] == '/menu':
            bot.sendMessage(
                chat_id,
                parse_mode='HTML',
                text=emojize(
                    "<b>Hi, these are the items on the menu.</b> :french_fries:\n\n"
                    ":chicken: /McSpicy - $5.80\n"
                    ":chicken: /DoubleMcSpicy - $7.65\n"
                    ":chicken: /McChicken - $3.95\n"
                    ":cow: /BigMac - $6.00\n"
                    ":cow: /Cheeseburger - $2.80\n"
                    ":cow: /DoubleCheeseburger - $4.60\n"
                    ":fish: /FiletOFish - $4.60\n"
                    ":chicken: /ChickenMcNuggets - $4.90\n"
                    ":chicken: /McWings - $4.90\n\n"
                    "<b>Upsized</b>\n"
                    ":chicken: /McSpicyUP - $7.30\n"
                    ":chicken: /DoubleMcSpicyUP - $9.15\n"
                    ":chicken: /McChickenUP - $5.45\n"
                    ":cow: /BigMacUP - $7.50\n"
                    ":cow: /CheeseburgerUP - $4.30\n"
                    ":cow: /DoubleCheeseburgerUP - $6.10\n"
                    ":fish: /FiletOFishUP - $6.10\n"
                    ":chicken: /ChickenMcNuggetsUP - $6.40\n"
                    ":chicken: /McWingsUP - $6.40\n"))

        elif msg['text'] == '/order':

            for order in orders_dict['orders']:
                if chat_id == order['chat_id']:

                    if len(order['orders']) == 0:
                        bot.sendMessage(chat_id,
                                        text='No item in cart!\n'
                                        'Add them from /menu now!')
                        break

                    else:
                        description = datetime.now().strftime(
                            '%Y-%m-%d %H:%M:%S') + '\n\n'
                        this_payload = 'CC:'
                        for order in orders_dict['orders']:
                            for item in order['orders']:
                                description += str(
                                    item[0]) + ' (${:.2f})\n'.format(
                                        int(item[1]) / 100)
                                this_payload += str(item[0]).replace(' ',
                                                                     '_') + ':'

                        sent = bot.sendInvoice(
                            chat_id=chat_id,
                            title='Checkout Cart',
                            description=description,
                            payload=this_payload,
                            provider_token=Token.PAYMENT_PROVIDER_TOKEN,
                            start_parameter=order['chat_id'],
                            currency='SGD',
                            photo_url=
                            'https://d1nqx6es26drid.cloudfront.net/app/uploads/2015/06/18104056/ramanda-bundles.png',
                            prices=[
                                LabeledPrice(label=item[0], amount=item[1])
                                for order in orders_dict['orders']
                                for item in order['orders']
                            ],
                            need_shipping_address=True,
                            need_phone_number=True)
                        print(sent)
                        break

            else:  # no such user in json file
                orders_dict['orders'].append({
                    'chat_id': int(chat_id),
                    "orders": []
                })
                with open('order_list.json', 'w') as outfile:
                    json.dump(orders_dict, outfile)
                bot.sendMessage(chat_id,
                                text='No item in cart!\n'
                                'Add them from /menu now!')

        elif msg['text'] == '/orderStatus':  # view cart
            incomplete_list = pb.get_pending_orders(chat_id=chat_id)
            to_sent_str = ''
            for item in incomplete_list:
                to_sent_str += 'Order: ' + str(item['id']) + '\n'
                to_sent_str += item['product'] + '\n\n'
            bot.sendMessage(chat_id, text=to_sent_str)

        elif msg['text'] == '/cart':  # view cart

            for order in orders_dict['orders']:
                if chat_id == order['chat_id']:

                    if len(order['orders']) == 0:
                        bot.sendMessage(chat_id,
                                        text='No item in cart!\n'
                                        'Add them from /menu now!')
                        break

                    else:
                        description = '<b>Click</b> /order <b>to checkout!</b>\n\n'
                        for item in order['orders']:
                            description += str(
                                item[0]) + ' (${:.2f})\n'.format(
                                    int(item[1]) / 100)
                        description += '\n'
                        for item in order['orders']:
                            description += '/drop_' + str(item[0]).replace(
                                ' ', '_') + '\n'
                        description += '\nEmpty cart: /clearCart'
                        bot.sendMessage(chat_id,
                                        text=description,
                                        parse_mode='HTML')
                        break

            else:  # no such user in json file
                orders_dict['orders'].append({
                    'chat_id': int(chat_id),
                    "orders": []
                })
                with open('order_list.json', 'w') as outfile:
                    json.dump(orders_dict, outfile)
                bot.sendMessage(chat_id,
                                text='No item in cart!\n'
                                'Add them from /menu now!')

        elif msg['text'] == '/clearCart':  # empty cart
            for order in orders_dict['orders']:
                if chat_id == order['chat_id']:
                    order['orders'] = []
                    with open('order_list.json', 'w') as outfile:
                        json.dump(orders_dict, outfile)
                    bot.sendMessage(chat_id,
                                    text='Cart is empty!\n'
                                    'Start browsing more items at /menu!')
                    break

        elif msg['text'][:4] == '/add':  # add individual items to order list

            for order in orders_dict['orders']:
                if chat_id == order['chat_id']:

                    if len(order['orders']) == 10:
                        bot.sendMessage(
                            chat_id,
                            text='Sorry, maximum order is 10 items!\n'
                            'Drop item(s) or /order now!')

                    else:
                        try:
                            name_to_compare = str(msg['text'])
                            name_to_compare = name_to_compare[5:]
                            name_to_compare = name_to_compare.upper()
                            print(name_to_compare)
                            for i in menu_dict:
                                if name_to_compare.replace('UP', '') == str(
                                        i['backend_name']).upper():
                                    if msg['text'][-2:].upper() == 'UP':
                                        order['orders'].append([
                                            str(i['frontend_name']) +
                                            ' Upsize',
                                            int(i['price_upsize'])
                                        ])
                                        bot.sendMessage(
                                            chat_id,
                                            text=
                                            'Item added to cart! View /cart!\n'
                                            'Continue browsing at /menu!')
                                        break
                                    else:
                                        order['orders'].append([
                                            str(i['frontend_name']),
                                            int(i['price'])
                                        ])
                                        bot.sendMessage(
                                            chat_id,
                                            text=
                                            'Item added to cart! View /cart!\n'
                                            'Continue browsing at /menu!')
                                        break
                            else:
                                bot.sendMessage(
                                    chat_id, text='No item added, try again?')
                                break

                            with open('order_list.json', 'w') as outfile:
                                json.dump(orders_dict, outfile)
                                break

                        except:
                            bot.sendMessage(chat_id,
                                            text='No item added, try again?')
                            break

            else:  # no such user in json file

                try:
                    name_to_compare = str(msg['text'])
                    name_to_compare = name_to_compare[5:]
                    name_to_compare = name_to_compare.upper()
                    print(name_to_compare)
                    for i in menu_dict:
                        if name_to_compare.replace('UP', '') == str(
                                i['backend_name']).upper():
                            if msg['text'][-2:].upper() == 'UP':
                                orders_dict['orders'].append({
                                    'chat_id':
                                    int(chat_id),
                                    "orders": [[
                                        str(i['frontend_name']) + ' Upsize',
                                        int(i['price_upsize'])
                                    ]]
                                })
                                bot.sendMessage(
                                    chat_id,
                                    text='Item added to cart! View /cart!')
                                break
                            else:
                                orders_dict['orders'].append({
                                    'chat_id':
                                    int(chat_id),
                                    "orders": [[
                                        str(i['frontend_name']),
                                        int(i['price'])
                                    ]]
                                })
                                bot.sendMessage(
                                    chat_id,
                                    text='Item added to cart! View /cart!')
                                break
                    else:
                        bot.sendMessage(chat_id,
                                        text='No item added, try again?')

                    with open('order_list.json', 'w') as outfile:
                        json.dump(orders_dict, outfile)

                except:
                    bot.sendMessage(chat_id, text='No item added, try again?')
                    orders_dict['orders'].append({
                        'chat_id': int(chat_id),
                        "orders": []
                    })
                    with open('order_list.json', 'w') as outfile:
                        json.dump(orders_dict, outfile)

        elif msg['text'][:5] == '/drop':  # drop individual items to order list
            for order in orders_dict['orders']:
                if chat_id == order['chat_id']:

                    if len(order['orders']) == 0:
                        bot.sendMessage(chat_id,
                                        text='No item in cart!\n'
                                        'Add them from /menu now!')

                    else:
                        try:
                            name_to_compare = str(msg['text'])
                            name_to_compare = name_to_compare[6:]
                            name_to_compare = name_to_compare.replace('_', ' ')
                            name_to_compare = name_to_compare.upper()
                            print(name_to_compare)
                            for i in range(len(order['orders'])):
                                name_in_dict = order['orders'][i][0]
                                if 'UPSIZE' in name_to_compare.upper():
                                    if name_to_compare.upper() == str(
                                            name_in_dict).upper():
                                        del order['orders'][i]
                                        bot.sendMessage(
                                            chat_id,
                                            text=
                                            'Item removed from cart! View /cart'
                                        )
                                        print(order['orders'])
                                        break
                                else:
                                    if name_to_compare.upper() == str(
                                            name_in_dict).upper():
                                        del order['orders'][i]
                                        bot.sendMessage(
                                            chat_id,
                                            text=
                                            'Item removed from cart! View /cart'
                                        )
                                        print(order['orders'])
                                        break
                            else:
                                bot.sendMessage(
                                    chat_id,
                                    text='No item removed, try again?')
                                break

                            with open('order_list.json', 'w') as outfile:
                                json.dump(orders_dict, outfile)
                                break

                        except:
                            bot.sendMessage(chat_id,
                                            text='No item removed, try again?')
                            break

            else:  # no such user in json file

                bot.sendMessage(chat_id, text='No item removed, try again?')
                try:
                    orders_dict['orders'].append({
                        'chat_id': int(chat_id),
                        "orders": []
                    })
                    with open('order_list.json', 'w') as outfile:
                        json.dump(orders_dict, outfile)
                except:
                    pass

        else:
            name_to_compare = str(msg['text'])
            name_to_compare = name_to_compare.replace("/", "")
            name_to_compare = name_to_compare.upper()
            for i in menu_dict:
                if name_to_compare.replace("UP", "") == str(
                        i['backend_name']).upper():

                    if name_to_compare[-2:] == "UP":
                        title = i['frontend_name'] + ' Upsize'
                        label = 'Meal - Upsize'
                        price = i['price_upsize']
                    else:
                        title = i['frontend_name']
                        label = 'Meal - No Upsize'
                        price = i['price']

                    sent = bot.sendInvoice(
                        chat_id=chat_id,
                        title=title,
                        description=i['description'],
                        payload=title,
                        provider_token=Token.PAYMENT_PROVIDER_TOKEN,
                        start_parameter=str(chat_id),
                        currency='SGD',
                        photo_url=i['photo_url'],
                        prices=[LabeledPrice(label=label, amount=price)],
                        need_shipping_address=True,
                        need_phone_number=True,
                        reply_markup=kb.custom_inline(price))
                    print(sent)
                    bot.sendMessage(chat_id,
                                    parse_mode='HTML',
                                    text='<b>Add to cart instead?</b>\n'
                                    'Click: /add_{}'.format(name_to_compare))
                    break

            else:
                bot.sendMessage(chat_id,
                                reply_markup=kb.default_keyboard,
                                text='Sorry, there seems to be an error!\n'
                                'Try out some of the actions below?')
예제 #10
0
    def post(self, request, bot_token):
        if bot_token != settings.TELEGRAM_BOT_TOKEN:
            return HttpResponseForbidden('Invalid token')

        commands = {
            '/start': _display_help,
            'help': _display_help,
            'football_feed': _display_football_feed,
            'hockey_feed': _display_hockey_feed,
            'buy': _send_invoice,
            'successful_payment': _payment_succes,
            'watch_video': _display_video,
        }

        raw = request.body.decode('utf-8')
        logger.info(raw)

        try:
            pload = json.loads(raw)
        except ValueError:
            return HttpResponseBadRequest('Invalid request body')
        else:
            if 'callback_query' in pload:
                query_id, from_id, query_data = telepot.glance(
                    pload['callback_query'], flavor='callback_query')
                #TelegramBot.sendMessage(chat_id, query_data, parse_mode='Markdown')
                cmd = query_data
                chat_id = from_id
            elif 'message' in pload:
                content_type, chat_type, chat_id = telepot.glance(
                    pload['message'])
                if content_type == 'successful_payment':
                    cmd = 'successful_payment'
                else:
                    #chat_id = pload['message']['chat']['id']
                    if pload['message'].get('text') == 'Новости футбола':
                        cmd = 'football_feed'
                    elif pload['message'].get('text') == 'Новости хоккея':
                        cmd = 'hockey_feed'
                    elif pload['message'].get(
                            'text') == 'Что сегодня в продаже?':
                        cmd = 'buy'
                    elif pload['message'].get('text') == 'Видео дня':
                        cmd = 'watch_video'
                    else:
                        cmd = pload['message'].get('text')  # command

                #TelegramBot.sendMessage(chat_id, flavor, parse_mode='Markdown')
            elif 'shipping_query' in pload:
                query_id, from_id, invoice_payload = telepot.glance(
                    pload['shipping_query'], flavor='shipping_query')
                chat_id = from_id
                TelegramBot.answerShippingQuery(
                    query_id,
                    True,
                    shipping_options=[
                        ShippingOption(id='fedex',
                                       title='FedEx',
                                       prices=[
                                           LabeledPrice(label='Local',
                                                        amount=345),
                                           LabeledPrice(label='International',
                                                        amount=2345)
                                       ]),
                        ShippingOption(id='dhl',
                                       title='DHL',
                                       prices=[
                                           LabeledPrice(label='Local',
                                                        amount=342),
                                           LabeledPrice(label='International',
                                                        amount=1234)
                                       ])
                    ])
            elif 'pre_checkout_query' in pload:
                query_id, from_id, invoice_payload = telepot.glance(
                    pload['pre_checkout_query'], flavor='pre_checkout_query')
                chat_id = from_id
                TelegramBot.answerPreCheckoutQuery(query_id, True)

            func = commands.get(cmd.split()[0].lower())

            if func:
                func(chat_id)
            else:
                f = open('cmd_text.txt', 'w')
                f.write(cmd)
                f.close()
                TelegramBot.sendMessage(chat_id, content_type)
                TelegramBot.sendMessage(chat_id, cmd, parse_mode='Markdown')
                TelegramBot.sendMessage(chat_id,
                                        'I do not understand you, Sir!')

        return JsonResponse({}, status=200)
예제 #11
0
def on_chat_message(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
##    print(msg)

##    for i in chat_list:               
##            if i['user1']==str(chat_id):
##                if content_type=="text":
##                    if msg['text']=="/bye":
##                        bot2.sendMessage(chat_id,"You are disconnected. Click here: /chat%s to reconnect."%i['user2'])
##                        chat_list.remove(i)
##                        
##                    else:
##                        bot2.sendMessage(int(i['user2']), "/chat{} says: ".format(chat_id))
##                        bot2.forwardMessage(int(i['user2']),chat_id,msg['message_id'])
##                        break
                        
    if 'contact' in msg.keys():
            if msg['contact']['user_id']==chat_id:
                id_phonedict[chat_id]=msg['contact']['phone_number']
                bot.sendMessage(chat_id,"Verified! %s"%thumbsup)
                introMessage="You can choose to be an Orderer or an Orderee. An Orderer helps the Orderee to order food.\nWould like to be an Orderer or Orderee? %s"%sassy
                markup=InlineKeyboardMarkup(inline_keyboard=[
                    [InlineKeyboardButton(text="Orderer",callback_data="o1"),
                     InlineKeyboardButton(text="Orderee",callback_data="o2")]
                    ])
                bot.sendMessage(chat_id,introMessage,reply_markup=markup)
            else:
                bot.sendMessage(chat_id,"Eh who you trying to bluff?! Thats not your phone number!")
                verify(chat_id)
                
    elif 'successful_payment' in msg.keys():
            bot.sendMessage(chat_id, 'Wah you damn brudder. Thanks for the Kopi! Limpeh will remember you forever!!')
            bot.sendSticker(chat_id, 'CAADAgADJQADyIsGAAGoEDksgR1WpAI')

    elif content_type=="text":
        
        if msg['text']=="/start":
            verify(chat_id)

        elif msg['text'].startswith("/broadcast"):
            if chat_id==243431792:
                count=0 #count how many users in each batch to prevent spam
                for i in id_phonedict:
                    if count>=20:
                        time.sleep(1)
                        count=0
                    else:
                        count+=1
                    bot.sendMessage(i,msg)

        elif msg['text']=="/logs":
            if chat_id==243431792:
                print(id_phonedict)
                print(orderee_list)
                print(all_list)

        elif msg['text']=="/stop":
            for i in all_list:
                if i['userid']==str(chat_id):
                    all_list.remove(i)
            bot.sendMessage(chat_id,"Done! You won't receive anymore orders. However, you may still accept existing orders!")

        elif msg['text']=="/report":
            bot.sendMessage(chat_id,"If reporting user, let me know the user name, mobile number and the reason below.",reply_markup=ForceReply())
            
##        elif msg['text'].startswith("/chat"):
##            for i in chat_list:
##                if i['user1']==str(chat_id):
##                    temp="/chat"+str(i['user2'])
##                    chat_list.remove(i)
##                    bot2.sendMessage(chat_id,"Previous chat was closed. Click here: %s to re-enter chat."%temp)
##            other_id=msg['text'][5:]
##            chat_pair={}
##            chat_pair['user1']=str(chat_id)
##            chat_pair['user2']=str(other_id)
##            chat_list.append(chat_pair)
##            bot2.sendMessage(chat_id,"You are connected to {}. Click here: /bye to close.".format(chat_pair['user2']))
##            bot.sendMessage(chat_id, "You are connected. Click here to chat: @orderup_chatbot")
            

        elif msg['text']=="/status":
            o1_stall_1=0
            o1_stall_2=0
            o1_stall_3=0
            o1_stall_4=0
            o1_stall_5=0
            o1_stall_6=0
            o1_stall_7=0
            o1_stall_8=0
            o1_stall_9=0
            o1_stall_10=0
            o1_stall_11=0
            o1_stall_12=0
            o1_stall_13=0
            o1_stall_14=0
##            o2_stall_1=0
##            o2_stall_2=0
##            o2_stall_3=0
##            o2_stall_4=0
##            o2_stall_5=0
##            o2_stall_6=0
##            o2_stall_7=0
##            o2_stall_8=0
##            o2_stall_9=0
##            o2_stall_10=0
##            o2_stall_11=0
##            o2_stall_12=0
##            o2_stall_13=0
##            o2_stall_14=0
            for i in all_list:
                if i["stall"]=="1":
                    o1_stall_1+=1
                elif i["stall"]=="2":
                    o1_stall_2+=1
                elif i["stall"]=="3":
                    o1_stall_3+=1
                elif i["stall"]=="4":
                    o1_stall_4+=1
                elif i["stall"]=="5":
                    o1_stall_5+=1
                elif i["stall"]=="6":
                    o1_stall_6+=1
                elif i["stall"]=="7":
                    o1_stall_7+=1
                elif i["stall"]=="8":
                    o1_stall_8+=1
                elif i["stall"]=="9":
                    o1_stall_9+=1
                elif i["stall"]=="a":
                    o1_stall_10+=1
                elif i["stall"]=="b":
                    o1_stall_11+=1
                elif i["stall"]=="c":
                    o1_stall_12+=1
                elif i["stall"]=="d":
                    o1_stall_13+=1
                elif i["stall"]=="e":
                    o1_stall_14+=1
                    
##            for j in orderee_list:
##                if j["options"][1]=="1":
##                    o2_stall_1+=1
##                elif j["options"][1]=="2":
##                    o2_stall_2+=1
##                elif j["options"][1]=="3":
##                    o2_stall_3+=1
##                elif j["options"][1]=="4":
##                    o2_stall_4+=1
##                elif j["options"][1]=="5":
##                    o2_stall_5+=1
##                elif j["options"][1]=="6":
##                    o2_stall_6+=1
##                elif j["options"][1]=="7":
##                    o2_stall_7+=1
##                elif j["options"][1]=="8":
##                    o2_stall_8+=1
##                elif j["options"][1]=="9":
##                    o2_stall_9+=1
##                elif j["options"][1]=="a":
##                    o2_stall_10+=1
##                elif j["options"][1]=="b":
##                    o2_stall_11+=1
##                elif j["options"][1]=="c":
##                    o2_stall_12+=1
##                elif j["options"][1]=="d":
##                    o2_stall_13+=1
##                elif j["options"][1]=="e":
##                    o2_stall_14+=1
                    
            message=("*Soya Milk*\nOrderer: {}\n*Fruit Juice*\nOrderer: {}\n*Chinese Food*\nOrderer: {}\n"
            "*Western Food*\nOrderer: {}\n*Chicken Rice*\nOrderer: {}\n*Japanese Food*\nOrderer: {}\n"
                     "*Ramen Corner*\nOrderer: {}\n*Yong Tau Foo*\nOrderer: {}\n*Vegetarian Food*\nOrderer: {}\n"
                     "*Fishball Noddles*\nOrderer: {}\n*Indian Food*\nOrderer: {}\n*Indonesian Food*\nOrderer: {}\n"
                     "*Drinks and Snacks*\nOrderer: {}\n*McDonalds*\nOrderer: {}\n".format(
                o1_stall_1,
                o1_stall_2,
                o1_stall_3,
                o1_stall_4,
                o1_stall_5,
                o1_stall_6,
                o1_stall_7,
                o1_stall_8,
                o1_stall_9,
                o1_stall_10,
                o1_stall_11,
                o1_stall_12,
                o1_stall_13,
                o1_stall_14))
            bot.sendMessage(chat_id,message,parse_mode="Markdown")

        elif msg['text']=="/orders":
            my_orderer_msg="---My orders for today---\n" #showing who your orderers
            my_orderee_msg="---What I'm ordering for others today---\n" #showing who you ordering for
            temp_num=0
            for i in all_list:
                if str(chat_id) in i['orderees']:
                    for k in orderee_list:
                        if 'orderer' in k.keys() and str(k['orderer'])==i['userid']:
                            temp_num+=1
                            my_orderer_msg+="{}) Orderer id: {}\nStall: {}\nOrder: {}\nTip: {}\n[CLICK HERE TO CHAT](tg://user?id={})\n\n".format(temp_num,i['userid'],i['stall'],k['order'],k['tip'],i['userid'])
                            
            bot.sendMessage(chat_id,my_orderer_msg,parse_mode="Markdown")
            temp_num=0
            for j in orderee_list:
                if 'orderer' in j.keys() and j['orderer']==chat_id:
                    temp_num+=1
                    my_orderee_msg+="{}) Orderee id: {}\nStall: {}\nOrder: {}\nTip: {}\n[CLICK HERE TO CHAT](tg://user?id={})\n\n".format(temp_num,j['userid'],j['options'][1],j['order'],j['tip'],j['userid'])
            bot.sendMessage(chat_id,my_orderee_msg,parse_mode="Markdown")


        elif 'reply_to_message' in msg.keys():
            if "Type your orders clearly below!" in msg['reply_to_message']['text']:
                if chat_id in temp_dict.keys():
                    orderee_info_dict=temp_dict[chat_id]
                    orderee_info_dict['order']=msg['text']
                    temp_dict[chat_id]=orderee_info_dict
                        
##                for i in orderee_list:
##                    if str(chat_id) in i['userid'] and "order" not in i.keys():
##                        i['order']=msg['text']
##                        break
                
                bot.sendMessage(chat_id,"Type your tip amount! Pay your Orderer when you collect your food!",reply_markup=ForceReply())

            elif "Type your tip amount! Pay your Orderer when you collect your food!" in msg['reply_to_message']['text']:
                if chat_id in temp_dict.keys():
                    orderee_info_dict=temp_dict[chat_id]
                    orderee_info_dict['tip']=msg['text']
                    temp_dict[chat_id]=orderee_info_dict
                bot.sendMessage(chat_id, "Type a location to meet!",reply_markup=ForceReply())

            elif "Type a location to meet!" in msg['reply_to_message']['text']:
                orderer_num_int=0
                if chat_id in temp_dict.keys():
                    orderee_info_dict=temp_dict[chat_id]
                    orderee_info_dict['location']=msg['text']
                    temp_options=orderee_info_dict['options']
                    temp_order=orderee_info_dict['order']
                    temp_tip=orderee_info_dict['tip']
                    temp_location=orderee_info_dict['location']
                
##                for i in orderee_list:
##                    if str(chat_id)in i['userid'] and "tip" not in i.keys():
##                        i['tip']=msg['text']
##                        temp_options=i['options']
##                        temp_order=i['order']
##                        temp_tip=i['tip']
##                        break
                    
                markup=InlineKeyboardMarkup(inline_keyboard=[
                    [InlineKeyboardButton(text="Accept",callback_data="A"+temp_options+str(chat_id))]
                                             ])

                markup1=InlineKeyboardMarkup(inline_keyboard=[
                    [InlineKeyboardButton(text="Cancel",callback_data="C"+temp_options+str(chat_id))]
                                             ])
                
                for j in all_list:
                    if j['stall']==temp_options[1]:
                        orderer_num_int+=1
                        bot.sendMessage(j["userid"],"Found an Orderee!\nOrder: {}\nTip: {}\nMeet: {}\nTo stop receiving: /stop".format(temp_order,temp_tip,temp_location),reply_markup=markup)

                message_with_inline_keyboard=None
                message_with_inline_keyboard=bot.sendMessage(chat_id, "{} orderers in the queue so far. Waiting for Orderers... {}".format(orderer_num_int,timer) ,reply_markup=markup1)
                orderee_info_dict['kmsg']=message_with_inline_keyboard
                orderee_list.append(orderee_info_dict)
                del temp_dict[chat_id]

            elif "If reporting user, let me know the user name, mobile number and the reason below." in msg['reply_to_message']['text']:
                bot.forwardMessage(243431792,chat_id,msg['message_id'])

                
        elif msg['text']=="/donate":
            bot.sendInvoice(chat_id,
                            "Donation", "Buy me Kopi if you like this project and would like to see it improve!",
                            payload='a-string-identifying-related-payment-messages-tuvwxyz',
                            provider_token='350862534:LIVE:ODg0ZDRiYzU3ZmY1',
                            start_parameter='abc',
                            currency='SGD', prices=[
                                LabeledPrice(label='Kopi', amount=300)],photo_url='https://goo.gl/4Mv7he',photo_size=4096,photo_width=64,photo_height=64)