Skip to main content

Asynchronous Python API for building Viber bots.

Project description

aioviber

Asynchronous Python API for building Viber bots.

Build Status Coverage Status Package version Python versions

Example

import logging

from aioviber.bot import Bot
from aioviber.chat import Chat
from viberbot.api.viber_requests import ViberSubscribedRequest

logger = logging.getLogger(__name__)

bot = Bot(
    name='ViberBot',
    avatar='http://avatar.example.com/avatar.jpg',
    auth_token="**************-**************-**************",  # Public account auth token
    host="my.host.com",  # should be available from wide area network
    port=80,
    webhook="https://my.host.com",  # Webhook url
)

@bot.command('ping')
async def ping(chat: Chat, matched):
    await chat.send_text('pong')

@bot.event_handler('subscribed')
async def user_subscribed(chat: Chat, request: ViberSubscribedRequest):
    await chat.send_text('Welcome')

@bot.message_handler('sticker')
async def sticker(chat: Chat):
    await chat.send_sticker(5900)

if __name__ == '__main__':  # pragma: no branch
    bot.run()  # pragma: no cover

API designed similar to aiotg

Getting Started

In order to implement the API you will need the following: 1. An Active Viber account on a platform which supports PA (iOS/Android). 2. Active Public Account; 3. Public Account authentication token; 4. Write your bot with aioviber.

Read more: Public Account Documentation — Viber REST API

There is no way to run viber bot in polling mode like Telegram.

Install

pip install aioviber

Viber API

Messaging flow

Messaging flow

Messaging flow

Events types

Documentation about events types https://developers.viber.com/docs/api/rest-bot-api/#callbacks

Callbacks can be proceeded with @bot.event_handler('subscribed') decorator

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioviber-0.1.4.5.tar.gz (11.1 kB view details)

Uploaded Source

File details

Details for the file aioviber-0.1.4.5.tar.gz.

File metadata

  • Download URL: aioviber-0.1.4.5.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aioviber-0.1.4.5.tar.gz
Algorithm Hash digest
SHA256 af71eb59e36ce26b619cd95448870f43a9ae1f76745e7ccbdef6dc379888ce80
MD5 f5e82d69558c1b05b5b60abdae412b94
BLAKE2b-256 3ed109dc6942397b098c25a11aa5add11ba3b9c65ddc43308b7d728506b4570b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page