def _cache_menu():
    global _menu
    global _menu_next
    global _menu_next_date
    _menu = yield menu.get_menu()

    if _menu:
        _menu_next_date = None
        _menu_next = {}
        print datetime.date.today(), _menu
        return

    _menu_next_date = datetime.date.today()
    while not _menu_next:
        # short circuit if greater than 30 days
        if _menu_next_date > datetime.date.today() + dateutil.relativedelta.relativedelta(days=30):
            _menu_next_date = None
            _menu_next = {}
            return

        _menu_next_date += dateutil.relativedelta.relativedelta(days=1)
        _menu_next = yield menu.get_menu(_menu_next_date)

    print datetime.date.today(), _menu
    print _menu_next_date, _menu_next
Пример #2
0
def tsn_requisites(message):
    message_menu = menu.get_menu("SELECT text FROM tsn_info WHERE name LIKE 'requisites'")
    tsn_keyboard = types.InlineKeyboardMarkup(row_width=1)
    tsn_button = types.InlineKeyboardButton(text="Вернуться в меню ТСН", callback_data="/tsn")
    tsn_keyboard.add(tsn_button)
    keyboards.main_menu_key(tsn_keyboard)
    bot.send_message(message.chat.id, message_menu, reply_markup=tsn_keyboard)
Пример #3
0
 def test_get_menu_should_display_menu(self):
     #arrange
     #act
     actual = len(menu.get_menu())
     expected = 1
     #assert
     self.assertEqual(expected, actual)
Пример #4
0
def get_relevant_data(message_text):
    shuttle_command_names = ["SHUTTLE HELP", "SHUTTLE CAMPUS", "SHUTTLE METRO"]
    menu_command_names = [
        "MENU BREAKFAST", "MENU LUNCH", "MENU SNACKS", "MENU DINNER"
    ]
    directory_command_names = ["INFIRMARY", "MAINTENANCE", "HOUSEKEEPING"]

    # First check if the message sent is any of the 3 SHUTTLE commands
    if message_text in shuttle_command_names:
        return_message = shuttle.get_shuttle(message_text)

    # Then check if the message sent is any of the 3 MENU commands
    elif message_text in menu_command_names:
        return_message = menu.get_menu(message_text)

    # Then check if the message sent is any of the phone directory commands
    elif message_text in directory_command_names:
        return_message = directory.get_directory(message_text)

    # If it is neither of the valid commands
    else:
        # For the shitty Facebook review process
        return_message = "Invalid command. Use the menu at the bottom of this screen to get desired information."

    # wow, that was new :O. Basically, if there are non-ASCII characters, skip them
    printable = set(string.printable)
    filter(lambda x: x in printable, return_message)

    # Add this message at the end of every message being sent back hehe
    return_message += '\n\nIf you like this bot and have a GitHub account, I\'ll be grateful if you can star the repository here: https://github.com/agdhruv/shuttle-bot'

    return return_message
Пример #5
0
def help_message(message):
    message_menu = menu.get_menu(
        "SELECT text FROM menu_text WHERE name LIKE 'help'")
    help_keyboard = types.InlineKeyboardMarkup(row_width=1)
    start_button = types.InlineKeyboardButton(
        text="/start - показать приветствие", callback_data="/start")
    help_button = types.InlineKeyboardButton(
        text="/help -  показать список всех команд", callback_data="/menu")
    tsn_button = types.InlineKeyboardButton(
        text="/tsn - показать информацию о ТСН", callback_data='/tsn')
    government_button = types.InlineKeyboardButton(
        text="/government - информация о госорганах",
        callback_data="/government")
    services_button = types.InlineKeyboardButton(
        text="/services - список услуг", callback_data='/services')
    bill_button = types.InlineKeyboardButton(text="/bill - квитанция за КУ",
                                             callback_data="/bill")
    check_button = types.InlineKeyboardButton(
        text="/check - проверка платежей и наличия задолженности",
        callback_data="/check")
    news_button = types.InlineKeyboardButton(text="/news - показать новости",
                                             callback_data="/news")

    help_keyboard.add(start_button, help_button, tsn_button, services_button,
                      government_button, bill_button, check_button,
                      news_button)
    bot.send_message(message.chat.id, message_menu, reply_markup=help_keyboard)
Пример #6
0
def webhook():
    # endpoint for processing incoming messaging events
    data = request.get_json()
    log(data)  # you may not want to log every incoming message in production, but it's good for testing

    if data["object"] == "page":

        for entry in data["entry"]:
            for messaging_event in entry["messaging"]:

                if messaging_event.get("message"):  # someone sent us a message

                    sender_id = messaging_event["sender"]["id"]        # the facebook ID of the person sending you the message
                    recipient_id = messaging_event["recipient"]["id"]  # the recipient's ID, which should be your page's facebook ID
                    if "text" in messaging_event["message"]:
                        message_text = messaging_event["message"]["text"]  # the message's text
                    else:
                        message_text = "Not identified"

                    message_text = message_text.upper() # convert to uppercase to make things easier

                    shuttle_command_names = ["SHUTTLE HELP","SHUTTLE CAMPUS","SHUTTLE METRO"]
                    menu_command_names = ["MENU BREAKFAST","MENU LUNCH","MENU SNACKS","MENU DINNER"]
                    directory_command_names = ["INFIRMARY", "MAINTENANCE", "HOUSEKEEPING"]
                    admin_command_names = ["ADMIN MENU"]

                    # First check if the message sent is any of the 3 SHUTTLE commands
                    if message_text in shuttle_command_names:
                        return_message = shuttle.get_shuttle(message_text)
                        return_message += '\n\nIf you like this bot and have a GitHub account, I\'ll be grateful if you can star the repository here: https://github.com/agdhruv/shuttle-bot'
                        send_message(sender_id, return_message)
                    
                    # Then check if the message sent is any of the 3 MENU commands
                    elif message_text in menu_command_names:

                        return_message = menu.get_menu(message_text)

                        # wow, that was new :O. Basically, if there are non-ASCII characters, skip them
                        printable = set(string.printable)
                        filter(lambda x: x in printable, return_message)

                        # Finally send the message
                        return_message += '\n\nIf you like this bot and have a GitHub account, I\'ll be grateful if you can star the repository here: https://github.com/agdhruv/shuttle-bot'
                        send_message(sender_id, return_message)

                    # Then check if the message sent is any of the directory commands
                    elif message_text in directory_command_names:
                        return_message = directory.get_directory(message_text)
                        return_message += '\n\nIf you like this bot and have a GitHub account, I\'ll be grateful if you can star the repository here: https://github.com/agdhruv/shuttle-bot'
                        send_message(sender_id, return_message)

                    # If it is neither of the valid commands
                    else:
                        # For the shitty Facebook review process
                        return_message = "Invalid command.\n\n1. SHUTTLE HELP to know more SHUTTLE commands.\n2. MENU BREAKFAST (LUNCH, SNACKS, DINNER) for mess menu.\n3. INFIRMARY, MAINTENANCE, HOUSEKEEPING for contact details."
                        return_message += '\n\nIf you like this bot and have a GitHub account, I\'ll be grateful if you can star the repository here: https://github.com/agdhruv/shuttle-bot'
                        send_message(sender_id, return_message)

    return "ok", 200
Пример #7
0
def menu(bot, update, args):
    """Send the menu."""
    import menu
    if len(args) == 0:
        weekday = get_weekday_for_current_menu()
        update.message.reply_text(menu.get_menu(weekday))
    else:
        try:
            weekday = decode_weekday(args[0])
            if isinstance(weekday, int):
                update.message.reply_text(menu.get_menu(weekday))
            else:
                raise ValueError('weekday not known.')
        except Exception:
            update.message.reply_text(
                'Es ist ein Fehler aufgetreten. Bitte probieren Sie /menu <weekday>'
            )
Пример #8
0
 def handle_hotkey(self, key):
  """Does the actual handling in a platform-independant way."""
  if self.key_timer:
   self.key_timer.cancel()
  key = key.lower()
  mode = modes.get_current_mode()
  if key == 'subtract':
   get_menu()
  elif key in ['divide', 'decimal']:
   modes.switch_mode({'divide': 'operation', 'decimal': 'shift'}[key])
   if key == 'decimal':
    self.autocapitalise = False
  elif key == 'add':
   if mode in [modes.MODE_OPERATION_STANDARD, modes.MODE_OPERATION_NUMBERS]:
    self.press_current_key()
    press('backspace')
   else:
    pressHoldRelease(application.config.get(mode.name, key, 'alt'))
  elif key == 'multiply':
   self.press_current_key()
  else:
   if mode == modes.MODE_OPERATION_NUMBERS: # Pass numbers straight through.
    press(key[-1])
   elif mode == modes.MODE_OPERATION_STANDARD:
    if key == 'enter':
     self.key_value = 'enter'
    elif key == self.last_key:
     self.index += 1
    else:
     self.press_current_key()
     self.index = 0
    possible_keys = application.config.get('keys', key)
    if self.index >= len(possible_keys):
     self.index = 0
    self.key_value = possible_keys[self.index]
    if self.key_value == ' ': # A space must be converted before sending.
     self.key_value = 'spacebar'
    output.output(self.key_value)
   else:
    pressHoldRelease(application.config.get(mode.name, key))
  self.last_key = key
  if mode == modes.MODE_OPERATION_STANDARD:
   t = time()
   self.key_timer = Timer(application.config.get('settings', 'timeout'), self.press_current_key, args = [t])
   self.key_timer.start()
   self.last_key_time = t
Пример #9
0
def start_message(message):
    message_menu = menu.get_menu("SELECT text FROM menu_text WHERE name LIKE 'start'") \
        .format(message.from_user.first_name)
    start_keyboard = types.InlineKeyboardMarkup(row_width=1)
    menu_button = types.InlineKeyboardButton(text="Начать работу",
                                             callback_data="/menu")
    url_button = types.InlineKeyboardButton(
        text="Документация проекта", url="https://github.com/rjeka/ldMayakBot")
    start_keyboard.add(menu_button, url_button)
    bot.send_message(message.chat.id,
                     message_menu,
                     reply_markup=start_keyboard)
Пример #10
0
def tsn_userinfo(message, user_info):
    if security.check_user_id(user_info):
        message_menu = menu.get_user_info("SELECT * from users WHERE telegram_id={};".format(user_info))
        tsn_keyboard = types.InlineKeyboardMarkup(row_width=1)
        tsn_button = types.InlineKeyboardButton(text="Вернуться в меню ТСН", callback_data="/tsn")
        tsn_keyboard.add(tsn_button)
        keyboards.main_menu_key(tsn_keyboard)
        bot.send_message(message.chat.id, message_menu + str(user_info), reply_markup=tsn_keyboard)
    else:
        message_menu = menu.get_menu("SELECT text FROM menu_text WHERE name LIKE 'tsn_access_deny'")
        tsn_keyboard = types.InlineKeyboardMarkup(row_width=1)
        get_id_button = types.InlineKeyboardButton(text="Получить Telegram ID", callback_data="/getid")
        tsn_keyboard.add(get_id_button)
        keyboards.main_menu_key(tsn_keyboard)
        bot.send_message(message.chat.id, message_menu, reply_markup=tsn_keyboard)
Пример #11
0
def display_menu():
    menu_list = menu.get_menu()
    for item in menu_list:
        print(item)
Пример #12
0
def callback_daily_menu(bot, job):
    import menu
    bot.send_message(job.context[0],
                     text=menu.get_menu(get_weekday_for_current_menu()))
Пример #13
0
def get_servises(message, user_info, service_group):
    if security.check_user_id(user_info):
        con = psycopg2.connect(database=os.environ['DB_NAME'],
                               user=os.environ['DB_USER'],
                               password=os.environ['DB_PASS'],
                               host=os.environ['DB_HOST'],
                               port=os.environ['DB_PORT'])
        services_keyboard = types.InlineKeyboardMarkup(row_width=1)

        with con.cursor() as cur:
            cur.execute(
                " SELECT description, contact, first_tel, second_tel, email, url, vk, instagram, other_contact"
                " FROM services WHERE service_group='{}';".format(
                    service_group))
            rows = cur.fetchall()
            print(len(rows))
            if len(rows) == 0:
                service_button = types.InlineKeyboardButton(
                    text="Вернуться в меню услуг", callback_data="/services")
                services_keyboard.add(service_button)
                keyboards.main_menu_key(services_keyboard)
                bot.send_message(
                    message.chat.id,
                    "К сожалению в данном разделе пока нет записей",
                    reply_markup=services_keyboard)
            else:
                for row in rows:
                    bot_message = ""
                    if row[0]:
                        bot_message = bot_message + row[0] + "\n\n"
                    if row[1]:
                        bot_message = bot_message + "Контактное лицо: " + row[
                            1] + "\n\n"
                    if row[2]:
                        bot_message = bot_message + "Тел: " + row[2] + "\n\n"
                    if row[3]:
                        bot_message = bot_message + "Тел: " + row[3] + "\n\n"
                    if row[4]:
                        bot_message = bot_message + "email: " + row[4] + "\n\n"
                    if row[5]:
                        bot_message = bot_message + "сайт: " + row[5] + "\n\n"
                    if row[6]:
                        bot_message = bot_message + "VK:\n" + row[6] + "\n\n"
                    if row[7]:
                        bot_message = bot_message + "Instagram:\n" + row[
                            7] + "\n\n"
                    if row[8]:
                        bot_message = bot_message + "Дополнительная информация:\n" + row[
                            8] + "\n\n"

                    time.sleep(1)
                    bot.send_message(message.chat.id, bot_message)

                service_button = types.InlineKeyboardButton(
                    text="Вернуться в меню услуг", callback_data="/services")
                services_keyboard.add(service_button)
                keyboards.main_menu_key(services_keyboard)
                bot.send_message(
                    message.chat.id,
                    "Запрос выполнен успешно найдено {} записи(ей)".format(
                        len(rows)),
                    reply_markup=services_keyboard)
    else:
        message_menu = menu.get_menu(
            "SELECT text FROM menu_text WHERE name LIKE 'tsn_access_deny'")
        services_keyboard = types.InlineKeyboardMarkup(row_width=1)
        get_id_button = types.InlineKeyboardButton(text="Получить Telegram ID",
                                                   callback_data="/getid")
        services_keyboard.add(get_id_button)
        keyboards.main_menu_key(services_keyboard)
        bot.send_message(message.chat.id,
                         message_menu,
                         reply_markup=services_keyboard)
Пример #14
0
while True:
    print('Welcome to Komodo Burgers')
    user_input = input('Choose a menu option:\n' + '1. Add a option\n' +
                       '2. Menu List\n' + '3. Update menu Option\n'
                       '4. Delete Item\n' + '5. Exit')

if user_input == '1':
    meal_number = input('Enter Menu Number: ')
    meal_name = input('Enter Meal Name: ')
    description = input('Enter Description: ')
    ingredients = input('View Ingredients: ')
    price = input('Menu Price: ')

elif user_input == '2':
    menu = menu.get_menu()
    print(menu)

elif user_input == '3':
    menu_to_update = input('Enter menu item to update: ')
    meal_number = input('Enter new Menu: ')
    meal_name = input('Enter new item: ')
    description = input('Enter new description: ')
    ingredients = input('Enter new ingredients: ')
    price = input('Enter new price: ')
    menu.update_menu(meal_number, meal_name, description, ingredients, price)

elif user_input == '4':
    menu_to_del = input('Enter menu item to delete: ')

if menu.delete_menu(menu_to_del) is None:
Пример #15
0
def callback_daily_menu(bot, job):
    import menu
    bot.send_message(job.context[0],
                     text=menu.get_menu(get_weekday_for_current_menu()),
                     parse_mode=telegram.ParseMode.MARKDOWN)
Пример #16
0
 def __init__(self, *args, **kwargs):
  super(TrayIcon, self).__init__()
  self.SetIcon(wx.IconFromBitmap(wx.EmptyBitmap(-1, -1)), application.name)
  self.Bind(wx.EVT_TASKBAR_CLICK, lambda event: get_menu())
Пример #17
0
def main():
    with (Path(__file__).parent / 'influxdb_config.json').open(mode='r') as fp:
        config = json.load(fp)
    menu = get_menu(config)
    menu.call()