-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
14 changed files
with
315 additions
and
11 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from aiohttp import web | ||
|
||
from waio import Bot, Dispatcher | ||
from waio.logs import loguru_filter | ||
from waio.types import Message | ||
|
||
loguru_filter.set_level('DEBUG') | ||
|
||
bot = Bot( | ||
apikey='API_KEY', | ||
src_name='SRC_NAME', | ||
phone_number=0000000000 | ||
) | ||
|
||
dp = Dispatcher(bot=bot) | ||
|
||
|
||
@dp.message_handler(commands=['start']) | ||
async def start_command(message: Message): | ||
await message.bot.send_audio( | ||
receiver=message.sender_number, | ||
url="https://www.buildquickbots.com/whatsapp/media/sample/audio/sample01.mp3" | ||
) | ||
|
||
|
||
async def handler_gupshup(request): | ||
event = await request.json() | ||
await dp.handle_event(event) | ||
return web.Response(status=200) | ||
|
||
|
||
if __name__ == "__main__": | ||
webhook = web.Application() | ||
webhook.add_routes([web.post('/api/v1/gupshup/hook', handler_gupshup)]) | ||
web.run_app(webhook, port=8008) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from aiohttp import web | ||
|
||
from waio import Bot, Dispatcher | ||
from waio.logs import loguru_filter | ||
from waio.types import Message | ||
|
||
loguru_filter.set_level('DEBUG') | ||
|
||
bot = Bot( | ||
apikey='API_KEY', | ||
src_name='SRC_NAME', | ||
phone_number=0000000000 | ||
) | ||
|
||
dp = Dispatcher(bot=bot) | ||
|
||
|
||
@dp.message_handler(commands=['start']) | ||
async def start_command(message: Message): | ||
await message.bot.send_file( | ||
receiver=message.sender_number, | ||
url='https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf', | ||
filename='test_file.pdf', | ||
caption='Test Caption' | ||
) | ||
|
||
|
||
async def handler_gupshup(request): | ||
event = await request.json() | ||
await dp.handle_event(event) | ||
return web.Response(status=200) | ||
|
||
|
||
if __name__ == "__main__": | ||
webhook = web.Application() | ||
webhook.add_routes([web.post('/api/v1/gupshup/hook', handler_gupshup)]) | ||
web.run_app(webhook, port=8008) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from aiohttp import web | ||
|
||
from waio import Bot, Dispatcher | ||
from waio.logs import loguru_filter | ||
from waio.types import Message | ||
|
||
loguru_filter.set_level('DEBUG') | ||
|
||
bot = Bot( | ||
apikey='API_KEY', | ||
src_name='SRC_NAME', | ||
phone_number=0000000000 | ||
) | ||
|
||
dp = Dispatcher(bot=bot) | ||
|
||
|
||
@dp.message_handler(commands=['start']) | ||
async def start_command(message: Message): | ||
await message.bot.send_sticker( | ||
receiver=message.sender_number, | ||
url="http://www.buildquickbots.com/whatsapp/stickers/SampleSticker01.webp", | ||
) | ||
|
||
|
||
async def handler_gupshup(request): | ||
event = await request.json() | ||
await dp.handle_event(event) | ||
return web.Response(status=200) | ||
|
||
|
||
if __name__ == "__main__": | ||
webhook = web.Application() | ||
webhook.add_routes([web.post('/api/v1/gupshup/hook', handler_gupshup)]) | ||
web.run_app(webhook, port=8008) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from aiohttp import web | ||
|
||
from waio import Bot, Dispatcher | ||
from waio.logs import loguru_filter | ||
from waio.types import Message | ||
|
||
loguru_filter.set_level('DEBUG') | ||
|
||
bot = Bot( | ||
apikey='API_KEY', | ||
src_name='SRC_NAME', | ||
phone_number=0000000000 | ||
) | ||
|
||
dp = Dispatcher(bot=bot) | ||
|
||
|
||
@dp.message_handler(commands=['start']) | ||
async def start_command(message: Message): | ||
await message.bot.send_video( | ||
receiver=message.sender_number, | ||
url="https://www.buildquickbots.com/whatsapp/media/sample/video/sample01.mp4", | ||
caption="Test video caption" | ||
) | ||
|
||
|
||
async def handler_gupshup(request): | ||
event = await request.json() | ||
await dp.handle_event(event) | ||
return web.Response(status=200) | ||
|
||
|
||
if __name__ == "__main__": | ||
webhook = web.Application() | ||
webhook.add_routes([web.post('/api/v1/gupshup/hook', handler_gupshup)]) | ||
web.run_app(webhook, port=8008) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import ujson | ||
|
||
|
||
class AudioModel: | ||
def __init__( | ||
self, | ||
url: str, | ||
): | ||
self.type = 'audio' | ||
self.url = url | ||
|
||
def dict(self): | ||
return { | ||
"type": self.type, | ||
"url": self.url, | ||
} | ||
|
||
def json(self): | ||
return ujson.dumps(self.dict(), indent=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Optional | ||
|
||
import ujson | ||
|
||
|
||
class FileModel: | ||
def __init__( | ||
self, | ||
url: str, | ||
filename: str, | ||
caption: Optional[str] = None | ||
): | ||
self.type = 'file' | ||
self.url = url | ||
self.filename = filename | ||
self.caption = caption | ||
|
||
def dict(self): | ||
return { | ||
"type": self.type, | ||
"url": self.url, | ||
"filename": self.filename, | ||
"caption": self.caption, | ||
} | ||
|
||
def json(self): | ||
return ujson.dumps(self.dict(), indent=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import ujson | ||
|
||
|
||
class StickerModel: | ||
def __init__( | ||
self, | ||
url: str, | ||
): | ||
self.type = 'sticker' | ||
self.url = url | ||
|
||
def dict(self): | ||
return { | ||
"type": self.type, | ||
"url": self.url, | ||
} | ||
|
||
def json(self): | ||
return ujson.dumps(self.dict(), indent=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Optional | ||
|
||
import ujson | ||
|
||
|
||
class VideoModel: | ||
def __init__( | ||
self, | ||
url: str, | ||
caption: Optional[str] = None | ||
|
||
): | ||
self.type = 'video' | ||
self.url = url | ||
self.caption = caption | ||
|
||
def dict(self): | ||
return { | ||
"type": self.type, | ||
"url": self.url, | ||
"caption": self.caption, | ||
} | ||
|
||
def json(self): | ||
return ujson.dumps(self.dict(), indent=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters