Coder Social home page Coder Social logo

rtelegram's Introduction

RTelegram

The project is still in an early phase, but some basic functionality is already working.

This is essentially a wrapper for the telegram bot API.

The idea is to use the telegram bot API to send

  • Simulation status and results
  • Crash logs
  • images

directly from R to your smartphone.

Installation

You can install the package directly from github with the devtools package:

library(devtools)
install_github("ja-thomas/RTelegram")

Or you can just clone this repository and load it in R via:

library(devtools)
load_all("[path]/RTelegram")

Basic usage

To create a bot you first have to use the botfather. For an in depth introduction on how to create a bot visit the telegram bot FAQ.

After creating a bot you recieve a token.

You can check if your bot works with the validate_bot() function

For security reasons bots are only allowed to send messages to real accounts after they recieved a message from that person. After sending your bot a message from your telegram app, you can call recieve_chat_id() to get your chat_id.

Only with the correct token and chat_id you are able to send messages from R to your smartphone.

Now you can send messages with send_message() and images with send_image().

rtelegram's People

Contributors

ja-thomas avatar

Watchers

 avatar  avatar  avatar  avatar

rtelegram's Issues

send_image

I'm try to use send_image function but the telegram received blank image.

what's wrong?

send_image <- function(image_call, chat_id, token, file = "image"){

if(!(inherits(chat_id, "chat_id") | is.character(chat_id))){
stop("chat_id must be a chat_id object or a character string")
}

if(!(inherits(token, "chat_bot") | is.character(token))){
stop("token must be a chat_bot object or a character string")
}

if(inherits(chat_id, "chat_id")){
chat_id <- chat_id$chat_id
}

if(inherits(token, "chat_bot")){
token <- token$token
}

filename = paste0("./", "file", ".jpg")

png(filename = filename)
image_call
dev.off()
httr::POST(url = paste0("https://api.telegram.org/bot", token, "/sendPhoto"),
body = list(chat_id = chat_id,
photo = httr::upload_file(filename)))
}

send_image("FT.jpg", chat_id, token, file = "image")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.