import pyshorteners
import os
import platform
import qrcode
class URL():
action = int(input(" What to do? (1.QrCode 2.ShortUrl) "))
def short_url():
url = input(" URL: ")
n = input(" Choice service ( 1:Os.db, 2:Chilp.it, 3:Da.gd, 4:Is.gd, 5:Qps.ru, 6:TinyURL.com): ")
if n == str(1):
s = pyshorteners.Shortener()
f = s.osdb.short(url)
print(" Short URL: ",f)
elif n == str(2):
s = pyshorteners.Shortener()
short_url = s.chilpit.short(url)
print(" Short URL: ",short_url)
elif n == str(3):
s = pyshorteners.Shortener()
abz = s.dagd.short(url)
print(" Short URL: ",abz)
elif n == str(4):
s = pyshorteners.Shortener()
abv = s.isgd.short(url)
print(" Short URL: ",abv)
elif n == str(5):
s = pyshorteners.Shortener()
abh = s.qpsru.short(url)
print(" Short URL: ",abh)
elif n == str(6):
s = pyshorteners.Shortener()
abk = s.tinyurl.short(url)
print(" Short URL: ",abk)
else:
print(' Error ')
def qr_code():
URL = input(" URL: ")
file = input(" Enter file name:")
filename = file +".png"
img = qrcode.make(URL)
img.save(filename)
if action == 1:
qr_code()
elif action == 2:
short_url()
else:
print(" Error ")
<b> это жирный текст </b>
<u> это подчеркнутый текст </u>
import telebot
token = 'TOKEN'
channel_name = '@CHANNEL'
bot = telebot.TeleBot(token)
@bot.message_handler(content_types=['text', 'audio'])
def send_message_group(message):
doc_id = message.audio.file_id
bot.send_audio(channel_name, audio=doc_id, caption=message.text, parse_mode='HTML')
print(f'\nСообщение успешно доставлено.\nText: {message.text}\nFile_Id: {doc_id}')
if __name__ == '__main__':
bot.infinity_polling()
# При этом message.text должен быть составлен так "Это обычный шрифт <b> а тут уже жирный шрифт </b> тут снова обычный <u> а тут подчеркнутый текст </u>"
def deffers():
cursor.execute('SELECT obshee_1 FROM tablica')
knopach1 = cursor.fetchone()
cursor.execute('SELECT obshee_2 FROM tablica')
knopach2 = cursor.fetchone()
klava = types.InlineKeyboardMarkup()
button1=types.InlineKeyboardButton(text='Всего: '+knopach1[0], callback_data='knopka1')
button2=types.InlineKeyboardButton(text='Всего: '+knopach2[0], callback_data='knopka2')
bot.send_message(message.text, 'Ваше абсолютно любое сообщение. Абсолютно любое.', reply_markup=klava)
@bot.message_handler(content_types=['photo'])
def handle_docs_photo(message):
try:
chat_id = message.chat.id
file_info_1 = bot.get_file(message.photo[-1].file_id)
bot.send_message(message.chat.id, file_info_1)
downloaded_file = bot.download_file(file_info_1.file_path)
src = dir + '\\' + file_info_1.file_path.split('/')[-1]
bot.send_message(message.chat.id, src)
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
except Exception as e:
bot.reply_to(message, e)
await bot.send_message(callback_query.from_user.id, 'Введите номер: ')
await bot.register_next_step_handler(message, <НАЗВАНИЕ def>)