Beispiel #1
0
 def get_username(self):
     if self.username is None:
         api = API(self)
         user = api.me()
         if user:
             self.username = user.name
         else:
             raise ChatpyError("Unable to get username, invalid token!")
     return self.username
Beispiel #2
0
 def get_username(self):
     if self.username is None:
         api = API(self)
         user = api.me()
         if user:
             self.username = user.name
         else:
             raise ChatpyError("Unable to get username, invalid token!")
     return self.username
def handler(data):
    auth = TokenAuthHandler(env('CHATWORK_TOKEN'))
    api = API(auth, api_root='/v2')
    data = filter(lambda x: x.get('status') != 'Resolved', data)
    if data:
        members = "\n".join([item.get('assigned_to') for item in data])

        body = "[toall]" \
               "[info][title]Danh sach members chưa hoàn thành Monthly report[/title][code]{0}[/code]Hiện tại em không thấy thông tin các bài monthly report của các anh chị trên redmine tháng này.\n" \
               "Các anh chị vui lòng hoàn thành sớm trước ngày 20 hàng tháng để Team Lead và Group leader thực hiện review" \
               "\n\n" \
               "Thank you!!![/info]".format(members)

        api.post_message(**{'room_id': '176758731', 'body': body})
Beispiel #4
0
# chatpy
# Copyright 2013-2015 aqn
# the original source code is written by Joshua Roesslein (Tweepy)
# See LICENSE for details.
"""
Chatwork API library
"""
__version__ = '0.2.2'
__license__ = 'MIT'

from chatpy.models import Status, ModelFactory
from chatpy.error import ChatpyError
from chatpy.api import API
from chatpy.cache import Cache, MemoryCache, FileCache
from chatpy.auth import TokenAuthHandler

# Global, unauthenticated instance of API
api = API()


def debug(level=1):
    from six.moves import http_client
    http_client.HTTPConnection.debuglevel = level
Beispiel #5
0
from flask import Flask
from chatpy.api import API
from chatpy.auth import TokenAuthHandler

app = Flask(__name__)
app.config.from_object('config')

chatwork = API(auth_handler=TokenAuthHandler(app.config['CHATWORK_TOKEN']))

from app.endpoint import *
Beispiel #6
0
def test_auth_ok():
    auth = TokenAuthHandler(chatwork_token)
    api = API(auth)
    api.me()
Beispiel #7
0
def test_auth_ng():
    auth = TokenAuthHandler("invalid_token")
    api = API(auth)
    api.me()