Beispiel #1
0
    def OnCommand(self, objects):
        if isAdmin(objects['from_id']) is False:
            return 'ok'

        message = objects['text'].split()
        if (len(message) != 2):
            self.bot.api.messages.send(user_id=objects['from_id'],
                                       message='Необходимо ввести: топ число')
            return 'ok'
        if not message[1].isdigit():
            self.bot.api.messages.send(user_id=objects['from_id'],
                                       message='Необходимо ввести: топ число')
            return 'ok'
        if int(message[1]) < 1 or int(message[1]) > 50:
            self.bot.api.messages.send(user_id=objects['from_id'],
                                       message='Предел варьируется от 1 до 50')
            return 'ok'
        s = 'Топ {} богачей<br><br>'.format(message[1])
        cursor = self.bot.db.query(
            'SELECT `vk_id`, `balance` FROM `accounts` ORDER BY `balance` DESC LIMIT {}'
            .format(message[1]))
        dataq = cursor.fetchall()
        index = 1
        for i in dataq:
            s += '{}. vk.com/id{} — {} ху-вон<br>'.format(index, i[0], i[1])
            index += 1
        self.bot.api.messages.send(user_id=objects['from_id'], message=s)
Beispiel #2
0
    def OnCommand(self, objects):
        if isAdmin(objects['from_id']) is False:
            return 'ok'

        message = objects['text'].split()
        if len(message) < 3:
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message="Команда введена неправильно")

        if not message[1].isdigit():
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='Необходимо ввести: сет ID-пользователя ху-вон')

        if not message[2].isdigit():
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='Необходимо ввести: сет ID-пользователя ху-вон')

        if int(message[1]) <= 0:
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='ID не может быть отрицательным')

        user = self.bot.createUser(int(message[1]))
        self.bot.api.messages.send(
            user_id=objects['from_id'],
            message='#log<br>Баланс vk.com/id{} изменен с {} на {}'.format(
                message[1], user.balance, message[2]))
        user.balance = int(message[2])
        user.save()
        user = None
def mapPoints():

    if "filter_species" not in request.args:
        filter_species = None
    else:
        filter_species = request.args.get('filter_species')
        if filter_species == "":
            return jsonify({ "results" : []})

    filter_networks = request.args.get('filter_networks',None)
    filter_networks = [filter_networks] if filter_networks else []

    rm = ReportModel();

    if utils.isAdmin():
        points = rm.getAdminReportsPoints(filterSpecies= filter_species,filterNetworks=filter_networks)

    else:
        points = rm.getReportsPointsComplete(status=4,filterSpecies=filter_species,filterNetworks=filter_networks) \
            + rm.getReportsPointsComplete(status=2,filterSpecies=filter_species,filterNetworks=filter_networks)

        if utils.isLogged():
            pointsUser = rm.getReportsPointsComplete(status=1,filterSpecies=filter_species,idUser=session["id_user"],filterNetworks=filter_networks)
            points = points + pointsUser


    return jsonify( { "results" : points })
Beispiel #4
0
def multireplprefix(irc, source, msgtarget, args):
    if utils.isAdmin(irc, source):
        if irc.multirepl == True:
            irc.multirepl = False
            irc.repls.run(msgtarget, irc.repl)
            irc.repl = ""
        else:
            irc.multirepl = True
Beispiel #5
0
def swagger_login(func):
    @wraps(func)
    def login_pass(*args, **kwargs):
        return func(*args, **kwargs)

    if isAdmin() or func.func_name != 'specs':
        return login_pass
    return login.login_required(func)
def deleteComment(id_comment):
    rm = ReportModel()
    c = rm.getComment(id_comment)
    if c==None:
        # this sleep is done to simulate a sending to mislead hackers
        time.sleep(1)
    else:
        if not utils.isAdmin():
            c = rm.getComment(id_comment)
            if c["id_user"]!=session["id_user"]:
                return make_response(jsonify( { 'error': 'Operation not allowed' } ), 400)

        rm.deleteComment(id_comment)

    return jsonify( {"result" : "done" })
Beispiel #7
0
    def OnCommand(self, objects):
        if isAdmin(objects['from_id']) is False:
            return 'ok'

        message = objects['text'].split()
        if len(message) < 4:
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message="Команда введена неправильно")

        if not message[1].isdigit() or not message[2].isdigit(
        ) or not message[3].isdigit():
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message=
                'Необходимо ввести: прн ID-пользователя ID-пользователя процент(1-100)'
            )

        if int(message[3]) < 1 or int(message[3]) > 100:
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='Процент варьируется от 1 до 100')

        if int(message[2]) <= 0 or int(message[2]) < 0:
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='ID не может быть отрицательным')

        user1 = self.bot.createUser(message[1])
        user2 = self.bot.createUser(message[2])
        result_minus = int(abs(user1.balance * int(message[3]) / 100))
        text_format = "#log<br>Перенос ху-вон vk.com/id{} -> vk.com/id{}<br>Перенесено {}% от суммы {} = {} ху-вон".format(
            user1.id, user2.id, message[3], user1.balance, result_minus)
        user1.balance -= result_minus
        user2.balance += result_minus
        user1.save()
        user2.save()
        user1 = None
        user2 = None
        self.bot.api.messages.send(user_id=objects['from_id'],
                                   message=text_format)
Beispiel #8
0
    def OnCommand(self, objects):

        if isAdmin(objects['from_id']) is False:
            return 'ok'

        message = objects['text'].split()

        if len(message) < 2:
            return 'ok'

        if not message[1].isdigit():
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='Необходимо ввести: балл ID-пользователя')
        if int(message[1]) <= 0:
            return self.bot.api.messages.send(
                user_id=objects['from_id'],
                message='ID не может быть отрицательным или равен нулю')

        user = self.bot.createUser(int(message[1]))
        self.bot.api.messages.send(user_id=objects['from_id'],
                                   message='Баланс id{}: {} ≜'.format(
                                       user.id, user.balance))
        user = None
Beispiel #9
0
def handle_PRIVMSG(irc, args):
    nick = args.sender.nick
    ident = args.sender.ident
    address = args.sender.mask
    ignored = False
    try:
        chan, message = args.args
    except ValueError:
        return

    if chan == irc.nick:
        chan = nick

    for user in irc.ignored:
        if fnmatch.fnmatch(nick.lower(), user.lower()) == True:
            ignored = True
        elif fnmatch.fnmatch(address.lower(), user.lower()) == True:
            ignored = True
        elif chan.lower() == user.lower():
            ignored = True

    if isAdmin(irc, args.sender) or isOp(irc, args.sender):
        ignored = False

    if ignored == False:

        if "\x01ACTION " in message:
            _format = "* {nick} {message}".format(nick=nick,
                                                  message=message.replace(
                                                      "\x01ACTION ",
                                                      "").replace("\x01", ""))
        else:
            _format = "<{nick}> {message}".format(nick=nick, message=message)

        try:
            if len(irc.channels[chan]["buffer"]) > irc.buffermaxlen:
                irc.channels[chan]["buffer"].pop(0)
            irc.channels[chan]["buffer"].append(_format)
        except:
            # buffer doesn't exist? usually a pm
            pass
            #irc.channels[chan] = {"buffer": []}

        for cmd in bot_regexes.items():
            regex, func = cmd
            m = regex.search(message)
            if m:
                #log.info("(%s) Calling regex for %s", irc.netname, func.__name__)
                c = threading.Thread(target=func,
                                     args=(irc, args.sender, chan, m.groups()))
                c.daemon = True
                c.start()

        if args.args[0] == irc.nick:
            # in a pm, should reply to nick not self
            args.args[0] = nick
            regex = u"(?:{}?)(.*?)(?:$|\s+)(.*)".format(irc.prefix)
        else:
            regex = u"(?:{})(.*?)(?:$|\s+)(.*)".format(irc.prefix)
        m = re.match(regex, message)
        if m:
            command, cmdargs = m.groups()

            if chan in irc.conf["blacklisted_commands"]:
                if command in irc.conf["blacklisted_commands"][chan]:
                    return

            try:
                func = utils.bot_commands[command]
            except KeyError:
                pass

            else:
                try:
                    log.info("(%s) Calling command %r", irc.netname, command)
                    threading.Thread(target=func,
                                     args=(irc, args.sender, chan,
                                           cmdargs)).start()

                except Exception as e:
                    log.exception(
                        "(%s) Unhandled exception caught in command %r",
                        irc.netname, command)
                    irc.msg(chan, "Uncaught exception: {}".format(str(e)))

        if chan not in irc.conf.get("donotlog", []):
            try:
                if chan != irc.nick:
                    irc.nicks[nick]["lastaction"] = {
                        "action": "PRIVMSG",
                        "args": message,
                        "time": time.time(),
                        "chan": chan
                    }
            except:
                pass
Beispiel #10
0
def multirepl(irc, source, msgtarget, args):
    args = args[0]
    if utils.isAdmin(irc, source) and irc.multirepl == True and args != '"""':
        irc.repl+=args+"\n"
Beispiel #11
0
def repl(irc, source, msgtarget, args):
    if utils.isAdmin(irc, source):
        irc.repls.run(msgtarget, args)
Beispiel #12
0
def handle_INVITE(irc, args):
    if utils.isAdmin(irc, args.sender):
        irc.send("JOIN {}".format(args.args[1]))
from video import create_capture
from common import draw_str, clock

# Read yaml config file
yamldata = utils.readYamlConfigFile(sys.argv[1])

# Get data from 'Database' list of yaml config file
databaseYamlData = yamldata[0]['Database']
dbConnection = databaseOperation.openConnection(databaseYamlData)

print('Mot de passe:')
inputPassword = input()

encodedInputPassword = utils.encodeToSha256(inputPassword)

if utils.isAdmin(encodedInputPassword, dbConnection):
    print('Oui')
else:
    print('Non')

known_face_encodings = []
known_face_names = []
known_face_filenames = []

# Arborescence des fichiers
for (dirpath, dirnames, filenames) in os.walk('src/'):
    known_face_filenames.extend(filenames)
    break

# Création des données des visages qui existent déjà
for filename in known_face_filenames: