예제 #1
0
	def __init__(self, ip, port, player_id):
		self.client = client.new_client(ip, port)
		self.client.set_remote_id(player_id)
		self.img = pygame.image.load("./player2_remote.png")
		self.size = self.img.get_rect().size
		self.players = {}
		self.update()
예제 #2
0
def import_feed(bot, update):
    """
    发送opml文件将会导入
    """
    if update.message.document.file_name.split('.')[-1] != 'opml':
        return
    client = new_client(update.message.chat_id)
    file_id = update.message.document.file_id
    newFile = bot.get_file(file_id)
    data = newFile.download_as_bytearray()
    client.import_feeds(data)
    bot.send_message(chat_id=update.message.chat_id, text=ADD_FEED_OK_MSG)
예제 #3
0
	def __init__(self, ip, port):
		global goal_pos
		self.client = client.new_client(ip, port)
		used_id_pool = self.client.get_id_pool()
		
		self.id = utility.new_id(used_id_pool)
		self.client.set_id(self.id)

		self.img = pygame.image.load("./player2.png")
		self.pos = self.img.get_rect()
		goal_pos = pygame.Rect(self.pos.center, (0, 0))
		self.update()
예제 #4
0
def export(bot, update):
    """
    usage: /export
    """
    client = new_client(update.message.chat_id)
    _ = client.export()
    opml_file = io.BytesIO(bytes(_, 'utf-8'))
    bot.send_document(
    chat_id=update.message.chat_id,
    document=opml_file,
     filename="export.opml")
    opml_file.close()
예제 #5
0
 def wrapper(bot, update, args=[]):
     if len(args) != arg_num:
         bot.send_message(chat_id=update.message.chat_id,
                          text=func.__doc__)
         return
     try:
         if not admin:
             client = new_client(update.message.chat_id)
         else:
             client = admin_client
     except UserNotBindError:
         bot.send_message(chat_id=update.message.chat_id,
                          text=NO_BIND_MSG)
         return
     try:
         func(bot, update, args, client)
     except ClientError as error:
         bot.send_message(chat_id=update.message.chat_id,
                          text=error.get_error_reason())
         return
예제 #6
0
 def wrapper(bot, update, *args, **kwargs):
     try:
         client = new_client(
             update.message.chat_id) if not admin else ADMIN_CLIENT
         return func(bot, update, client=client, *args, **kwargs)
     except UserNotBindError:
         bot.send_message(
             chat_id=update.message.chat_id,
             text=NO_BIND_MSG)
         return
     except ClientError as e:
         bot.send_message(
             chat_id=update.message.chat_id,
             text=e.get_error_reason())
         return
     except RequestException as e:
         bot.send_message(
             chat_id=update.message.chat_id,
             text=str(e))
         return
예제 #7
0
def import_feed(bot, update):
    """
    发送opml文件将会导入
    """
    if not update.document.file_name.split('.')[-1] != 'opml':
         return
    try:
        client = new_client(update.message.chat_id)
    except UserNotBindError:
        bot.send_message(chat_id=update.message.chat_id, text=NO_BIND_MSG)
        return

    file_id = update.message.document.file_id
    newFile = bot.get_file(file_id)
    data = newFile.download_as_bytearray()
    try:
        client.import_feeds(data.decode())
    except ClientError as error:
        bot.send_message(
    chat_id=update.message.chat_id,
     text=error.get_error_reason())
        return
예제 #8
0
def test_new_client_error():
    with pytest.raises(UserNotBindError):
        ret = new_client('2',session=DBSession)
예제 #9
0
def test_new_client():
    ret = new_client('1', session=DBSession)
    assert isinstance(ret, Client)
예제 #10
0
# -*- coding: utf-8 -*-
import client
import sys


controler = client.new_client("localhost", 5000)

for argument in sys.argv[1:]:

	if argument == "kick_all":
		controler.kick_users()

	elif argument == "shutdown":
		controler.kill_remote()
	else:
		print(("unknown option: " + argument))
예제 #11
0
from swagger_client.api.pet_api import PetApi
from swagger_client.api.store_api import StoreApi
from swagger_client.api.user_api import UserApi
from swagger_client.models.pet import Pet

from swagger_client.configuration import Configuration
from client import new_client

if __name__ == "__main__":
    client = new_client(configuration=Configuration())
    body = {
        "id": 0,
        "category": {
            "id": 0,
            "name": "dog"
        },
        "name": "blaki",
        "status": "available"
    }
    pet = client.pet.add_pet(body)
    data = client.pet.delete_pet(pet_id=1)
    print(data)