Dépôt sur le scorbot modérateur
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

from typing import List
from .requests import LoginRequest, PostLoginRequest
import logging
class Interlocutor:
def __init__(self, nick: str, age:int, city: str, is_male: bool, conv_id: str):
self.nick = nick
self.age = age
self.is_male = is_male
self.city = city
self.id = conv_id
@classmethod
def from_string(cls, str):
# 47130922100412004Rastapopoulos
# 47 (age) 1 (sexe) 30922 (city id) 100412(conv id)
age = str[:2]
is_male = int(str[2:3]) in (1, 6)
city_id = str[3:8]
conv_id = str[8:14]
nick = str[17:]
return cls(nick, age, city_id, is_male, conv_id)
def __eq__(self, other):
return other.nick == self.nick
class CocoClient:
def __init__(self, nick: str, age: int, is_female: bool, zip_code: str):
self.nick = nick
self.age = age
self.is_female = is_female
self.zip_code = zip_code
self.interlocutors = [] # type: List[Interlocutor]
self.user_id = None # type:str
self.user_pass = None # type:str
def connect(self):
login_req = LoginRequest(self.nick, self.age, self.is_female, self.zip_code)
self.user_id, self.user_pass = login_req.retrieve()
logging.info("Logged in to coco as %s" % self.nick)
post_login_req = PostLoginRequest(self.user_id, self.user_pass)
post_login_req.retrieve()
logging.info("Post login successful")
def pulse(self):
pass
def send_msg(self):
pass
def switch_conv(self, nick: str=None):
pass