Exemple #1
0
    def on_put(self, req, resp):
        data = req.context["doc"]
        userid = req.context['userid']
 
        if score.save_all(userid,data):
            resp.body = utils.sendMessage(True, 'Ok')
        else:
            resp.body = utils.sendMessage(False, 'Error al guardar')
Exemple #2
0
    def on_put(self, req, resp):
        data = req.context["doc"]
        data["url_logo"] = utils.saveImageBase64(data["logo_base64"])

        if team.save(data):
            resp.body = utils.sendMessage(True, "")
        else:
            resp.body = utils.sendMessage(False, "Error al registrar")
Exemple #3
0
    def on_put(self, req, resp):
        data = req.context['doc']
        userid = req.context['userid'] 

        if userid == data['id']:
            resp.body = utils.sendMessage(False, 'No es posible cambiar datos del mismo usuario')
            return

        if user.update(data):
            resp.body = utils.sendOk('ok')
        else:
            resp.body = utils.sendMessage(False, 'Error al momento de registrar')
Exemple #4
0
    def on_get(self, req, resp, id):
        user = db.first("select id, name from gambler where id=%s", (id,))

        if user:
            resp.body = utils.sendOk(user)
        else:
            resp.body = utils.sendMessage(False,"Usuario no existe")
Exemple #5
0
    def on_get(self, req, resp, championship_id):
        obj = db.first("""
                select id, name,is_disabled
                from championship
                where id = %s
                order by name asc
                """, (championship_id,))

        datesDetail = db.query("""
            select
                d.id,
                d.name
            from championship_date d
            where is_disabled = false and
                  id_championship = %s
            order by id asc
            """, (championship_id,))

        dateWithMatchForClient = []
        for row in datesDetail:
            types = date.findTypeOfResults(row['id'])

            for key in types.keys():
                row[key] = types[key]['points']

            matchDetails = db.query("""
                select
                    m.id,
                    id_team1,
                    id_team2,
                    t1.name as name_team1,
                    t2.name as name_team2,
                    goals_team1,
                    goals_team2,
                    date_start
                from championship_match m
                inner join team t1
                    on t1.id = m.id_team1
                inner join team t2
                    on t2.id = m.id_team2
                where m.is_disabled = false and
                      m.id_championship_date = %s
                """, ( row["id"] ,) )

            convertScoreInString(matchDetails)
            row["matchs"] = matchDetails
            dateWithMatchForClient.append(row)
        if obj is None:
            resp.body = utils.sendMessage(False, "Campeonato no encontrado")
        else:
            obj["dates"] = dateWithMatchForClient
            resp.body = utils.sendOk(obj)
Exemple #6
0
    def on_post(self, req, resp):
        inUser = req.context["doc"]

        inUser['username'] = inUser['username'].lower()

        foundUser = db.first("""
            select id,name,role,is_disabled
            from gambler
            where
                username = %(username)s
                --and password = %(password)s
                and is_disabled = false """, inUser)

        result = {}
        if foundUser == None:
            resp.body = utils.sendMessage(False,
                '''Todavía no te unes al Club de Eventos DS.
                    Para saber cómo hacerlo, haz clic <a href="https://www.conexionbcp.com/wikis/home?lang=es#!/wiki/W22300a7f9e01_4d59_ac64_3ec295877429/page/Qué hago para pertenecer al Club de Eventos-DS" target='_blank'>aquí</a>''')
        else:
            try:
                #if not utils.isValidUserOnActiveDirectory(inUser['username'],inUser['password']):
                #    resp.body = utils.sendMessage(False,'Matrícula o contraseña no coincide')
                #    return
                #end-if

                token = utils.makeToken()
                db.execute("update gambler set token=%s where id=%s",
                            (token, foundUser["id"]) )
                result = {
                    "token": token,
                    "id": foundUser["id"],
                    "name": foundUser["name"],
                    "role": foundUser["role"]}
                resp.body = utils.sendOk(result)
            except:
                resp.body = utils.sendMessage(False,'Error al intentar iniciar sesión')
def sendRequest(sock: socket.socket, request_header: dict) -> int:
    """Send request to a connected socket."""
    # send request header, pass possible error
    if utils.sendMessage(sock, str(request_header)) == 1:
        return 1

    # make request
    if request_header["method"] == "list":
        utils.printList(
            eval(utils.recvMessage(sock, message_len=const.HUGE_MESSAGE)))
    # check if filename argument is given
    elif not request_header["filename"]:
        print("ERROR: filename argument required for get/post")
    elif request_header["method"] == "post":
        utils.sendFile(sock, request_header["filename"])
    elif request_header["method"] == "get":
        utils.recvFile(sock, request_header["filename"])
    # shouldn't get here
    else:
        print("ERROR: unknown metehod.")
Exemple #8
0
def betGame(s, user, message):
    messagelist = message.split(" ")
    if len(messagelist) == 2 and messagelist[1].isdigit():
        bet = int(messagelist[1])
        num = random.randint(1, 100)
        if bet > cfg.POINTS[user] or bet == 0:
            if bet == 0:
                utils.sendMessage(s, "plz Kappa")
            else:
                utils.sendMessage(
                    s, user + " you are too broke to bet that much.(Points: " +
                    str(cfg.POINTS[user]) + ")")
        else:
            cfg.POINTS[user] -= bet
            if num < 51:
                utils.sendMessage(s, "Sorry, you lost it all " + user + " :(")
            if num < 76 and num > 50:
                num2 = random.randint(1, (bet * 2))
                utils.sendMessage(
                    s, "You won back " + str(num2) + " points " + user)
                cfg.POINTS[user] += num2
            if num < 100 and num > 75:
                utils.sendMessage(
                    s, "You won double the amount you bet " + user + "!")
                cfg.POINTS[user] += (bet * 2)
            if num == 100:
                utils.sendMessage(
                    s, "Congrats " + user +
                    ", you won 3 times the amount you bet! PogChamp")
                cfg.POINTS[user] += (bet * 3)
            saveData("etc/points.dat", cfg.POINTS)
    else:
        utils.whisper(s, user,
                      "Invalid syntax, command is: " + cfg.HELPLIST['bet'])
def send_msg(bot, msg, cid=None):
    chatToSend = cfg.subscribed_chats if cid is None else [cid]
    for chat_id in chatToSend:
        utils.sendMessage(bot, chat_id, msg, 'HTML')
Exemple #10
0
 def on_get(self, req, resp, team_id):
     obj = db.first("select * from team where id = %s", (team_id,))
     if obj is None:
         resp.body = utils.sendMessage(False, "Equipo no encontrado")
     else:
         resp.body = utils.sendOk(obj)
Exemple #11
0
def command(user, message, s):
    try:
        print(user + " used command: " + message)
    except UnicodeEncodeError:
        print("Unicode message used with command")
    message = message[:-1]
    message = message.lower()
    temp = message.split(" ")

    ###Admin commands/ other commands###
    if message == "!mods":
        utils.whisper(s, user, str(cfg.MODS)[1:-1])
    if temp[0] == "!help":
        data.help(s, message, user)

    ##Poll Commands##
    if temp[0] == "!openpoll" and utils.isOP(user):
        data.openpoll(s, message, user)
    if temp[0] == "!vote":
        data.vote(s, message, user)
    if message == "!closepoll" and utils.isOP(user):
        data.closepoll(s, user)

    ##Raffle Commands##
    if message == "!openraffle" and utils.isOP(user):
        data.openraffle(s, user)
    if message == "!raffle":
        data.raffle(s, user)
    if message == "!closeraffle" and utils.isOP(user):
        data.closeraffle(s, user)

    ##Roulette Commands##
    if message == "!roulette" and data.checkcooldown(30, 0, user):
        data.roulette(user, s)

    ##Points Commands##
    if message == "!points":
        utils.sendMessage(s,
                          user + " has " + str(cfg.POINTS[user]) + " points")
    if temp[0] == "!bet" and data.checkcooldown(10, 2, user):
        data.betGame(s, user, message)
    if temp[0] == "!addpoints" and user == cfg.CHAN:
        print("***" + temp[2] + " points added to " + temp[1] + "***")
        try:
            data.addPoints(temp[1], int(temp[2]))
        except:
            print("Failed to add points")
    if message == "!leaderboard" and data.checkcooldown(60, 3, user):
        data.leaderboard(s)

    ###Text Commands (found in cfg.py)###
    message = message.replace(" ", "")
    if message in cfg.DATA:
        utils.sendMessage(s, cfg.DATA[message])
        if message == "!social":
            data.checkcooldown(1800, 1, "NULLUSER")
    if "unmodwalkire" in message or "unmodwa1kire" in message:
        if not utils.isOP(user):
            utils.timeout(s, user, 120)

    ##Endbot Command##
    #USED FOR DEBUGGING
    if message == "!endbot" and user == "walkire":
        print("Ending bot")
        saveData("etc/points.dat", cfg.POINTS)
        return -1
Exemple #12
0
if not 'matches' in data:
    utils.exitWithMessage(session, 'ProssimoMatch Error: No matches key in json')
    
matches = data['matches']
if len(matches) == 0:
    sys.exit()

matchStatus = matches[0]['status']
if matchStatus != 'SCHEDULED':
    sys.exit()
    
dateString = matches[0]['utcDate']
dateMatch = datetime.strptime(dateString, '%Y-%m-%dT%H:%M:%S%z')
timezone = pytz.timezone('Europe/Rome')

dateMatch = dateMatch.astimezone(timezone)
dateNow = datetime.now().astimezone(timezone)

hoursTillMatch = (dateMatch - dateNow).total_seconds() / 60 / 60

message = '\nRicordatevi di postare la formazione almeno 15 minuti prima'

if hoursTillMatch > 23.5 and hoursTillMatch < 24.6:
    message = 'La prossima giornata inizierà domani alle ' + dateMatch.strftime('%H:%M') + message
elif hoursTillMatch > 2.5 and hoursTillMatch < 3.6:
    message = 'La prossima giornata inizierà OGGI alle ' + dateMatch.strftime('%H:%M') + message
else:
    sys.exit()

utils.sendMessage(session, message)