Giter Club home page Giter Club logo

telbot's Introduction

telbot

Active Development

Telbot provides telegram bot types and API wrappers.

Specifically, telbot now supports:

  • telbot-types: basic telegram types / requests / responses
[dependencies]
telbot-types = "0.3.0"
  • telbot-cf-worker: API wrapper for cloudflare workers
[dependencies]
telbot-cf-worker = "0.3.0"
  • telbot-ureq: API wrapper for ureq client
[dependencies]
telbot-ureq = "0.3.1"
  • telbot-hyper: API wrapper for hyper client
[dependencies]
telbot-hyper = "0.3.0"

Examples

Extending telbot

You can implement two methods, send_json and send_file with your own http client to create your own API wrapper.

send_json should serialize JsonMethod into json format and send it to the API endpoint.

send_file should serialize FileMethod into multipart/form-data format and send it to the API endpoint.

files(&self) method in FileMethod helps getting fields of type InputFileVariant.

For the ease of serializing, both JsonMethod and FileMethod implements serde::Serialize.

TelegramMethod, the super trait of both JsonMethod and FileMethod, provides name() method, which can be used to get the method's name in &str format.

Contributing

telbot is not a mature project yet, so your help will be very helpful.

Please leave an issue if you find wrongly coded piece or get a nice idea to improve telbot.

telbot's People

Contributors

kiwiyou avatar ofen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

telbot's Issues

Capiton are json encoded even when not send as json

Hello,

When I try to send a file with a caption it is surrounded by " and if it contain the character " it is send as \".

Here a minimal example:

use telbot_ureq::types::message::SendDocument;
use telbot_ureq::types::chat::ChatId;
use telbot_ureq::types::file::InputFile;
use telbot_ureq::Api;

fn main() {
	let data: Vec<u8> = "exemple".to_string().into_bytes();
	let caption = "exemple \" exemple";

	let api = Api::new("...".to_string());
	let chat_id: ChatId = 123456789i64.into();

	let file = InputFile {
		name: "test.txt".to_string(),
		data: data,
		mime: "text/plain".to_string(),
	};

	api
		.send_file(
			&SendDocument::new(chat_id, file)
				.with_caption(caption)
		)
		.expect("Error while sending document to Telegram");
}

And here what I get in Telegram:

image

From what I can see the problem is that the send_file method use serde_json::to_value but the body is not send as json (but as multipart) so the text is json escaped but Telegram do not decode it.

PS: I'm using the main version from git telbot-ureq = { git = "https://github.com/kiwiyou/telbot" }

Publish version 0.3.0

Hello,

I don't see version 0.3.0 on crates.io, can you publish it ?

Thank you ๐Ÿ˜ƒ

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.