Giter Site home page Giter Site logo

setiawanhu / laravel-madeline-proto Goto Github PK

View Code? Open in Web Editor NEW
48.0 2.0 50.0 81 KB

A third party Telegram client library danog/MadelineProto wrapper for Laravel

License: GNU Affero General Public License v3.0

PHP 100.00%
telegram laravel madeline-proto

laravel-madeline-proto's Introduction

Laravel MadelineProto

Latest Stable Version Total Downloads License

A third party Telegram client library danog/MadelineProto wrapper for Laravel.

Getting Started

Add the laravel-madeline-proto to the project dependency:

composer require setiawanhu/laravel-madeline-proto

Then publish the telegram.php config file:

php artisan vendor:publish --provider="Hu\MadelineProto\MadelineProtoServiceProvider"

Set up the Telegram API key by providing env variables:

MP_TELEGRAM_API_ID=... //your telegram api id here
MP_TELEGRAM_API_HASH=... //your telegram api hash here

This wrapper package supports for running both single / multiple telegram account.

Dig Deeper

Please check wiki for more details about laravel-madeline-proto usage

Notes

  • This wrapper package is still not wrapping all the apis yet, I'm still focusing on wrapping the messages api.

  • If you can't find the method that you want in Messages facade or need to use the default danog/MadelineProto api, you might want to use MadelineProto::getClient() facade method. It will return danog\MadelineProto\API object where you can call all the method provided by the danog/MadelineProto library.

Thanks To

Bryan Ramaputra for helping me to write readable documentations.

laravel-madeline-proto's People

Contributors

danog avatar setiawanhu avatar

Stargazers

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

Watchers

 avatar  avatar

laravel-madeline-proto's Issues

Storing Sessions

Hi, how are sessions stored?
Can I run multiple telegram accounts?

Thanks

session of type string

hi

after login with multi account try used

$account = Account::first();

$telegramSession = $account->telegramSession;

$madelineProto = $this->factory->get($telegramSession);

dd($madelineProto);

image

image

please help me

Laravel installation error

I get the following error while running 'composer require setiawanhu/laravel-madeline-proto' in my laravel project v7.0. Is there something i am missing? Cannot find any relevant info in the web.

Using version ^1.0 for setiawanhu/laravel-madeline-proto
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for paragonie/random_compat (locked at v9.99.99) -> satisfiable by paragonie/random_compat[v9.99.99].
- setiawanhu/laravel-madeline-proto 1.0.0 requires danog/madelineproto ^5.1 -> satisfiable by danog/madelineproto[5.1.0, 5.1.1, 5.1.10, 5.1.11, 5.1.12, 5.1.13, 5.1.14, 5.1.15, 5.1.17, 5.1.18, 5.1.19, 5.1.2, 5.1.20, 5.1.21, 5.1.22, 5.1.23, 5.1.24, 5.1.25, 5.1.26, 5.1.27, 5.1.28, 5.1.29, 5.1.3, 5.1.30, 5.1.31, 5.1.32, 5.1.33, 5.1.34, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.8, 5.1.9].
- setiawanhu/laravel-madeline-proto 1.0.1 requires danog/madelineproto ^5.1 -> satisfiable by danog/madelineproto[5.1.0, 5.1.1, 5.1.10, 5.1.11, 5.1.12, 5.1.13, 5.1.14, 5.1.15, 5.1.17, 5.1.18, 5.1.19, 5.1.2, 5.1.20, 5.1.21, 5.1.22, 5.1.23, 5.1.24, 5.1.25, 5.1.26, 5.1.27, 5.1.28, 5.1.29, 5.1.3, 5.1.30, 5.1.31, 5.1.32, 5.1.33, 5.1.34, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.8, 5.1.9].
- setiawanhu/laravel-madeline-proto 1.0.2 requires danog/madelineproto ^5.1 -> satisfiable by danog/madelineproto[5.1.0, 5.1.1, 5.1.10, 5.1.11, 5.1.12, 5.1.13, 5.1.14, 5.1.15, 5.1.17, 5.1.18, 5.1.19, 5.1.2, 5.1.20, 5.1.21, 5.1.22, 5.1.23, 5.1.24, 5.1.25, 5.1.26, 5.1.27, 5.1.28, 5.1.29, 5.1.3, 5.1.30, 5.1.31, 5.1.32, 5.1.33, 5.1.34, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.8, 5.1.9].
- danog/madelineproto 5.1.0 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.1 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.10 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.11 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.12 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.13 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.14 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.15 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.17 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.18 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.19 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.2 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.20 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.21 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.22 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.23 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.24 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.25 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.26 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.27 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.28 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.29 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.3 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.30 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.31 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.32 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.33 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.34 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.4 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.5 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.6 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.7 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.8 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- danog/madelineproto 5.1.9 requires danog/tgseclib ^3 -> satisfiable by danog/tgseclib[3].
- Conclusion: don't install setiawanhu/laravel-madeline-proto 1.0.3|install danog/tgseclib 3
- Conclusion: don't install danog/tgseclib 3
- Installation request for setiawanhu/laravel-madeline-proto ^1.0 -> satisfiable by setiawanhu/laravel-madeline-proto[1.0.0, 1.0.1, 1.0.2, 1.0.3].

TelegramObject Constructor Not Accepting Array or Empty Argument

Hello,
Firstly, thank you for this package.
But I got an error and couldn't find a solution.

When I used array arguments;

$payload = new TelegramObject([
    'peer' = '@your_username',
    'message' = 'Your Message'
]);
Messages::sendMessage($payload);

I'm getting this error:

ErrorException
Array to string conversion

When I used Object arguments;

$payload = new TelegramObject();
$payload->peer = '@your_username';
$payload->message = 'Your Message';
Messages::sendMessage($payload);

I'm getting:

ArgumentCountError
Too few arguments to function Hu\MadelineProto\TelegramObject::__construct(), 0 passed in /Users/ilkerkocatepe/Desktop/PROJELER/telegram/routes/web.php on line 27 and exactly 1 expected

MadelineProto::getClient() is working correctly.
Thank you.
Best regards.

Edit: I'm using Laravel 8 and PHP 7.4

Cannot send message (ClientMessages constructor issue)

Great work however when I faced this issue

Argument 1 passed to Hu\MadelineProto\ClientMessages::__construct() must implement interface danog\MadelineProto\messages, instance of danog\MadelineProto\APIFactory given, called in \vendor\setiawanhu\laravel-madeline-proto\src\MadelineProto.php on line 150

My Controller
`<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Hu\MadelineProto\TelegramObject;
use Hu\MadelineProto\Facades\Messages;

class TestController extends Controller
{

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index(){

    $payload = new TelegramObject();
    $payload->peer = '@user-name';
    $payload->message = 'Your Message';
    Messages::sendMessage($payload);
}

}
`

Wrong Example in the documentation

Hi!
In the documentation, There is an example for new session when user is logging in:

public function newSession(Request $request) {
    //Insert the session into the telegram_sessions table

    $user = User::find($request->get('user_id'));
    
    $telegramSession = $user->telegramSession()->create([
        'session_file' => "{$user->name}.madeline"
    ]);
    
    //You can either use one of this following method

    $madelineProto = $this->factory->get($telegramSession);
    //or
    $madelineProto = Factory::get($telegramSession);

    $madelineProto->phoneLogin($request->get('phone_number'));

    return response()->json([
        'message' => 'Phone code sent!'
    ]);
}

At the beginning of the function, It gets user_id from the request.
If we know the user_id, Why do we need to authenticate the user?

Assuming that the laravel application uses telegram authentication api to authenticate its users.

Php 8 supports

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to composer install
  2. See error
  Problem 2
    - setiawanhu/laravel-madeline-proto 1.1.0 requires php ^7.4 -> your PHP version (8.0.0) does not satisfy that requirement.
    - setiawanhu/laravel-madeline-proto 1.1.0 requires php ^7.4 -> your PHP version (8.0.0) does not satisfy that requirement.
    - Installation request for setiawanhu/laravel-madeline-proto ^1.1 -> satisfiable by setiawanhu/laravel-madeline-proto[1.1.0].

Expected behavior
can install on php 8.0

get People NearBy

Hi. It is great job. But I can not use getLocated
$inputGeoPoint = ['_' => 'inputGeoPoint', 'lat' => 40.2514, 'long' => 49.5020, 'accuracy_radius' => 42]; $location = MadelineProto::getClient()->contacts->getLocated(['background'=> false, 'geo_point' => $inputGeoPoint, 'self_expires' => 0]); ddd($location);
It return this answer

array:7 [▼ "_" => "updates" "updates" => [] "users" => [] "chats" => [] "date" => 1610980851 "seq" => 0 "request" => array:12 [▼ "apifactory" => true "datacenter" => 2 "_" => "contacts.getLocated" "type" => "Updates" "contentRelated" => true "promise" => Amp\Deferred {#1642 ▶} "method" => true "unencrypted" => false "body" => array:3 [▶] "serialized_body" => b"D¼HÓ\x01\x00\x00\x00ɬ·óq\eà- D@ÇK7‰AÀH@\x00\x00\x00\x00" (ERROR: invalid input) "sent" => 1610980851 "tries" => 0 ] ]

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.