Example #1
0
async def process_callback_check_pay(callback_query: types.CallbackQuery):
	cb_m_id = callback_query.message.chat.id
	if callback_query.data.endswith(str(callback_query.from_user.id)):
		last_tr = banking.mono_check(cb_m_id)
		if int(db.get_from_db(cb_m_id, "price")) <= last_tr['amount'] / 100:
			str_to_db = db.get_from_db(str(cb_m_id),"list_user")
			try:
				user = last_tr['comment'] + "✅"
				not_done = last_tr['comment']
				if str_to_db == "none":
					db.insert_db(cb_m_id,list_user= user + "\n")
				elif str_to_db.find(not_done) > -1:
					db.insert_db(cb_m_id,list_user=str_to_db.replace(not_done,user))
					await bot.send_message(cb_m_id,"Oплата прошла успешно")
				elif str_to_db.find(user) == -1:
					db.insert_db(cb_m_id,list_user=str_to_db + user + "\n")
					await bot.send_message(cb_m_id,"Oплата прошла успешно")
				else:
					await bot.send_message(cb_m_id,"Oплата не прошла, обратитесь к админу")
			except:
				await bot.send_message(cb_m_id,"Oплата не прошла, обратитесь к админу")
		else:
			await bot.send_message(cb_m_id,"Oплата не прошла, обратитесь к админу")
		data = callback_query.data.split()
		await bot.edit_message_reply_markup(cb_m_id, int(data[1]) + 1)
Example #2
0
def decide_offer():
  #Display the property which the user owns and existing offer on the property via inner join
  #Selecting the property that has an offer that is owned by current customer
  myQ = "SELECT a.address, b.decision, b.amtsold from properties a inner join offers b on a.property_id=b.property_id where b.cust_id =" + current_user.user_id()
  myD = db.get_from_db(myQ)
  decision = myD[0][1] #Get the decision of property from offers table

  if (decision >= 1):
    eg.msgbox(msg="No current offers.")

  elif (decision == 0):
    query = "SELECT a.property_type, a.address, a.MINprice, b.bid, b.amtsold, a.property_id FROM properties a inner join offers b on a.user="******"Property Type: " + str(property_type) + "\n" + "Address: " + str(address) + "\n" + "Minimum Price: " + str(minprice) + "\n" + "Bid: " + str(bid) + "\n" + "Maximum Bid: " + str(amtsold) + "\n"

    text = "Accept or Reject Existing Offer?"
    choices = ["Accept", "Reject"]
    reply=eg.boolbox(msg, title=text, choices=choices) #Boolbox returns 1 if the first button is chosen. Otherwise returns 0.

    #If offer is accepted
    if (reply == 1):
      eg.msgbox(msg="Offer Accepted")
      acceptoffer = "UPDATE offers set decision=1 where cust_id=" + current_user.user_id()
      db.add_to_db(acceptoffer)
    #If offer is rejected
    if (reply == 0):
      eg.msgbox(msg="Offer Rejected")
      rejectoffer = "UPDATE offers set decision=3 where cust_id=" + current_user.user_id()
      db.add_to_db(rejectoffer)
Example #3
0
def translate(bot, update):
    lock = get_from_db(update.message.chat_id, lock=True)

    if lock == '1':
        update.message.reply_text('You have to choose languages in the message above')
        return

    text = update.message.text
    source, target = get_from_db(chat_id=update.message.chat_id, source=True, target=True)
    result, data = deepl.translate(text, source=source, target=target)
    update.message.reply_text(result, quote=True)
Example #4
0
def pogodka(chat_id):
    date = db.get_from_db(chat_id, "date").split('.')
    locale = db.get_from_db(str(chat_id), "locale").strip()
    observation = mgr.forecast_at_coords(float(locale.split()[0]),
                                         float(locale.split()[1]),
                                         '3h').forecast
    need_d = datetime(2021, int(date[1]), int(date[0]),
                      12).strftime("%m/%d/%Y %H:%M")
    for i in observation:
        if need_d == i.reference_time('date').strftime("%m/%d/%Y %H:%M"):
            temp = i.temperature("celsius")
            status = i.detailed_status
            return f"На тусовочке будет {status} - {temp['temp']} градусов."
def check_filter(ots_id):
    """
    Check document in ots_id against a list of regex rules.
    Return set of filters triggered by document in ots_id (returns empty set if no filters were triggered)
    """
    filters = set()
    document = db.get_from_db(ots_id)

    if includes_severe_accident(document):
        filters.add('Severe Accident')

    media = includes_media(document)
    if media:
        filters.add(f'Media ({(media)})')

    key_test = includes_keyword(document)
    if key_test:
        found_keyword = key_test.group(0)
        filters.add(f'Keyword: {found_keyword}')

    if includes_planecrash(document):
        filters.add('Planecrash')

    if includes_brawl(document):
        filters.add('Brawl')

    if includes_animal(document):
        filters.add('Animal')

    return filters
Example #6
0
def mono_bank(char_id):
    token = db.get_from_db(char_id, "mono").split()[0]
    mono = monobank.Client(token)
    user_info = mono.get_client_info()
    for i in user_info['accounts']:
        if i['type'] == 'white':
            return i['balance'] / 100
Example #7
0
async def process_callback_mono_pay(callback_query: types.CallbackQuery):
	cb_m_id = callback_query.message.chat.id
	if callback_query.data.endswith(str(callback_query.from_user.id)):
		await bot.answer_callback_query(callback_query.id)
		info = db.get_from_db(cb_m_id,"mono")
		price = db.get_from_db(cb_m_id,"price")
		data = callback_query.data.split()
		kb.check_b.callback_data = "check_pay " + str(callback_query.message.message_id) + " " + data[2]
		if info == "none":
			await bot.send_message(cb_m_id,"К сожалению Монобанк не был подключен",reply_markup=kb.check_kb)
		else:
			card_num = info.split()[1]
			await bot.send_message(cb_m_id, f'Вы выбрали Монобанк, теперь \
отправьте больше {price} гривен на {card_num} и укажите свой ник в комментарии к \
платежу . После отправки нажмите Проверить',reply_markup=kb.check_kb)
		await bot.edit_message_reply_markup(cb_m_id, int(data[1]) + 1)
Example #8
0
def offer_history(prop_id):
    # get the offers from the property and users info for those who made offers
    query = "SELECT bid, cust_id FROM offers WHERE property_id=" + prop_id
    prop = db.get_from_db(query)
    msg = "Offer History \n"
    for row in prop:
        msg += "Bid: " + str(row[0]) + "\t" + "From: Customer #" + str(row[1]) + " \n"

    eg.msgbox(msg)
Example #9
0
def property_menu(prop_id):
  prop = db.get_from_db("SELECT address, city, property_type, MAXprice FROM properties WHERE property_id=" + prop_id)
  msg = str(prop[0][0]) +" "+ str(prop[0][1])
  choices = ["View Full Details", "View Offer History", "Make An Offer"]
  menu = eg.choicebox(msg=msg, title="Property App:", choices=choices)

  if (menu == "View Full Details" ): viewProperty(prop_id)
  if (menu == "View Offer History" ): offer_history(prop_id)
  if (menu == "Make An Offer") : make_offer(prop_id)
Example #10
0
def offer_history(prop_id):
  #get the offers from the property and users info for those who made offers
  query = "SELECT bid, cust_id FROM offers WHERE property_id=" + prop_id
  prop = db.get_from_db(query)
  msg = "Offer History \n"
  for row in prop:
    msg += "Bid: " + str(row[0]) + "\t" + "From: Customer #" + str(row[1]) +" \n"

  eg.msgbox(msg)
Example #11
0
def property_menu(prop_id):
  prop = db.get_from_db("SELECT address, city, property_type, MAXprice FROM properties WHERE property_id=" + prop_id)
  msg = str(prop[0][0]) +" "+ str(prop[0][1])
  choices = ["View Full Details", "View Offer History", "Make An Offer"]
  menu = eg.choicebox(msg=msg, title="Property App:", choices=choices)

  if (menu == "View Full Details" ): viewProperty(prop_id)
  if (menu == "View Offer History" ): offer_history(prop_id)
  if (menu == "Make An Offer") : make_offer(prop_id)
Example #12
0
async def process_callback_nal_pay(callback_query: types.CallbackQuery):
	cb_m_id = callback_query.message.chat.id
	if callback_query.data.endswith(str(callback_query.from_user.id)):
		await bot.send_message(cb_m_id, "Теперь отправь свой адрес, например Антонова 43")
		await Test.term.set()
		await bot.answer_callback_query(callback_query.id)
		info_mono = db.get_from_db(cb_m_id,"mono")
		info_private = "none"
		if info_mono == "none":
			card_num = info_mono
		else:
			card_num = info_mono.split()[1]
		price = db.get_from_db(cb_m_id,"price")
		data = callback_query.data.split()
		kb.check_b.callback_data = "check_pay " + str(callback_query.message.message_id) + " " + data[2]
		await bot.send_message(cb_m_id, f'Вы выбрали Наличные, теперь отправьте \
больше {price} гривен на {card_num} или на {info_private} и укажите свой ник в \
комментарии к платежу подождите после отправки 1 минуту и нажмите Проверить',reply_markup=kb.check_kb)
		await bot.edit_message_reply_markup(cb_m_id, int(data[1]) + 1)
Example #13
0
def to_callback(bot, update):
    query = update.callback_query
    target = query.data[2:]

    update_in_db(query.message.chat_id, target=target, lock='0')
    source = get_from_db(query.message.chat_id, source=True)

    bot.edit_message_text(text="Currently translating from {} to {}".format(meaning[source], meaning[target]),
                          chat_id=query.message.chat_id,
                          message_id=query.message.message_id)
Example #14
0
def offer_history(prop_id):
  #Select bid amount and customer id from offers table for a single property
  query = "SELECT bid, cust_id FROM offers WHERE property_id=" + prop_id
  prop = db.get_from_db(query) #Prop is a list of offers that SQL returns
  msg = "Offer History \n"
  for row in prop:
    #Adding fields to view
    msg += "Bid: " + str(row[0]) + "\t" + "From: Customer #" + str(row[1]) +" \n"

  eg.msgbox(msg)
Example #15
0
def mono_check(char_id):
    token = db.get_from_db(char_id, "mono").split()[0]
    mono = monobank.Client(token)
    user_info = mono.get_client_info()
    id_w = ""
    for i in user_info['accounts']:
        if i['type'] == 'white':
            id_w = i['id']
    time_now = datetime.datetime.now()
    time_p = datetime.datetime.now() - datetime.timedelta(days=1)
    stat = mono.get_statements(id_w, time_p, time_now)
    return stat[0]
Example #16
0
def dashboard():
  global current_user
  #msg = str(current_user.user_id())
  #eg.msgbox(msg)
  msg = 'Your Properties: \n Address \t City \t Type'
  query = "SELECT address, city, property_type FROM properties WHERE user ="******"\t " + str(item)
  msg += "\n"
  eg.msgbox(msg)
Example #17
0
def dashboard():
    global current_user
    # msg = str(current_user.user_id())
    # eg.msgbox(msg)
    msg = "Your Properties: \n Address \t City \t Type"
    query = "SELECT address, city, property_type FROM properties WHERE user ="******"\t " + str(item)
    msg += "\n"
    eg.msgbox(msg)
Example #18
0
def property_list():
  #Return a list of rows of properties from the databae
  properties = db.get_from_db("SELECT property_id, property_type, address FROM properties") #Users are shown a list of all existing properties
  choices = []  #List of strings that you can click on
  number = len(properties) #Count number of properties
  for row in properties:
    choices.append(str(row[0]) + "\t " + str(row[1]) + "\t" + str(row[2]))  #Append a string of formatted property title to list of choices

  property_list = eg.choicebox(msg='Showing: ' + str(number) +" properties", title=' ', choices=choices) #Sending data to easy gui
  prop_id = property_list.split()[0]
  #Divides all the choices, so that when one is selected it will take you to property_menu
  if (prop_id):
    property_menu(prop_id)
Example #19
0
def property_list():

  properties = db.get_from_db("SELECT property_id, property_type, address FROM properties")
  choices = []
  number = len(properties)
  for row in properties:
    choices.append(str(row[0]) + "\t " + str(row[1]) + "\t" + str(row[2]))

  property_list = eg.choicebox(msg='Showing: ' + str(number) +" properties", title=' ', choices=choices)
  prop_id = property_list.split()[0]

  if (prop_id):
    property_menu(prop_id)
Example #20
0
def property_list():

    properties = db.get_from_db("SELECT property_id, property_type, address FROM properties")
    choices = []
    number = len(properties)
    for row in properties:
        choices.append(str(row[0]) + "\t " + str(row[1]) + "\t" + str(row[2]))

    property_list = eg.choicebox(msg="Showing: " + str(number) + " properties", title=" ", choices=choices)
    prop_id = property_list.split()[0]

    if prop_id:
        property_menu(prop_id)
Example #21
0
def viewProperty(prop_id):
  prop = db.get_from_db("SELECT address, city, zipcode, bedrooms, bathrooms, sqft, MINprice, MAXprice  FROM properties WHERE property_id=" + prop_id)

  msg = ""

  fields = ["Address", "City", "Zip", "Beds", "Baths", "Sqft", "Min Price", "Max Price"]
  #this breaks when fields are different
  i = 0
  for value in prop[0]:
    if value:
      msg += fields[i] + ": \t  " + str(value) + " \n"
      i = i + 1

  eg.msgbox(msg)
Example #22
0
def dashboard():
  #An inner join is used to display the property address, city, and property type of the..
  #..properties that belong to the current user.
  query = "SELECT b.address, b.city, b.property_type  from properties.customer a inner join properties.properties b on a.cust_id=b.user WHERE a.cust_id =" + current_user.user_id()
  rows = db.get_from_db(query)  #Rows is a list of properties that SQL returns
  msg = ""
  for row in rows: #For loop goes through each property
    address = row[0]
    city = row[1]
    property_type = row[2]
    #Adding fields to view
    msg += "Address: " + str(address) + "\n" + "City: " + str(city) + "\n" + "Type: " + str(property_type) + "\n" + "\n"

  eg.msgbox(msg=msg, title="Your Properties", ok_button="OK")
Example #23
0
def viewProperty(prop_id):
    prop = db.get_from_db(
        "SELECT address, city, zipcode, bedrooms, bathrooms, sqft, MINprice, MAXprice  FROM properties WHERE property_id="
        + prop_id
    )

    msg = ""

    fields = ["Address", "City", "Zip", "Beds", "Baths", "Sqft", "Min Price", "Max Price"]
    # this breaks when fields are different
    i = 0
    for value in prop[0]:
        if value:
            msg += fields[i] + ": \t  " + str(value) + " \n"
            i = i + 1

    eg.msgbox(msg)
Example #24
0
def viewProperty(prop_id):
  #Return all details of one property
  #Query to select fields from one property
  prop = db.get_from_db("SELECT address, city, zipcode, bedrooms, bathrooms, sqft, MINprice, MAXprice  FROM properties WHERE property_id=" + prop_id)

  msg = ""

  fields = ["Address", "City", "Zip", "Beds", "Baths", "Sqft", "Min Price", "Max Price"]

  #Formatting view with fields and values
  i = 0
  for value in prop[0]: #Prop is a list of rows from property table; here we are selecting the first item
    if value:   #Loop through the fields in property to see if it is not null
      msg += fields[i] + ": \t  " + str(value) + " \n"    #Msg is a string that we add fields to (with indentation) if they are not empty
      i = i + 1

  eg.msgbox(msg)
Example #25
0
def login():
  global current_user
  #Data to be displayed in the window: message, title, login labels and inputs
  msg = "Hello and welcome to the App!"
  title = "Real Estate App"
  fieldNames = ["Email", "Password"]
  fieldValues = []
  form = eg.multpasswordbox(msg,title, fieldNames)

  login = 1
  while login == 1:
    if form == None: break
    errmsg = ""

    for i in range(len(form)):
        # make sure that none of the fields were left blank
        if form[i].strip() == "":
            errmsg = errmsg + ('"%s" is a required field.\n\n' % fieldNames[i])

        #otherwise, proceed to authentication
        if errmsg == "":
          entered_email = form[0]
          entered_pass = form[1]
          users = db.get_from_db("SELECT cust_email, password, cust_id, fname, lname FROM customer")
          # this can be improved to be less inefficient

          #Check if the email is if the users table
          for usr in users:
            email = usr[0]
            password = usr[1]
            user_id = usr[2]
            fname = usr[3]
            lname = usr[4]

            if (email == entered_email):
              if (entered_pass == password):
                #Create a new user instance for use later.
                current_user = User(user_id,fname,lname)
                login = 0 #stops the login process


  #If the user has been authenticated, we let them know now via a message:
  msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
  eg.msgbox(msg)
Example #26
0
def login():
    global current_user
    # Data to be displayed in the window: message, title, login labels and inputs
    msg = "Hello and welcome to the App!"
    title = "Real Estate App"
    fieldNames = ["Email", "Password"]
    fieldValues = []
    form = eg.multpasswordbox(msg, title, fieldNames)

    login = 1
    while login == 1:
        if form == None:
            break
        errmsg = ""

        for i in range(len(form)):
            # make sure that none of the fields were left blank
            if form[i].strip() == "":
                errmsg = errmsg + ('"%s" is a required field.\n\n' % fieldNames[i])

            # otherwise, proceed to authentication
            if errmsg == "":
                entered_email = form[0]
                entered_pass = form[1]
                users = db.get_from_db("SELECT cust_email, password, cust_id, fname, lname FROM customer")
                # this can be improved to be less inefficient

                # Check if the email is if the users table
                for usr in users:
                    email = usr[0]
                    password = usr[1]
                    user_id = usr[2]
                    fname = usr[3]
                    lname = usr[4]

                    if email == entered_email:
                        if entered_pass == password:
                            # Create a new user instance for use later.
                            current_user = User(user_id, fname, lname)
                            login = 0  # stops the login process

    # If the user has been authenticated, we let them know now via a message:
    msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
    eg.msgbox(msg)
Example #27
0
def setup(bot, update):
    lock = get_from_db(update.message.chat_id, lock=True)

    if lock == '1':
        update.message.reply_text('You have to choose languages in the message above')
        return

    update_in_db(update.message.chat_id, lock='1')

    first_row = cc[:5]
    second_row = cc[5:]

    buttons = [
        [InlineKeyboardButton(text=get_flag(f), callback_data='from' + clr(f)) for f in first_row],
        [InlineKeyboardButton(text=get_flag(f), callback_data='from' + f) for f in second_row]
    ]
    reply_markup = InlineKeyboardMarkup(buttons, resize_keyboard=False)

    update.message.reply_text('Please choose language to translate from:', reply_markup=reply_markup)
Example #28
0
def make_offer(prop_id):
  #Get the details of property
  query = "SELECT address, MINprice, MAXprice FROM properties WHERE property_id =" + str(prop_id)
  prop = db.get_from_db(query)
  address = prop[0][0]
  minprice = prop[0][1]

  msg = "How much would like to offer? (Minimum offer is: $ " + str(minprice) +")" #Add min price to message
  form = eg.enterbox(msg=msg, title="Make An Offer For" + str(address), default='', strip=True) #Add address to title

  insert_offer = ''

  if (form): #If anything is entered to form
    #Add offer to database
    insert_offer = "INSERT INTO offers (property_id, cust_id, bid) VALUES (" + wrap(prop_id) + wrap(current_user.user_id()) + wrap(form)

  insert_offer = insert_offer[:-2] + ")" #-2 to remove excess )'; add ) to end query

  db.add_to_db(insert_offer)
Example #29
0
def login():
  global current_user
  #Data to be displayed in the window: message, title, login labels and inputs
  msg = "Hello and welcome to the App!"
  title = "Real Estate App"
  fieldNames = ["Email", "Password"]
  fieldValues = []

  #Loop until user is authenticated/until login = 0
  login = 1
  while login == 1:
    form = eg.multpasswordbox(msg,title, fieldNames)
    entered_email = form[0]
    entered_pass = form[1]
    #Uses the get_from_db function that is equivalent to execute
    #This query returns a list of email, password, cust_id, and full name from customer table where the email is the same as the entered email
    user = db.get_from_db("SELECT cust_email, password, cust_id, fname, lname FROM customer WHERE cust_email =" + "'"+str(entered_email)+"'")
    #Get_from_db function returns a list of rows which consist of a single row; inside row are fields from select statement

    #User email and password verification
    if user:
      email = user[0][0];   #User is a list inside of a list of users
      password = user[0][1]
      user_id = user[0][2]
      fname = user[0][3]
      lname = user[0][4]
      if (email == entered_email):
        if (password == entered_pass):
          current_user = User(user_id, fname, lname)
          login = 0
          #If the user has been authenticated, we let them know now via a message:
          msg = "Thank you for logging in, " + current_user.name() + "."+" \n Press ok to get started."
          eg.msgbox(msg)
          menu()
        else:
          #If the user uses the incorrect password, we let them know via a message:
          msg = "Wrong password."
    b = list(user)  #Check to see if the SQl query returns anything that matches specific email/password combination
    #Check to see if credentials match the database
    if (len(b) <= 0): #If there is nothing in the user list, there is no email and password combination in the database
      #If the user inputs an incorrect email and password combination, we let them know via a message:
      msg = "No such email and password combination."
Example #30
0
def create_user():
  global current_user
  msg = "Please enter the new account details:"
  error_msg= ''
  title = "Create New User"
  fieldNames = ["First Name:", "Last Name:", "Phone Number:", "Email:", "Password:"******"(fname, lname, phone_number, password, cust_email)"
  query = "INSERT INTO customer" + fields + "VALUES ("
  values = ''

  for field in fieldList:
    values += wrap(field)

  values = values[:-2]
  query += values + ")"

  db.add_to_db(str(query))

  query = "SELECT cust_id FROM customer where cust_email =" + "'"+str(cust_email)+"'"
  row = db.get_from_db(query)
  user_id = row[0]
  current_user = User(user_id,fname,lname)

  msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
  eg.msgbox(msg)
Example #31
0
def create_user():
    global current_user
    msg = "Please enter the new account details:"
    error_msg = ""
    title = "Create New User"
    fieldNames = ["First Name:", "Last Name:", "Phone Number:", "Email:", "Password:"******"(fname, lname, phone_number, password, cust_email)"
    query = "INSERT INTO customer" + fields + "VALUES ("
    values = ""

    for field in fieldList:
        values += wrap(field)

    values = values[:-2]
    query += values + ")"

    db.add_to_db(str(query))

    query = "SELECT cust_id FROM customer where cust_email =" + "'" + str(cust_email) + "'"
    row = db.get_from_db(query)
    user_id = row[0]
    current_user = User(user_id, fname, lname)

    msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
    eg.msgbox(msg)
Example #32
0
def create_user():
  global current_user
  msg = "Please enter the new account details:"
  error_msg= ''
  title = "Create New User"
  fieldNames = ["First Name:", "Last Name:", "Phone Number:", "Email:", "Password:"******"(fname, lname, phone_number, password, cust_email)"

  #Prepare a query to be sent to SQL
  query = "INSERT INTO customer" + fields + "VALUES ("
  values = ''   #Set up blank string that will be appended to query
  for field in fieldList: #Loop through each field and add to values
    values += wrap(field)  #Helper function to format string

  values = values[:-2] #-2 to remove excess )' from string
  query += values + ")" #End query

  db.add_to_db(str(query)) #Send query to database

  #Go back to database once user created to get the new user id
  query = "SELECT cust_id FROM customer where cust_email =" + "'"+str(cust_email)+"'"
  row = db.get_from_db(query)
  user_id = int(row[0][0])  #Selecting first row from list of rows

  current_user = User(user_id,fname,lname) #After the user registers, we instantiate the user object

  #After sign up is completed, we let them know via message:
  msg = "Thank you for logging in, " + current_user.name() + " \n Press ok to get started."
  eg.msgbox(msg)
Example #33
0
async def send_command(message: types.Message):
	if message.text.lower().startswith('/start'):
		db.insert_db(message.chat.id)
		await message.answer( f'{message.from_user.first_name} , добро \
пожаловать к PartyBot!\nЕсть вопросы? Обратись к помощи /help\n')
	elif message.text.lower() == "/help":
		await message.answer("Этот бот поможет организовать тусовочку\n\
/setinfo - установить информацию тусовочки\n/setlocale - установить место\n\
/setdate - установить дату\n/setprice - установить цену\n/setcardinfo \
		- установить автопроверку платежей (Monobank, PrivatBank)")
	elif message.text.lower() == "/setinfo":
		await message.answer("А теперь отправь информацию о тусовочке!")
		await Test.info.set()
	elif message.text.lower() == "/setlocale":
		kb.inline_btn_1.callback_data = "btn1 " + str(message.message_id) + " " + str(message.from_user.id)
		kb.inline_btn_2.callback_data = "btn2 " + str(message.message_id) + " "  + str(message.from_user.id)
		await message.answer("А теперь выбери формат адреса",reply_markup=kb.inline_kb_variant_addres)
	elif message.text.lower() == "/setdate":
		await message.answer("А теперь отправь дату тусовочки!\nНапример 17.03")
		await Test.date.set()
	elif message.text.lower() == "/setprice":
		await message.answer("А теперь отправь стоимость проходки на тусовочку!")
		await Test.price.set()
	elif message.text.lower() == "/setcardinfo":
		kb.mono.callback_data = "monokey " + str(message.message_id) + " " + str(message.from_user.id)
		kb.private.callback_data = "privatekey " + str(message.message_id) + " "  + str(message.from_user.id)
		await message.answer("А теперь выбери свой банк!",reply_markup=kb.bank_kb)
	elif message.text.lower().startswith("/delete"):
		str_to_db = db.get_from_db(str(message.chat.id),"list_user")
		user = message.text.split()[1]
		if str_to_db.find(user) == -1:
			await message.answer(user + " - нет в списке")
		else:
			str_to_db = str_to_db.replace(user + "\n","")
			db.insert_db(message.chat.id,list_user=str_to_db)
			await message.answer(user + " - удалил из списка")
Example #34
0
import time
from datetime import datetime

from config import STATE_FILTER, DELAY, DOWNLOAD_LIMIT
from helpers.log_to_logfile import add_to_log
from helpers.send_to_slack import message_to_slack, create_attachment
import db
import regex_filters

if __name__ == '__main__':
    while True:
        new_stories=db.update(STATE_FILTER, DOWNLOAD_LIMIT)
        if len(new_stories) > 0:
            print(f'Found new stories: {new_stories}:')
            for item in new_stories:
                story = db.get_from_db(item)
                datetime_published = datetime.strptime(story['published'], '%Y-%m-%dT%H:%M:%S%z')
                story_title = story['title'].replace('\n', ' ').replace('\r', '')
                print(f'{datetime_published.strftime("%d.%m.%Y %H:%M:%S")} {story_title} ({story["url"]})')
                filter_result = regex_filters.check_filter(item)
                if filter_result:
                    print(f'+++ {" ".join(str(s) for s in filter_result)} +++')
                    output_message = f'{datetime_published.strftime("%d.%m.%Y %H:%M:%S")} {story_title} ({story["url"]}) [{" ".join(str(s) for s in filter_result)}]'
                    if 'Image' in str(filter_result): # Create attachment for slack for items with image 
                        attached = create_attachment(story)
                        message_to_slack(output_message, attached)
                    else: # Send straight to slack if no image present
                        message_to_slack(output_message)
                    # message_to_slack(f'{datetime_published.strftime("%d.%m.%Y %H:%M:%S")} {story_title} ({story["url"]}) [{" ".join(str(s) for s in filter_result)}]')
                    add_to_log(f'{" ".join(str(s) for s in filter_result)}, {story["url"]}', 'info')
        else:
Example #35
0
def info(bot, update):
    source, target = get_from_db(chat_id=update.message.chat_id, source=True, target=True)
    update.message.reply_text(f'Currently translating from {meaning[source]} to {meaning[target]}')
Example #36
0
async def send_text(message: types.Message):
	m_id = message.chat.id
	proxyDict = {
		"http"  : os.environ.get('FIXIE_URL', ''), 
		"https" : os.environ.get('FIXIE_URL', '')}
	if message.text.lower() == 'погодка':
		try:
			await message.answer(other.pogodka(m_id),reply_markup=delkey)
		except:
			await message.answer("Погодка будет доступна за 5 дней до туссовки.",reply_markup=delkey)
	elif message.text.startswith('/key'):
		await message.answer("Вот мои комманды: ",reply_markup=kb.markup_key)
	elif message.text.lower() == 'дата':
		await message.answer(db.get_from_db(str(m_id),"date"),reply_markup=delkey)
	elif message.text.lower() == 'цена':
		await message.answer(db.get_from_db(str(m_id),"price") + " ₴",reply_markup=delkey)
	elif message.text.lower() == 'инфо':
		await message.answer(db.get_from_db(str(m_id),"info"),reply_markup=delkey)
	elif message.text.lower() == 'кто будет?':
		await message.answer(db.get_from_db(str(m_id),"list_user"),reply_markup=delkey)
	elif message.text.lower() == 'я буду':
		str_to_db = db.get_from_db(str(m_id),"list_user")
		user = message.from_user.username
		if user is None:
			user = message.from_user.full_name
		if str_to_db.find(user) == -1:
			if str_to_db == "none":
				db.insert_db(m_id,list_user= "******" + user + "\n")
			else:
				db.insert_db(m_id,list_user=str_to_db + "@" + user + "\n")
			await message.answer("@" + user + " - добавил тебя в список",reply_markup=delkey)
		else:
			await message.answer("@" + user + " - извини но ты уже в списке",reply_markup=delkey)
	elif message.text.lower() == 'не буду':
		str_to_db = db.get_from_db(str(m_id),"list_user")
		user = message.from_user.username
		if user is None:
			user = message.from_user.full_name
		if str_to_db.find(user) == -1:
			await message.answer("@" + user + " - тебя нет в списке",reply_markup=delkey)
		else:
			str_to_db = str_to_db.replace("@" + user + "\n","")
			db.insert_db(m_id,list_user=str_to_db)
			await message.answer("@" + user + " - удалил тебя из списка",reply_markup=delkey)
	elif message.text.lower() == 'геолока':
		locale = db.get_from_db(str(m_id),"locale").strip()
		if locale[0].isdigit():
			await message.answer_location(locale.split()[0],locale.split()[1])
		else:
			location = geolocator.geocode(locale, language='ru')
			await message.answer(location,reply_markup=delkey)
			await message.answer_location(location.latitude, location.longitude)
	elif message.text.lower() == 'бюджет':
		try:
			# p_price = privat_bank(os.getenv('API_PRIVAT2'),proxyDict, "155325","5168745302334229")
			m_price = int(banking.mono_bank(m_id))
			await message.answer("Бюджет тусовочки 💴 💴 💴 : " + str(m_price) + " ₴",reply_markup=delkey)
		except:
			await message.answer('Cервер выебываеться попробуйте позже 😔 😔 😔',reply_markup=delkey)
	elif message.text.lower() == 'оплатить':
		kb.mono_pay.callback_data = "mono_pay " + str(message.message_id) + " " + str(message.from_user.id)
		kb.private_pay.callback_data = "private_pay " + str(message.message_id) + " " + str(message.from_user.id)
		kb.nal_pay.callback_data = "nal_pay " + str(message.message_id) + " " + str(message.from_user.id)
		await message.answer("Выберите способ оплаты :",reply_markup=kb.payment_kb)