Skip to content

Commit

Permalink
Fix the sample and readme imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarM committed Jan 11, 2017
1 parent ec2c474 commit a3ba0cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
33 changes: 17 additions & 16 deletions README.md
Expand Up @@ -14,18 +14,19 @@ This library is released under the terms of the Apache 2.0 license. See [License
### Installing
Creating a basic Viber bot is simple:

1. Import `viber.api` library to your project
2. Create a Public Account and use the API key from [https://developers.viber.com]()
3. Configure your bot as described in the documentation below
4. Start your web server
5. Call `set_webhook(url)` with your web server url
1. Install the library though pip `pip install viberbot`
2. Import `viberbot.api` library to your project
3. Create a Public Account and use the API key from [https://developers.viber.com]()
4. Configure your bot as described in the documentation below
5. Start your web server
6. Call `set_webhook(url)` with your web server url

## A simple Echo Bot
### Firstly, let's import and configure our bot

```python
from viber.api.api import Api
from viber.api.bot_configuration import BotConfiguration
from viberbot import Api
from viberbot.api.bot_configuration import BotConfiguration

bot_configuration = BotConfiguration(
name='PythonSampleBot',
Expand Down Expand Up @@ -76,7 +77,7 @@ logger.addHandler(handler)
```

### Do you supply a basic types of messages?
Well, funny you ask. Yes we do. All the Message types are located in `viber.api.messages` package. Here's some examples:
Well, funny you ask. Yes we do. All the Message types are located in `viberbot.api.messages` package. Here's some examples:

```python
from viberbot.api.messages import (
Expand Down Expand Up @@ -124,11 +125,11 @@ from viberbot.api.messages import VideoMessage
from viberbot.api.messages.text_message import TextMessage
import logging

from viber.api.viber_requests import ViberConversationStartedRequest
from viber.api.viber_requests import ViberFailedRequest
from viber.api.viber_requests import ViberMessageRequest
from viber.api.viber_requests import ViberSubscribedRequest
from viber.api.viber_requests import ViberUnsubscribedRequest
from viberbot.api.viber_requests import ViberConversationStartedRequest
from viberbot.api.viber_requests import ViberFailedRequest
from viberbot.api.viber_requests import ViberMessageRequest
from viberbot.api.viber_requests import ViberSubscribedRequest
from viberbot.api.viber_requests import ViberUnsubscribedRequest

app = Flask(__name__)
viber = Api(BotConfiguration(
Expand Down Expand Up @@ -174,7 +175,7 @@ As you can see there's a bunch of `Request` types here's a list of them.
## Viber API
### Api class

`from viber.api.api import Api`
`from viberbot import Api`

* Api
* [init(bot\_configuration)](#new-Api())
Expand Down Expand Up @@ -456,7 +457,7 @@ message = URLMessage(media="http://my.siteurl.com");
| contact | `Contact` |

```python
from viber.api.messages.data_types.contact import Contact
from viberbot.api.messages.data_types.contact import Contact

contact = Contact(name="Viber user", phone_number="+0015648979", avatar="http://link.to.avatar")
contact_message = ContactMessage(contact=contact)
Expand Down Expand Up @@ -494,7 +495,7 @@ message = VideoMessage(media="http://site.com/video.mp4", size=21499)
| location | `Location` |

```python
from viber.api.messages.data_types.location import Location
from viberbot.api.messages.data_types.location import Location

location = Location(lat=0.0, lon=0.0)
location_message = LocationMessage(location=location)
Expand Down
19 changes: 9 additions & 10 deletions sample_bot.py
@@ -1,18 +1,18 @@
from flask import Flask, request, Response
from viber.api.api import Api
from viber.api.bot_configuration import BotConfiguration
from viber.api.messages.text_message import TextMessage
from viberbot import Api
from viberbot.api.bot_configuration import BotConfiguration
from viberbot.api.messages.text_message import TextMessage
from viberbot.api.viber_requests import ViberConversationStartedRequest
from viberbot.api.viber_requests import ViberFailedRequest
from viberbot.api.viber_requests import ViberMessageRequest
from viberbot.api.viber_requests import ViberSubscribedRequest
from viberbot.api.viber_requests import ViberUnsubscribedRequest

import time
import logging
import sched
import threading

from viber.api.viber_requests import ViberConversationStartedRequest
from viber.api.viber_requests import ViberFailedRequest
from viber.api.viber_requests import ViberMessageRequest
from viber.api.viber_requests import ViberSubscribedRequest
from viber.api.viber_requests import ViberUnsubscribedRequest

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
Expand Down Expand Up @@ -52,7 +52,6 @@ def incoming():
def set_webhook(viber):
viber.set_webhook('https://mybotwebserver.com:8443/')


if __name__ == "__main__":
scheduler = sched.scheduler(time.time, time.sleep)
scheduler.enter(5, 1, set_webhook, (viber,))
Expand Down

0 comments on commit a3ba0cc

Please sign in to comment.