telegram

package module
v0.0.0-...-39699f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 14 Imported by: 0

README

Telegram Backend for RClone

This is a backend for RClone that allows you to use Telegram as a remote storage service.

Installation

To use this backend, you need to have RClone installed. You can download the latest version of RClone from their official website.

To use this backend, you also need to have a Telegram bot and chat ID. You can create a bot and obtain the chat ID by following the instructions in Telegram's Bot API documentation.

Once you have RClone and a Telegram bot set up, you can install this backend by running the following command:

go install github.com/greengeckowizard/RcloneTelegram@latest

Configuration

To use this backend, you need to add it to your RClone configuration file. You can do this by running the following command:

rclone config

Then, follow the prompts to configure the backend. You will need to provide your Telegram bot token and chat ID.

Here's an example configuration:

[mytelegram]
type = telegram
token = <your-telegram-bot-token>
chat_id = <your-telegram-chat-id>

You can replace "mytelegram" with any name you like.

How to Test

Since this code is still in development, it is recommended that you test it thoroughly before using it for production purposes.

To test the backend, you can try running the following RClone commands:

rclone lsf mytelegram:/

This should list the contents of your Telegram chat.

rclone copy /path/to/local/file mytelegram:/remote/path

This should upload the local file to your Telegram chat.

rclone copy mytelegram:/remote/path /path/to/local/file

This should download the remote file from your Telegram chat to the local file system.

Note that the Telegram backend only supports files up to 2GB in size.

Community

Discord Server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFs

func NewFs(name string, m configmap.Mapper) (fs.Fs, error)

NewFs constructs a new Fs

Types

type Fs

type Fs struct {
	// contains filtered or unexported fields
}

Fs represents a remote Telegram chat

func (*Fs) Features

func (f *Fs) Features() *vfs.Features

Features returns the optional features of this Fs

func (*Fs) Hashes

func (f *Fs) Hashes() hash.Set

Hashes returns the supported hash sets

func (*Fs) List

func (f *Fs) List(ctx context.Context, dir string) (fs.DirChan, fs.EntryChan, error)

List returns a channel to the objects and subdirectories in dir with directory entries popped from the channel

func (*Fs) Mkdir

func (f *Fs) Mkdir(ctx context.Context, dir string) error

Mkdir creates the directory if it doesn't exist

func (*Fs) Name

func (f *Fs) Name() string

Name of the remote (as passed into NewFs)

func (*Fs) NewObject

func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)

NewObject finds the Object at remote

func (*Fs) Precision

func (f *Fs) Precision() time.Duration

Precision of the ModTimes in this Fs

func (*Fs) Put

func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

Put uploads contents to the remote path

func (*Fs) PutStream

func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

PutStream uploads contents to the remote path using a stream

func (*Fs) Rmdir

func (f *Fs) Rmdir(ctx context.Context, dir string) error

Rmdir removes the directory

func (*Fs) Root

func (f *Fs) Root() string

Root of the remote (as passed into NewFs)

func (*Fs) String

func (f *Fs) String() string

String returns a description of the FS

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object represents a remote Telegram file

func (*Object) Fs

func (o *Object) Fs() fs.Info

Fs returns the parent Fs

func (*Object) Hash

func (o *Object) Hash(r hash.Type) (string, error)

Hash returns the selected checksum of the file If no checksum is available it returns ""

func (*Object) ModTime

func (o *Object) ModTime(ctx context.Context) time.Time

ModTime returns the modification time of the file

func (*Object) Open

func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)

Open opens the file for read

func (*Object) Remote

func (o *Object) Remote() string

Remote returns the remote path

func (*Object) Remove

func (o *Object) Remove(ctx context.Context) error

Remove deletes the remote object

func (*Object) SetModTime

func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error

SetModTime sets the modification time of the file

func (*Object) Size

func (o *Object) Size() int64

Size returns the size of the file

func (*Object) Storable

func (o *Object) Storable() bool

Storable returns whether this object can be stored

func (*Object) String

func (o *Object) String() string

String returns a description of the Object

func (*Object) Update

func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error

Update updates the object from in with modTime

type Options

type Options struct {
	Token  string `config:"token"`
	ChatID string `config:"chat_id"`
}

Options defines the configuration for this backend

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL