Skip to content

Commit

Permalink
Added post_message method to Client
Browse files Browse the repository at this point in the history
  • Loading branch information
Issei Horie committed Jun 22, 2019
1 parent b02c8bb commit aedd88e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions typetalk/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


class Bot(Client):
def __init__(self, token):
self.token = token
def __init__(self):
self.is_bot = True
16 changes: 14 additions & 2 deletions typetalk/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# -*- coding: utf-8 -*-

from .http import HTTPClient
from .http import Route, HTTPClient


class Client:
def __init__(self):
def __init__(self, token):
self.http = HTTPClient()

def post_message(self, topic_id, message):
r = Route('POST', '/api/v1/topics/{topic_id}', topic_id=topic_id)
payload = {}

if message:
payload['message'] = message
else:
# TODO: throw error
pass

return self.http.request(r, json=payload)
12 changes: 0 additions & 12 deletions typetalk/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,3 @@ async def request(self, route, **kwargs):
async with self.__session.request(method, url, **kwargs) as r:
data = await json_or_text(r)
return data

def post_message(self, topic_id, message):
r = Route('POST', '/api/v1/topics/{topic_id}', topic_id=topic_id)
payload = {}

if message:
payload['message'] = message
else:
# TODO: throw error
pass

return self.request(r, json=payload)

0 comments on commit aedd88e

Please sign in to comment.