Пример #1
0
def restart(request, boost, username, authcode):
    try:
        authcode.split('-')
    except:
        return HttpResponse('კოდები არასწორ ფორმატშია' if request.LANGUAGE_CODE == 'ka' else 'Invalid format')
    if boost == 'trade':
        if not is_running('TradeBoost.py'):
            return HttpResponse('ბუსტი ჩართული არაა')

        if not WebSettings.tboost_enabled and not request.user.is_staff:
            return HttpResponse('ბუსტი დროებით გათიშულია' if request.LANGUAGE_CODE == 'ka' else 'boost temporarily disabled')
        try:
            db = Trade_queue.objects.get(username=username)
        except:
            return HttpResponseRedirect(REDIRECT_URL)
        if not request.user.is_staff and Hour_queue.objects.filter(username=username, stopped=False).exists():
            return HttpResponse('დაელოდეთ Hour ბუსტის დასრულებას ან გამორთეთ', status=202)
        # if user is trying to restart other user's boost, redirect them unless they're staff member
        if request.user.username == db.user or request.user.is_staff:
            db.stopped = False
            db.finished = False
            db.errlog = ''
            db.authcode = encode(BOOST_ENCRYPTION_KEY, authcode)
            db.save()
            return HttpResponse('განახლდა' if request.LANGUAGE_CODE == 'ka' else 'success')
    elif boost == 'hour':
        if not is_running('HourBoost.py'):
            return HttpResponse('ბუსტი ჩართული არაა')

        if not WebSettings.hboost_enabled and not request.user.is_staff:
            return HttpResponse('ბუსტი დროებით გათიშულია' if request.LANGUAGE_CODE == 'ka' else 'boost temporarily disabled')
        try:
            db = Hour_queue.objects.get(username=username)
        except:
            return HttpResponseRedirect(REDIRECT_URL)
        if not request.user.is_staff and Trade_queue.objects.filter(username=username, stopped=False).exists():
            return HttpResponse('დაელოდეთ Trade ბუსტის დასრულებას ან გამორთეთ', status=202)
        # if user is trying to restart other user's boost, redirect them unless they're staff member
        if request.user.username == db.user or request.user.is_staff:
            db.stopped = False
            db.finished = False
            db.errlog = ''
            db.authcode = encode(BOOST_ENCRYPTION_KEY, authcode)
            db.save()
            return HttpResponse('განახლდა' if request.LANGUAGE_CODE == 'ka' else 'success')
    return HttpResponseRedirect(REDIRECT_URL)
Пример #2
0
def _escape_key():
    if not utils.is_running("Safari"): return
    cmd = """
    tell application "Safari"
        activate
        tell application "System Events" to key code 53
    end tell
    """ % locals()
    utils.execute_as(cmd)
Пример #3
0
def _safari_reload():
    if not utils.is_running("Safari"): return
    cmd = """
    tell application "Safari"
        activate
        tell application "System Events" to (keystroke "r" using {command down})
    end tell
    """ % locals()
    utils.execute_as(cmd)
Пример #4
0
def _safari_reload():
    if not utils.is_running("Safari"): return
    cmd = """
    tell application "Safari"
        activate
        tell application "System Events" to (keystroke "r" using {command down})
    end tell
    """ % locals()
    utils.execute_as(cmd)
Пример #5
0
def _escape_key():
    if not utils.is_running("Safari"): return
    cmd = """
    tell application "Safari"
        activate
        tell application "System Events" to key code 53
    end tell
    """ % locals()
    utils.execute_as(cmd)
Пример #6
0
def _fourod_fullscreen():
    if not utils.is_running("Safari"): return
    width, height = utils.screen_size()
    cmd = """
    tell application "Safari" 
        activate
        set bounds of window 1 to {0, 22, 1000, 8000}
    end tell
    """ % locals()

    # These need to be done synchronously
    utils.execute_as_async(cmd)
    sleep(0.5)
    mouseclick(850, 700)
Пример #7
0
def _fourod_pg_accept():
    if not utils.is_running("Safari"): return
    width, height = utils.screen_size()
    #cmd = """
    #tell application "Safari" 
        #activate
        #set bounds of window 1 to {0, 22, 1000, 8000}
    #end tell
    #""" % locals()

    ## These need to be done synchronously
    #utils.execute_as_async(cmd)
    #sleep(0.5)
    mouseclick(width * 0.40, height * 0.59)
Пример #8
0
    def _TerminateProcess(self, pid, timeout):
        """Helper function to terminate a process, given the pid

        Args:
            pid: integer process id of the process to terminate.
        """
        ret = ''
        try:
            for sig in ('SIGTERM', 'SIGKILL'):
                if utils.is_running(pid, psarg='-Acj'):
                    os.kill(pid, getattr(signal, sig))
                    time.sleep(timeout)
                    ret = 'killed with %s' % sig
        except OSError, (errno, strerror):
            print 'WARNING: failed os.kill: %s : %s' % (errno, strerror)
Пример #9
0
    def TerminateProcess(self, pid, timeout):
        """Helper function to terminate a process, given the pid

        Args:
            pid: integer process id of the process to terminate.
        """
        ret = ''
        try:
            for sig in ('SIGABRT', 'SIGTERM', 'SIGKILL'):
                if utils.is_running(pid):
                    os.kill(pid, getattr(signal, sig))
                    time.sleep(timeout)
                    ret = 'killed with %s' % sig
        except OSError, (errno, strerror):
            print 'WARNING: failed os.kill: %s : %s' % (errno, strerror)
Пример #10
0
def help_search(google_api, action, api_key, lga_dict, entity, state=''):

    state_data = []

    is_running(get_state)

    state_data += get_state(google_api, action, api_key, entity, state)

    is_running(get_state_lga)

    state_data = get_state_lga(lga_dict, google_api, action, api_key, entity,
                               state_data, state)

    is_running(get_lga)

    state_data = get_lga(lga_dict, google_api, action, api_key, entity,
                         state_data, state)
    print(f'We found {len(state_data)} results for {state}')

    return state_data
Пример #11
0
def _fourod_pauseplay():
    if not utils.is_running("Safari"): return
    width, height = utils.screen_size()
    mouseclick(30, height-50)
    sleep(1)
    mousemove(300,100)
Пример #12
0
def boost(request, action):
    user = request.user
    if request.method != 'POST':
        raise Http404
    if user.gems > 0 and not user.is_staff:
        if request.LANGUAGE_CODE == 'ka':
            return HttpResponse('ბუსტის ჩართვამდე საჭიროა დარჩენილი %s Gem-ის დაბრუნება (მთავარი გვერდიდან)' % user.gems)
        else:
            return HttpResponse('You need to return %s gem (from main page) before starting boost' % user.gems)
    try:
        if action == 'hour':
            if not is_running('HourBoost.py'):
                return HttpResponse('ბუსტი ჩართული არაა')

            if not WebSettings.hboost_enabled and not request.user.is_staff:
                return HttpResponse('ბუსტი დროებით გათიშულია' if request.LANGUAGE_CODE == 'ka' else 'boost temporarily disabled')
            form = h_boost_form(request.POST)
            if not form.is_valid():
                return HttpResponse('მონაცემები არასწორია' if request.LANGUAGE_CODE == 'ka' else 'Invalid input', status=400)
            time = str(datetime.datetime.now())
            username = form.cleaned_data['steam_username'].replace(
                ' ', '').lower()
            if Hour_queue.objects.filter(username=username).exists():
                return HttpResponse('ბუსტი უკვე ჩართულია' if request.LANGUAGE_CODE == 'ka' else 'boost is already started', status=202)
            if Trade_queue.objects.filter(username=username, stopped=False).exists():
                return HttpResponse('დაელოდეთ Trade ბუსტის დასრულებას ან გამორთეთ' if request.LANGUAGE_CODE == 'ka' else 'Trade boost already started, wait until it\'s finished or cancel it', status=202)
            password = form.cleaned_data['steam_password']
            authcode = form.cleaned_data['auth_code']
            boost_time = form.cleaned_data['boost_time']
            games = form.cleaned_data['games_id']
            free = form.cleaned_data['free']
            try:
                for x in games.split('-'):
                    int(x)  # raises error if x is string
                if len(games.split('-')) > 30:
                    return HttpResponse('თამაშების სია 30-ზე მეტია' if request.LANGUAGE_CODE == 'ka' else 'you can\'t boost more than 30 games at the same time')
            except:
                return HttpResponse('თამაშების სია არასწორია')
            total_price = WebSettings.h_boost_price * boost_time
            if user.credits >= total_price or user.is_superuser or free:
                if not user.is_superuser:
                    if not free:
                        user.credits -= round(total_price, 2)
                        user.save()
                link = Hour_queue.objects.create(user=user.username, username=username, password=encode(
                    BOOST_ENCRYPTION_KEY, password), authcode=encode(BOOST_ENCRYPTION_KEY, authcode), target_time=boost_time, games=games, free=free)
                Logs.objects.create(user=user, type='hour_boost', time=time, details=f'{username} | {boost_time} | {games}', change=-total_price, link=link.id)
                return HttpResponse("ბუსტი ჩაირთო" if request.LANGUAGE_CODE == 'ka' else 'boost started')
            else:
                return HttpResponse("თქვენ არ გაქვთ საკმარისი თანხა" if request.LANGUAGE_CODE == 'ka' else 'insufficient funds')
        elif action == 'comment':
            if not WebSettings.cboost_enabled and not request.user.is_staff:
                return HttpResponse('ბუსტი დროებით გათიშულია' if request.LANGUAGE_CODE == 'ka' else 'boost temporarily disabled')
            form = c_boost_form(request.POST)
            if not form.is_valid():
                return HttpResponse('მონაცემები არასწორია' if request.LANGUAGE_CODE == 'ka' else 'Invalid input', status=400)
            amount = form.cleaned_data['comment_amount']
            time = datetime.datetime.now()
            if amount == 6:
                free = True
                if not user.freeCommentAvailable:
                    return HttpResponseRedirect(REDIRECT_URL)
            else:
                free = False
                amount = round(amount, -2)
                if amount == 0:
                    return HttpResponse('რაოდენობა არასწორია' if request.LANGUAGE_CODE == 'ka' else 'Invalid amount')
            delay = form.cleaned_data['delay']
            if delay == '' or delay is None:
                delay = 0
            comment = form.cleaned_data['comment']
            if comment == '' or comment is None:
                comment = None
            steam64id = user.username
            if Comment_queue.objects.filter(steam64id=steam64id).exists():
                return HttpResponse('ბუსტი უკვე ჩართულია' if request.LANGUAGE_CODE == 'ka' else 'Boost already started', status=202)
            total_price = round(amount, -2) * (WebSettings.c_boost_price / 100)
            if user.balance >= total_price or user.is_superuser or free:
                if not user.is_superuser and not free:
                    user.balance -= round(total_price, 2)
                if free:
                    user.freeCommentAvailable = False
                req = requests.get(
                    'https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&format=json&steamids=%s' % (apiKey, user.username)).json()
                if not 'commentpermission' in req['response']['players'][0] or not req['response']['players'][0]['commentpermission']:
                    return HttpResponse('თქვენი პროფილი არის private, შეცვალეთ და ახლიდან ჩართეთ ბუსტი')
                user.save()
                db = Comment_queue.objects.create(
                    steam64id=steam64id, delay=delay, comment=comment, amount=amount, time=time, commented='', returned='')
                Logs.objects.create(user=user, type='comment_boost', time=time, details='%s(%s)' % (
                    comment, amount), change=-total_price)
                if not free:
                    commentList = 'https://steamboost.ge/commentlist' if db.comment is None else 'wait for custom list in discord'
                    msg = 'https://steamcommunity.com/profiles/%s (%s)' % (
                        db.steam64id, commentList)
                    amount_of_keys = int(amount/100)
                    Thread(target=send_keys_to_dealer,
                           args=(amount_of_keys, msg)).start()
                return HttpResponse("ბუსტი დაიწყება უახლოეს 24 საათში" if request.LANGUAGE_CODE == 'ka' else 'Boost may take up to 24 hours')
            else:
                return HttpResponse("თქვენ არ გაქვთ საკმარისი თანხა")
        elif action == 'trade':
            if not is_running('TradeBoost.py'):
                return HttpResponse('ბუსტი ჩართული არაა')
            if not WebSettings.tboost_enabled and not request.user.is_staff:
                return HttpResponse('ბუსტი დროებით გათიშულია' if request.LANGUAGE_CODE == 'ka' else 'boost temporarily disabled')

            form = t_boost_form(request.POST)
            if not form.is_valid():
                return HttpResponse('მონაცემები არასწორია ან ბუსტი ნაკლებია/მეტია მინიმუმზე/მაქსიმუმზე', status=202)
            username = form.cleaned_data['steam_username'].replace(
                ' ', '').lower()
            if Trade_queue.objects.filter(username=username).exists():
                return HttpResponse("ბუსტი უკვე ჩართულია" if request.LANGUAGE_CODE == 'ka' else 'Boost already started', status=202)
            if Hour_queue.objects.filter(username=username, stopped=False).exists():
                return HttpResponse('დაელოდეთ hour ბუსტის დასრულებას ან გამორთეთ' if request.LANGUAGE_CODE == 'ka' else 'wait until hour boost is finished or cancel it', status=202)
            password = form.cleaned_data['steam_password']
            authcode = form.cleaned_data['authcode'].replace(' ', '')
            identity_secret = form.cleaned_data['identity_secret'].replace(
                ' ', '')
            shared_secret = form.cleaned_data['shared_secret'].replace(' ', '')
            trade_amount = form.cleaned_data['trade_amount']
            free = False
            if trade_amount == 250:
                if user.freeTradeAvailable:
                    if not check_lvl(user.username):
                        return HttpResponse('ფეიკ აქაუნთების თავიდან ასაცილებლად საჭიროა სტიმზე გქონდეთ 6 ლეველზე მეტი' if request.LANGUAGE_CODE == 'ka' else 'you need to be at least 6 level to use free boost')
                    user.freeTradeAvailable = False
                    free = True
                else:
                    return HttpResponse('უფასო 250 უკვე გამოყენებულია')
            else:
                if trade_amount < 1000:
                    return HttpResponse('მინიმუმი 1000 თრეიდია' if request.LANGUAGE_CODE == 'ka' else 'Minimum amount is 1000')
            total_price = WebSettings.t_boost_price * (trade_amount / 1000)
            if trade_amount >= 10000:  # if more than 10k, calculate discount
                discount = (trade_amount // 10000) * 10
                total_price -= (discount * ((trade_amount / 1000)
                                            * WebSettings.t_boost_price)) / 100
            if not user.is_superuser and not free and user.balance < total_price and user.credits < total_price:
                return HttpResponse("თქვენ არ გაქვთ საკმარისი თანხა" if request.LANGUAGE_CODE == 'ka' else 'insufficient funds')
            if not free and not user.is_superuser:
                if user.credits >= total_price:
                    user.credits -= round(total_price, 2)
                else:
                    user.balance -= round(total_price, 2)
            if authcode == '':
                link = Trade_queue.objects.create(user=user.username, username=username, password=encode(BOOST_ENCRYPTION_KEY, password), shared_secret=encode(
                    BOOST_ENCRYPTION_KEY, shared_secret), identity_secret=encode(BOOST_ENCRYPTION_KEY, identity_secret), amount=trade_amount, one_way_trade=False)
            else:
                link = Trade_queue.objects.create(user=user.username, username=username, password=encode(
                    BOOST_ENCRYPTION_KEY, password), authcode=encode(BOOST_ENCRYPTION_KEY, authcode), amount=trade_amount, one_way_trade=True)
                if not free:
                    user.gems += trade_amount
            user.save()
            Logs.objects.create(user=user.username, type='trade_boost', time=datetime.datetime.now(
            ), details='%s - %s' % (username, trade_amount), change=-total_price if not free else 0, link=link.id)
            message = 'ბუსტი ჩაირთო, ' if request.LANGUAGE_CODE == 'ka' else 'boost started, '
            if free or authcode == '':
                message += 'ამ შემთხვევაში gem-ების დაბრუნება საჭირო არაა' if request.LANGUAGE_CODE == 'ka' else 'no need to return gems for free boost'
            else:
                if request.LANGUAGE_CODE == 'ka':
                    message += 'დასრულების შემდეგ დააბრუნეთ %s gem მთავარი გვერდიდან' % trade_amount
                else:
                    message += 'return %s gem from main page after completing boost' % trade_amount
            return HttpResponse(message)
        elif action == 'artwork':
            if not WebSettings.aboost_enabled and not request.user.is_staff:
                return HttpResponse('ბუსტი დროებით გათიშულია' if request.LANGUAGE_CODE == 'ka' else 'boost temporarily disabled')
            form = a_boost_form(request.POST)
            if not form.is_valid():
                return HttpResponse('მონაცემები არასწორია' if request.LANGUAGE_CODE == 'ka' else 'Invalid input', status=400)
            link = form.cleaned_data['sharedID']
            if Artwork.objects.filter(sharedID=link).exists():
                return HttpResponse('ბუსტი უკვე ჩართულია' if request.LANGUAGE_CODE == 'ka' else 'Boost already started')
            try:
                sharedID = int(link.split('id=')[1])
            except:
                return HttpResponse('არტვორკის ლინკი არასწორია' if request.LANGUAGE_CODE == 'ka' else 'invalid artwork link')
            likeAmount = form.cleaned_data['likeAmount']
            favAmount = form.cleaned_data['favAmount']
            if likeAmount == 10 and favAmount == 10:
                free = True
                if not user.freeArtworkAvailable:
                    return HttpResponseRedirect(REDIRECT_URL)
            else:
                free = False
                likeAmount = 250 * round(likeAmount/250)
                favAmount = 250 * round(favAmount/250)
            total_price = (round(favAmount/250) +
                           round(likeAmount/250)) * WebSettings.a_boost_price
            time = datetime.datetime.now()
            if user.balance < total_price and not user.is_superuser and not free:
                return HttpResponse("თქვენ არ გაქვთ საკმარისი თანხა" if request.LANGUAGE_CODE == 'ka' else 'insufficient funds')
            if not user.is_superuser and not free:
                user.balance -= round(total_price, 2)
            if free:
                user.freeArtworkAvailable = False
            user.save()
            Artwork.objects.create(
                user=user.username, sharedID=link, likeAmount=likeAmount, favAmount=favAmount)
            Logs.objects.create(user=user, type='artwork_boost', time=time, details='%s (%s | %s)' % (
                sharedID, likeAmount, favAmount), change=-total_price)
            if not free:
                msg = 'https://steamcommunity.com/sharedfiles/filedetails/?id=%s (like - %s | fav - %s)' % (
                    sharedID, likeAmount, favAmount)
                keys = int(total_price/WebSettings.a_boost_price)
                Thread(target=send_keys_to_dealer, args=(keys, msg)).start()
            return HttpResponse("ბუსტი დაიწყება უახლოეს 24 საათში" if request.LANGUAGE_CODE == 'ka' else 'Boost may take up to 24 hours')
        else:
            return HttpResponseRedirect('/boost')
    except:
        Notifications.objects.create(to=user.username, sender='System', time=datetime.datetime.now(), message=f'დაფიქსირდა შეცდომა, დაგვიკავშირდით <a href="{DISCORD_INVITE}" target="_blank" style="color: red">დისქორდზე</a>', cause=str(exceptionTraceback()))
        return HttpResponse(f'დაფიქსირდა შეცდომა, დაგვიკავშირდით <a href="{DISCORD_INVITE}" target="_blank" style="color: red">დისქორდზე</a> (500)', status=500)