verygram


Nameverygram JSON
Version 0.2.5 PyPI version JSON
download
home_pagehttps://github.com/SiriRSST/Verygram
SummaryLightweight library for working with Telegram Bot Api version 7.10
upload_time2024-10-26 18:38:39
maintainerNone
docs_urlNone
authorSiri-Team
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Verygram

**Verygram** - это легкая библиотека для работы с Telegram Bot API версии 7.10. Она предоставляет простой и понятный интерфейс для отправки различных типов сообщений и обработки обновлений.

__Библиотека похожа на telebot, но она более простая и подходит для разработки достаточно сложных проектов__

## Установка
```bash
pip install verygram
```

## Общий пример использования:
```python
from verygram import Bot, Markup
import time

bot = Bot('You_Bot_Token')

@bot.message_handler(content_types=['new_chat_member'])
def hello_mention(message):
    new_member = message.new_chat_member.first_name
    new_id = message.new_chat_member.id
    chat_id = message.chat.id
    print(new_member)
    if new_id == bot.get_me().id:
        bot.reply_message(text=f"Привет, меня зовут бот", mode="Markdown")
    else:
        bot.reply_message(chat_id, text=f"Привет [{str(new_member).replace('[', '').replace(']', '')}](tg://user?id={new_id})!", mode="Markdown")


@bot.message_handler(content_types=['left_chat_member'])
def godbye_mention(message):
    tot_name = message.left_chat_member.first_name
    tot_id = message.left_chat_member.id
    chat_id = message.chat.id
    bot.reply_message(chat_id, f"[{str(tot_name).replace('[', '').replace(']', '')}](tg://user?id={tot_id}) покинул(а) беседу", mode="Markdown")


@bot.message_handler(commands=['start'])
def start(message):
    buttons = [{'text': 'Кнопка 1', 'callback_data': '1'}, {'text': 'Кнопка 2', 'callback_data': '2'}, {'text': 'Кнопка 3', 'callback_data': '3'}]
    reply_markup = Markup.create_inline_keyboard(buttons, row_width=2)
    p = bot.reply_message(message.chat.id, f"Выберите кнопку {message.from_user.first_name}:", reply_markup=reply_markup)
    bot.edit_message_text(p.chat.id, message_id=p.message_id, text="Окей, шучу")
    bot.edit_message_reply_markup(p.chat.id, message_id=p.message_id, reply_markup=reply_markup)


@bot.message_handler(commands=['help'])
def help(message):
    buttonss = [{'text': 'Кнопка 1'}, {'text': 'Кнопка 2'}, {'text': 'Кнопка 3'}]
    reply_markup = Markup.create_reply_keyboard(buttonss, row_width=1)
    bot.reply_message(message.chat.id, "Кнопки:", reply_markup=reply_markup)


@bot.callback_query_handler(func=lambda call: True)
def handle_button_1(call):
    if call.data == '1':
        bot.answer_callback_query(call.id, text="Вы нажали кнопку 1!")
    elif call.data == '2':
        bot.answer_callback_query(call.id, text="Вы нажали кнопку 2!")
    elif call.data == '3':
        bot.answer_callback_query(call.id, text="Вы нажали кнопку 3!")

@bot.message_handler(content_types=['text'])
def ms_obrabotka(ms):
    chat_id = ms.chat.id
    message_id = ms.message_id
    if ms.text == 'Кнопка 1':
        bot.reply_message(chat_id, 'Вы нажали кнопку 1!', reply_to_message_id=message_id)
    if ms.text == 'Кнопка 2':
        bot.reply_message(chat_id, 'Вы нажали кнопку 2!', reply_to_message_id=message_id)
    if ms.text == 'Кнопка 3':
        bot.reply_message(chat_id, 'Вы нажали кнопку 3!', reply_to_message_id=message_id)
    if ms.text == 'Привет':
        bot.reply_message(chat_id, 'Привет, я бот!', reply_to_message_id=message_id)


@bot.message_handler(content_types=['photo'])
def handle_photo_message(message):
    chat_id = message.chat.id
    photo_id = message.photo[-1].file_id
    p = bot.get_file(photo_id)
    bot.download_file(p, p.file_path)
    bot.reply_photo(chat_id, photo=photo_id, reply_to_message_id=message.message_id, caption=f"`{photo_id}`", mode="Markdown")
    bot.delete_chat_photo(chat_id)


@bot.message_handler(content_types=['voice'])
def handle_voice_message(message):
    chat_id = message.chat.id
    voice = message.voice.file_id
    bot.reply_voice(chat_id, voice=voice, reply_to_message_id=message.message_id, caption=f"`{voice}`", mode="Markdown")


@bot.message_handler(content_types=['document'])
def handle_document_message(message):
    chat_id = message.chat.id
    document = message.document.file_id
    p = bot.get_file(document)
    bot.download_file(p, './document.txt')
    bot.reply_document(chat_id, document=open('./document.txt', 'rb'), reply_to_message_id=message.message_id, caption=f"`{document}`", mode="Markdown")

@bot.message_handler(content_types=['video'])
def handle_video_message(message):
    chat_id = message.chat.id
    video = message.video.file_id
    p = bot.get_file(video)
    bot.download_file(p, './video.mp4')
    bot.reply_video(chat_id, video=open('./video.mp4', 'rb'), reply_to_message_id=message.message_id, caption=f"`{video}`", mode="Markdown")


@bot.message_handler(content_types=['audio'])
def handle_audio_message(message):
    chat_id = message.chat.id
    audio = message.audio.file_id
    p = bot.get_file(audio)
    bot.download_file(p, './audio.mp3')
    bot.reply_audio(chat_id, audio=open('./audio.mp3', 'rb'), reply_to_message_id=message.message_id, caption=f"`{audio}`", mode="Markdown")


@bot.message_handler(content_types=['video_note'])
def handle_video_note_message(message):
    chat_id = message.chat.id
    video_note = message.video_note.file_id
    p = bot.get_file(video_note)
    bot.download_file(p, './video_note.mp4')
    bot.reply_video_note(chat_id, video_note=open('./video_note.mp4', 'rb'), reply_to_message_id=message.message_id, caption=f"`{video_note}`", mode="Markdown")


@bot.message_handler(content_types=['sticker'])
def handle_sticker_message(message):
    chat_id = message.chat.id
    sticker = message.sticker.file_id
    p = bot.get_file(sticker)
    bot.download_file(p, './sticker.webp')
    bot.reply_sticker(chat_id, sticker=open('./sticker.webp', 'rb'), reply_to_message_id=message.message_id)


@bot.message_handler(content_types=['animation'])
def handle_animation_message(message):
    chat_id = message.chat.id
    animation = message.animation.file_id
    p = bot.get_file(animation)
    bot.download_file(p, './animation.mp4')
    bot.reply_animation(chat_id, animation=open('./animation.mp4', 'rb'), reply_to_message_id=message.message_id)    


bot.polling()
```

## Лицензия
Verygram распространяется под лицензией MIT.

## Контакты
Если у вас есть вопросы или предложения, пожалуйста, напишите нам: siriteamrs@gmail.com

## Обратная связь
**Если у вас есть еще вопросы, пожалуйста, дайте мне знать!**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SiriRSST/Verygram",
    "name": "verygram",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Siri-Team",
    "author_email": "siriteamrs@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c7/eb/396392f31a1391b600dd559ea73580c768d4b0864b19d8750bcb6bf42173/verygram-0.2.5.tar.gz",
    "platform": null,
    "description": "# Verygram\r\n\r\n**Verygram** - \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Telegram Bot API \u0432\u0435\u0440\u0441\u0438\u0438 7.10. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.\r\n\r\n__\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 telebot, \u043d\u043e \u043e\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432__\r\n\r\n## \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\r\n```bash\r\npip install verygram\r\n```\r\n\r\n## \u041e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:\r\n```python\r\nfrom verygram import Bot, Markup\r\nimport time\r\n\r\nbot = Bot('You_Bot_Token')\r\n\r\n@bot.message_handler(content_types=['new_chat_member'])\r\ndef hello_mention(message):\r\n    new_member = message.new_chat_member.first_name\r\n    new_id = message.new_chat_member.id\r\n    chat_id = message.chat.id\r\n    print(new_member)\r\n    if new_id == bot.get_me().id:\r\n        bot.reply_message(text=f\"\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0431\u043e\u0442\", mode=\"Markdown\")\r\n    else:\r\n        bot.reply_message(chat_id, text=f\"\u041f\u0440\u0438\u0432\u0435\u0442 [{str(new_member).replace('[', '').replace(']', '')}](tg://user?id={new_id})!\", mode=\"Markdown\")\r\n\r\n\r\n@bot.message_handler(content_types=['left_chat_member'])\r\ndef godbye_mention(message):\r\n    tot_name = message.left_chat_member.first_name\r\n    tot_id = message.left_chat_member.id\r\n    chat_id = message.chat.id\r\n    bot.reply_message(chat_id, f\"[{str(tot_name).replace('[', '').replace(']', '')}](tg://user?id={tot_id}) \u043f\u043e\u043a\u0438\u043d\u0443\u043b(\u0430) \u0431\u0435\u0441\u0435\u0434\u0443\", mode=\"Markdown\")\r\n\r\n\r\n@bot.message_handler(commands=['start'])\r\ndef start(message):\r\n    buttons = [{'text': '\u041a\u043d\u043e\u043f\u043a\u0430 1', 'callback_data': '1'}, {'text': '\u041a\u043d\u043e\u043f\u043a\u0430 2', 'callback_data': '2'}, {'text': '\u041a\u043d\u043e\u043f\u043a\u0430 3', 'callback_data': '3'}]\r\n    reply_markup = Markup.create_inline_keyboard(buttons, row_width=2)\r\n    p = bot.reply_message(message.chat.id, f\"\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 {message.from_user.first_name}:\", reply_markup=reply_markup)\r\n    bot.edit_message_text(p.chat.id, message_id=p.message_id, text=\"\u041e\u043a\u0435\u0439, \u0448\u0443\u0447\u0443\")\r\n    bot.edit_message_reply_markup(p.chat.id, message_id=p.message_id, reply_markup=reply_markup)\r\n\r\n\r\n@bot.message_handler(commands=['help'])\r\ndef help(message):\r\n    buttonss = [{'text': '\u041a\u043d\u043e\u043f\u043a\u0430 1'}, {'text': '\u041a\u043d\u043e\u043f\u043a\u0430 2'}, {'text': '\u041a\u043d\u043e\u043f\u043a\u0430 3'}]\r\n    reply_markup = Markup.create_reply_keyboard(buttonss, row_width=1)\r\n    bot.reply_message(message.chat.id, \"\u041a\u043d\u043e\u043f\u043a\u0438:\", reply_markup=reply_markup)\r\n\r\n\r\n@bot.callback_query_handler(func=lambda call: True)\r\ndef handle_button_1(call):\r\n    if call.data == '1':\r\n        bot.answer_callback_query(call.id, text=\"\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 1!\")\r\n    elif call.data == '2':\r\n        bot.answer_callback_query(call.id, text=\"\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 2!\")\r\n    elif call.data == '3':\r\n        bot.answer_callback_query(call.id, text=\"\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 3!\")\r\n\r\n@bot.message_handler(content_types=['text'])\r\ndef ms_obrabotka(ms):\r\n    chat_id = ms.chat.id\r\n    message_id = ms.message_id\r\n    if ms.text == '\u041a\u043d\u043e\u043f\u043a\u0430 1':\r\n        bot.reply_message(chat_id, '\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 1!', reply_to_message_id=message_id)\r\n    if ms.text == '\u041a\u043d\u043e\u043f\u043a\u0430 2':\r\n        bot.reply_message(chat_id, '\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 2!', reply_to_message_id=message_id)\r\n    if ms.text == '\u041a\u043d\u043e\u043f\u043a\u0430 3':\r\n        bot.reply_message(chat_id, '\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 3!', reply_to_message_id=message_id)\r\n    if ms.text == '\u041f\u0440\u0438\u0432\u0435\u0442':\r\n        bot.reply_message(chat_id, '\u041f\u0440\u0438\u0432\u0435\u0442, \u044f \u0431\u043e\u0442!', reply_to_message_id=message_id)\r\n\r\n\r\n@bot.message_handler(content_types=['photo'])\r\ndef handle_photo_message(message):\r\n    chat_id = message.chat.id\r\n    photo_id = message.photo[-1].file_id\r\n    p = bot.get_file(photo_id)\r\n    bot.download_file(p, p.file_path)\r\n    bot.reply_photo(chat_id, photo=photo_id, reply_to_message_id=message.message_id, caption=f\"`{photo_id}`\", mode=\"Markdown\")\r\n    bot.delete_chat_photo(chat_id)\r\n\r\n\r\n@bot.message_handler(content_types=['voice'])\r\ndef handle_voice_message(message):\r\n    chat_id = message.chat.id\r\n    voice = message.voice.file_id\r\n    bot.reply_voice(chat_id, voice=voice, reply_to_message_id=message.message_id, caption=f\"`{voice}`\", mode=\"Markdown\")\r\n\r\n\r\n@bot.message_handler(content_types=['document'])\r\ndef handle_document_message(message):\r\n    chat_id = message.chat.id\r\n    document = message.document.file_id\r\n    p = bot.get_file(document)\r\n    bot.download_file(p, './document.txt')\r\n    bot.reply_document(chat_id, document=open('./document.txt', 'rb'), reply_to_message_id=message.message_id, caption=f\"`{document}`\", mode=\"Markdown\")\r\n\r\n@bot.message_handler(content_types=['video'])\r\ndef handle_video_message(message):\r\n    chat_id = message.chat.id\r\n    video = message.video.file_id\r\n    p = bot.get_file(video)\r\n    bot.download_file(p, './video.mp4')\r\n    bot.reply_video(chat_id, video=open('./video.mp4', 'rb'), reply_to_message_id=message.message_id, caption=f\"`{video}`\", mode=\"Markdown\")\r\n\r\n\r\n@bot.message_handler(content_types=['audio'])\r\ndef handle_audio_message(message):\r\n    chat_id = message.chat.id\r\n    audio = message.audio.file_id\r\n    p = bot.get_file(audio)\r\n    bot.download_file(p, './audio.mp3')\r\n    bot.reply_audio(chat_id, audio=open('./audio.mp3', 'rb'), reply_to_message_id=message.message_id, caption=f\"`{audio}`\", mode=\"Markdown\")\r\n\r\n\r\n@bot.message_handler(content_types=['video_note'])\r\ndef handle_video_note_message(message):\r\n    chat_id = message.chat.id\r\n    video_note = message.video_note.file_id\r\n    p = bot.get_file(video_note)\r\n    bot.download_file(p, './video_note.mp4')\r\n    bot.reply_video_note(chat_id, video_note=open('./video_note.mp4', 'rb'), reply_to_message_id=message.message_id, caption=f\"`{video_note}`\", mode=\"Markdown\")\r\n\r\n\r\n@bot.message_handler(content_types=['sticker'])\r\ndef handle_sticker_message(message):\r\n    chat_id = message.chat.id\r\n    sticker = message.sticker.file_id\r\n    p = bot.get_file(sticker)\r\n    bot.download_file(p, './sticker.webp')\r\n    bot.reply_sticker(chat_id, sticker=open('./sticker.webp', 'rb'), reply_to_message_id=message.message_id)\r\n\r\n\r\n@bot.message_handler(content_types=['animation'])\r\ndef handle_animation_message(message):\r\n    chat_id = message.chat.id\r\n    animation = message.animation.file_id\r\n    p = bot.get_file(animation)\r\n    bot.download_file(p, './animation.mp4')\r\n    bot.reply_animation(chat_id, animation=open('./animation.mp4', 'rb'), reply_to_message_id=message.message_id)    \r\n\r\n\r\nbot.polling()\r\n```\r\n\r\n## \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u044f\r\nVerygram \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 MIT.\r\n\r\n## \u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b\r\n\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430\u043c: siriteamrs@gmail.com\r\n\r\n## \u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0432\u044f\u0437\u044c\r\n**\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0434\u0430\u0439\u0442\u0435 \u043c\u043d\u0435 \u0437\u043d\u0430\u0442\u044c!**\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Lightweight library for working with Telegram Bot Api version 7.10",
    "version": "0.2.5",
    "project_urls": {
        "Homepage": "https://github.com/SiriRSST/Verygram"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eddb4bf26e2f0d39b5e50e03372a83d64fed83e588dd3265a37229bb3c19c0c4",
                "md5": "27df5d4534bc79d5e05183d541faa5ca",
                "sha256": "7fa0cb309e157184a56fd29b0657bc3e0c88156281968b45490a6305fa161a69"
            },
            "downloads": -1,
            "filename": "verygram-0.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "27df5d4534bc79d5e05183d541faa5ca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 18532,
            "upload_time": "2024-10-26T18:38:36",
            "upload_time_iso_8601": "2024-10-26T18:38:36.628555Z",
            "url": "https://files.pythonhosted.org/packages/ed/db/4bf26e2f0d39b5e50e03372a83d64fed83e588dd3265a37229bb3c19c0c4/verygram-0.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c7eb396392f31a1391b600dd559ea73580c768d4b0864b19d8750bcb6bf42173",
                "md5": "95181ac08ccf4059081143b109291779",
                "sha256": "261832f8c6969590ecfc686ae459eaebeb52c9fa1446763ceba9ccdb89848eea"
            },
            "downloads": -1,
            "filename": "verygram-0.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "95181ac08ccf4059081143b109291779",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 20802,
            "upload_time": "2024-10-26T18:38:39",
            "upload_time_iso_8601": "2024-10-26T18:38:39.139997Z",
            "url": "https://files.pythonhosted.org/packages/c7/eb/396392f31a1391b600dd559ea73580c768d4b0864b19d8750bcb6bf42173/verygram-0.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 18:38:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SiriRSST",
    "github_project": "Verygram",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.25.1"
                ]
            ]
        }
    ],
    "lcname": "verygram"
}
        
Elapsed time: 1.89174s