xooniverse / televerse

Your gateway to seamless Telegram Bot Development 💙
https://televerse.xooniverse.com
BSD 3-Clause "New" or "Revised" License
64 stars 11 forks source link

Encountering Unusual Error While Using Bot API's sendPhoto Method with Bot Token #151

Closed OttomanDeveloper closed 1 year ago

OttomanDeveloper commented 1 year ago

It was working perfectly fine before but today whenever I try to send the photo. I'm getting this issue. File Path: package:televerse/src/utils/http.dart

response = await _httpClient.multipartPost( _buildUri("sendPhoto"), files, params, );

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_Map<String, dynamic>' is not a subtype of type 'String'
[Offensive text hidden - some testing weirdos I forgot to remove - @HeySreelal]
I/flutter ( 6196): DioException [bad response]: The request returned an invalid status code of 403.
I/flutter ( 6196): #0      DioMixin.fetch.<anonymous closure>
dio_mixin.dart:507
I/flutter ( 6196): #1      _RootZone.runUnary (dart:async/zone.dart:1661:54)
I/flutter ( 6196): #2      _FutureListener.handleError (dart:async/future_impl.dart:165:22)
I/flutter ( 6196): #3      Future._propagateToListeners.handleError (dart:async/future_impl.dart:796:47)
I/flutter ( 6196): #4      Future._propagateToListeners (dart:async/future_impl.dart:817:13)

E/flutter ( 7210): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Uint8List' is not a subtype of type 'String'
E/flutter ( 7210): #0      HttpClient._dioCatch
http.dart:18
E/flutter ( 7210): #1      HttpClient.multipartPost
http.dart:103
E/flutter ( 7210): <asynchronous suspension>
E/flutter ( 7210): #2      RawAPI.sendPhoto
raw_api.dart:388
E/flutter ( 7210): <asynchronous suspension>
E/flutter ( 7210): #3      BotFunctions._sendPhotos
bot_fun_core.dart:94
HeySreelal commented 1 year ago

Oops sorry! Nothing, just forgot to remove some testing things. Was blown out yesterday.

I've retracted the version on pub.dev, will update the code later today.

If you're interested feel free to shoot a PR.

OttomanDeveloper commented 1 year ago

I haven't made any fork but older versions are making the same issue. Can you tell me how I can fix the issue?

HeySreelal commented 1 year ago

I'm extremely sorry for the inconveniences caused to you.

Can you check if v1.10.7 has this issue?

Reset assured, this will be fixed by tonight itself.

OttomanDeveloper commented 1 year ago

I think the issue is resolved.

HeySreelal commented 1 year ago

In v1.10.7? Good to hear :)

Let's keep this issue opened for a while. I'll check this later today.

HeySreelal commented 1 year ago

Hey, I just tried to make the error again. This is my code:

  bot.command('test', (ctx) async {
    await ctx.api.sendPhoto(
      ctx.id,
      InputFile.fromFile(
        File('example/assets/photo.jpeg'),
      ),
    );
  });

The code worked fine, and the photo message was sent. So, it's working even in the latest version? Otherwise, can you please share your code which threw the given exception?

HeySreelal commented 1 year ago

Hey @OttomanDeveloper - can you confirm if this bug exists in the dev branch? If it doesn't, I'd like to release a new version as soon as possible.

Kind regards :)

OttomanDeveloper commented 1 year ago

In v1.10.7? Good to hear :)

Let's keep this issue opened for a while. I'll check this later today.

Yes, there's no issue in v1.10.7.

OttomanDeveloper commented 1 year ago

Okay, I will check dev branch tomorrow and let you know.

HeySreelal commented 1 year ago

Thankss @OttomanDeveloper. I'll stand by.

OttomanDeveloper commented 1 year ago

Hey, I just tried to make the error again. This is my code:

  bot.command('test', (ctx) async {
    await ctx.api.sendPhoto(
      ctx.id,
      InputFile.fromFile(
        File('example/assets/photo.jpeg'),
      ),
    );
  });

The code worked fine, and the photo message was sent. So, it's working even in the latest version? Otherwise, can you please share your code which threw the given exception?

I'm not sure why this issue started randomly yesterday, especially since the same version was working fine the day before. However, I followed your advice and downgraded to the version you recommended, v1.10.7.

HeySreelal commented 1 year ago

Hey, thanks! I rechecked it and found that it's not actually just with the sendPhoto method instead the code would break whenever an exception was thrown from the Telegram side - like sending a message to a blocked chat, etc.

Fixed it in 19f3e640f64b2ce783c9825516938eea5ea62c8a

Thanks again for improving Televerse, feel free to report more issues if you find any. 🚀

OttomanDeveloper commented 1 year ago

I appreciate it. I checked the problem, and it seems to be resolved now.

HeySreelal commented 1 year ago

Awesome!! Thanks for confirming ❤️