question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Good evening. You can run the bot in webhook mode on localhost. Logically, you can go to it with uCurl, passing the necessary parameters. The question is how to go to the bot using uCurl. It would have greatly facilitated testing at the level of the system.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
evgfilim1commented, Jan 26, 2020

Works for me

bot:

from aiogram import Bot, Dispatcher
from aiogram.dispatcher.webhook import SendMessage

bot = Bot('token-goes-here')
dp = Dispatcher(bot)

@dp.message_handler(commands=['start'])
async def start(message):
    return SendMessage(text='Hello!').reply(message).to(message)

async def on_startup(d: Dispatcher):
    await d.bot.set_webhook(f'https://my-domain/something')  # Domain and path are handled by nginx

async def on_shutdown(d: Dispatcher):
    await d.bot.delete_webhook()

if __name__ == '__main__':
    executor.start_webhook(dp, '/', on_startup=on_startup, on_shutdown=on_shutdown, host='0.0.0.0',
                           port=3456)

console:

$ curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ "update_id":10000, "message":{ "date":1441645532, "chat":{ "last_name":"Test Lastname", "id":1111111, "first_name":"Test", "username":"Test" }, "message_id":1365, "from":{ "last_name":"Test Lastname", "id":1111111, "first_name":"Test", "username":"Test" }, "text":"/start" } }' "http://0.0.0.0:3456/"
{"method": "sendMessage", "chat_id": 1111111, "text": "Hello!", "reply_to_message_id": 1365}

@LuckyDenis if this issue is still relevant, could you provide us more information?

0reactions
LuckyDeniscommented, Apr 28, 2020

The issue is resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing incoming webhooks using cURL
A simple way to test an incoming webhook and to make formatting messages easier is to use a simple command-line tool called cURL....
Read more >
curl - Discord Webhooks Guide - Hello
curl - command line tool for sending web requests. Windows - can be installed with Scoop or Chocolatey. Linux - can be installed...
Read more >
Webhooks - How to Test - SugarOutfitters
To test your webhook script, you can simple use curl to send a POST ... Below are a couple full example curl requests...
Read more >
Post a message to the webhook using cURL #1546 - GitHub
This returns: Bad payload received by generic incoming webhook. The correct command is: curl -H 'Content-Type: application/json' - ...
Read more >
Connect Webhook to CURL with LeadsBridge
1. How to set up your bridge step-by-step tutorial 2. Before you start 3. Bridges Main information
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found