Телеграм бот калькулятор python

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Телеграм бота, который высчитывает математическое выражение, в том чисел с одной парой скобок

PromathBul/Bot_calculator

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Данная программа представляет собой Телеграм бота, который высчитывает математическое выражение.

  • арифметические действия
    • сложение
    • вычитание
    • умножение
    • деление
    • id пользователя
    • имя пользователя
    • фамилия пользователя
    • арифметическое выражение, введенное пользователем
    • и результат арифметического выражения

    NB! Выражение вводите без пробелов. Запуск бота производится командой /start .

    About

    Телеграм бота, который высчитывает математическое выражение, в том чисел с одной парой скобок

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    Простой Telegram-бот на языке Python на библиотеке telebot

    mikhail-shamshurin/Calculator-bot

    This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

    Name already in use

    A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

    Sign In Required

    Please sign in to use Codespaces.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching Xcode

    If nothing happens, download Xcode and try again.

    Launching Visual Studio Code

    Your codespace will open once ready.

    There was a problem preparing your codespace, please try again.

    Latest commit

    Git stats

    Files

    Failed to load latest commit information.

    README.md

    Простой Telegram-бот на языке Python, использующий библиотеку telebot.

    Весь код лежит в файле Bot-calculator.py . Чтобы бот начал работать заполните опцию с токеном для бота и картинки (по желанию). Документация для Telebot — по ней можно прекрасно понять как создать бота для Telegram. Если же вы не дружите с английским, то пользуйтесь переводчиком 🙂

    About

    Простой Telegram-бот на языке Python на библиотеке telebot

    Источник

    Калькулятор Wolframalpha в диалоге Telegram

    В диалогах телеграма я очень часто использую телеграм бот: inlatexbot. Он позволяет вставлять Latex прямо в диалоге телеграма — это удобно: математическое обозначение можно отправить понятной картинкой, чтобы было так

    , а не так sqrt(4)*2^x * 1/3 =1024.
    Но не менее часто, мне в телеграме необходим функционал WolframAlpha: посчитать сложный счет за вечеринку с друзьями, различные проценты, решить уравнение и так далее — полный функционал WolframAlpha, но при этом не выходить из диалога телеграма.

    Подключение Wolfram

    Я нашел Wolfram Alpha API для python (https://pypi.org/project/wolframalpha/). Документация предельно понятная и можно сделать все, что доступно в веб версии. Правда, есть ограничение бесплатного Wolfram API на 2000 запросов в месяц. Код, который работает с вольфрамом предельно простой и у меня вышел в 4 строки.

    import wolframalpha client = wolframalpha.Client('TOKEN') res = client.query(query) print(next(res.results).text)

    В первых двух строчках я импортирую модуль wolframalpha, создаю client со своим APP ID — необходимо предварительно зарегистрироваться в wolfram и получить его, далее можно отправлять запросы к вольфраму и просто делаю принт результат того, что получил Wolfram Alpha. Все работает — теперь можно приступать к интегрированию с Telegram.

    Интеграция в Телеграм бот

    Осталось соединить все вместе и отправлять запросы, полученные из Телеграм в Вольфрам и выдавать ответ юзеру. Создаю бот в @BotFather, в настройках включаю режим inline, чтобы бот работал прямо в диалоге Телеграм. Использую пример inline бота из GitHub для Телеграм, и отправляю ответ юзеру. Вот как выглядит самая важная часть кода.

    def inlinequery(update, context): """Handle the inline query.""" query = update.inline_query.query print(query) res = client.query(query) results = [ InlineQueryResultArticle( title="Magic answer is here!", input_message_content=InputTextMessageContent( "<> => *<>*".format(query, next(res.results).text), parse_mode=ParseMode.MARKDOWN))] update.inline_query.answer(results)

    Как это работает?

    Очень просто — прямо в диалоге я ввожу @calcherebot 12 + 15 и мне выдает ответ 27. Бот в телеграме упрощает не только процесс подсчетов чего-либо, но и процесс различных доказательств, например можно узнать население Москвы или средний вес человека и бот в каком-то смысле меняет коммуникацию: больше не нужны скриншоты калькуляторов, википедии или других источников — теперь все может быть доступно в диалоге.

    Что дальше?

    Пока что бот работает локально и поддерживает всего лишь 2000 запросов в месяц, что очень мало для публичного использования. В моих планах его доработка для массового использования всем, кому это необходимо: студентам, ученым, просто людям которым нужно что-то посчитать или доказать прямо в телеграме. Если у вас есть идеи или пожелания по доработке( скорее всего они есть, так как бот был написан за пару часов) напишите мне на почту: rk-helper@yandex.ru

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    aiogram 3.0.0b7 calculator bot

    Lexxx42/calculator_bot_aiogram

    This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

    Name already in use

    A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

    Sign In Required

    Please sign in to use Codespaces.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching Xcode

    If nothing happens, download Xcode and try again.

    Launching Visual Studio Code

    Your codespace will open once ready.

    There was a problem preparing your codespace, please try again.

    Latest commit

    Git stats

    Files

    Failed to load latest commit information.

    README.md

    1. Создать бота у бота отца https://t.me/BotFather
    2. Используя команду /newbot или через меню бота-отца
    3. установить зависимости из файла requirements.txt командой: pip install -r requirements.txt
    4. создать в корне проекта файл .env
    5. вставить в .env строку: BOT_TOKEN=ВАШ_ТОКЕН_ТЕЛЕГРАМА, где ВАШ_ТОКЕН_ТЕЛЕГРАМА — токен бота, который получен от бота-отца.
    BOT_TOKEN=ВАШ_ТОКЕН_ТЕЛЕГРАМА

    If there is an error about lack of access, add current user to the docker group:

    sudo usermod -a -G docker [user] newgrp docker

    Use this sequence of commands to run the container:

    sudo apt install docker-compose
    git clone https://github.com/Lexxx42/calculator_bot_aiogram.git
    cd calculator_bot_aiogram/

    Don’t forget to save changes!

    Added docker image to public repository

    If you are using docker image from DockerHub use following commands:

    docker pull alex42konukhov/calculator-bot-aiogram:ubuntu 
    docker run alex42konukhov/calculator-bot-aiogram:ubuntu 
    docker cp .env docker_container_id:/calc-bot/.env 
    docker start container_id 

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    it is a simple calculator telegramBot with python .

    sedhossein/simple-python-calculator

    This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

    Name already in use

    A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

    Sign In Required

    Please sign in to use Codespaces.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching GitHub Desktop

    If nothing happens, download GitHub Desktop and try again.

    Launching Xcode

    If nothing happens, download Xcode and try again.

    Launching Visual Studio Code

    Your codespace will open once ready.

    There was a problem preparing your codespace, please try again.

    Latest commit

    Git stats

    Files

    Failed to load latest commit information.

    README.md

    Simple Telegram Calculator Bot

    It’s just a simple calculator bot on telegram with python.

    Also helpful for start robot programming with python in Messenger (Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed. )

    About

    it is a simple calculator telegramBot with python .

    Источник

    Читайте также:  Вывести количество чисел python
Оцените статью