示例#1
0
def send_code(request):
    """
    kug;i;oig;oig
    :param ede
    :params ede
    :parameter edwede
    """

    # refresh = RefreshToken.for_user(user)
    code = random.randint(100000, 999999)
    time = datetime.datetime.now()
    mobile = request.data['mobile']
    check_existense = User.objects.filter(mobile=mobile)
    if check_existense.count() == 0:
        user = User.objects.create(is_active=False,
                                   mobile=request.data['mobile'],
                                   username=request.data['mobile'],
                                   tracking_code=code,
                                   registration_date=time)
        sms = ghasedak.Ghasedak("erfreferferfrefre")
        sms_content = u'Your X Registration Code is ' + str(code)
        sms.send({
            'message': sms_content,
            'receptor': mobile,
            'linenumber': 'x',
            'senddate': '',
            'checkid': ''
        })

        test_content = {
            'status_code': '200',
            'data_code': '2120',
            'data': code,
        }
        content = {'message': 'Hello, World! from X api'}
        # return Response('kthdkyt')
        # return JsonResponse(user1, safe=False)
        return JsonResponse(test_content, status=200)
    elif check_existense.count() > 0:
        u = check_existense.first()
        u.tracking_code = code
        u.save()
        sms = ghasedak.Ghasedak("evetftef")
        sms_content = u'Your X Registration Code is ' + str(code)
        sms.send({
            'message': sms_content,
            'receptor': mobile,
            'linenumber': 'x',
            'senddate': '',
            'checkid': ''
        })

        content = {
            'status_code': '200',
            'data_code': '2120',
            'data': code,
        }
        # return JsonResponse(user1, safe=False)
        return JsonResponse(content, status=200)
def sendSMS(name):
    sms = ghasedak.Ghasedak(
        "4f6ea7feb088eddeef32735843ca31864b6d44c4fcb0a9911a0d6cb952c45e69")
    sms.send({
        'message': name + 'یک پیام روی سابت برات گذاشت',
        'receptor': "09154860551",
        'linenumber': "10008566"
    })
示例#3
0
 def get(self, request, user_slug):
     sms = ghasedak.Ghasedak("a4405434b82dd6d46e4a88f0ef89d0d71c190265c87e8f883e34e73fe5ef8799")
     user = get_object_or_404(User, slug=user_slug)
     time_otp = pyotp.TOTP(user.key, interval=120)
     time_otp = time_otp.now()
     print(time_otp)
     sms.send(
         {'message': " Your verification code is " + time_otp, 'receptor': user.phone_number,
          'linenumber': "10008566"})
     return redirect(reverse('mobile_verify', args=(user.slug,)))
 def get(self, request, slug):
     user = User.objects.get(slug=slug)
     totp_obj = TOTPVerification(user.key)
     generated_token = totp_obj.generate_token()
     sms = ghasedak.Ghasedak("Your_API_code_is_given_by_Ghasedak")
     sms.send(
         {'message': f"{generated_token}", 'receptor': "user's mobile",
          'linenumber': "10008566"})
     # sms.send(
     #     {'message': f"Payamgram Activation code: {generated_token}", 'receptor': f"0{user.mobile[3:]}",
     #      'linenumber': "10008566"})
     return render(request, 'user/acc_active_sms.html', {'user': user})
def sms_sender(from_c, send_to):
    sms = ghasedak.Ghasedak(
        "a953ba30854130502559586ca6b93e0f81de604661d4bd0ec858e162330f8a76")
    sms.send({
        'message':
        str(from_c) +
        ' invited you to chat on PyChat.\n\nYou can download PyChat with the link below : \n\n'
        + "http://8upload.ir/uploads/f74418985.zip",
        'receptor':
        str(send_to),
        'linenumber':
        '10008566'
    })
示例#6
0
    def post(self, request):
        if request.method == 'POST':
            form = RegisterUserForm(request.POST, request.FILES)
            if form.is_valid():
                user = form.save(commit=False)
                user.is_active = False

                if form.cleaned_data['phone'] == None:
                    user.username = form.cleaned_data['email']
                    user.save()
                    """path to view
                                                            -getting domain we are on 
                                                            -relative url to verification
                                                            -encode uid
                                                            -token 
                                                              """
                    uidb64 = urlsafe_base64_encode(force_bytes(user.pk))

                    domain = get_current_site(request).domain
                    link = reverse('activate', kwargs={
                        'uidb64': uidb64, 'token': token_genarator.make_token(user)}
                                   )
                    activate_url = 'http://' + domain + link
                    email_body = 'Hi please use this link to verify your account\n\n' + activate_url
                    email_subject = 'Activate your account'
                    email = form.cleaned_data.get('email')
                    email = EmailMessage(
                        email_subject, email_body, to=[email]
                    )
                    email.send()
                    return HttpResponse('Please confirm your email address to complete the registration')

                else:
                    user.username = form.cleaned_data['phone']
                    token = randint(100, 999)
                    user.sms_verify = token
                    user.save()
                    sms = ghasedak.Ghasedak("")
                    sms.send({'message': "Use " + str(token) + " to verify your account.",
                              'receptor': form.cleaned_data['phone'],
                              'linenumber': "10008566"})
                    return redirect('sms', pk=user.id)
            else:
                message = 'You must enter a valid email or phone number!'
                return render(request, 'registration/register_user.html', {'form': form, 'message': message})
        else:
            form = RegisterUserForm()
            return render(request, 'registration/register_user.html', {'form': form})
示例#7
0
def dddddddd(request):
    """
    kug;i;oig;oig
    """

    # msg = EmailMultiAlternatives("Subject", "text body",
    #                              "*****@*****.**", ["*****@*****.**","*****@*****.**"])
    # msg.attach_alternative("<html>html body from X </html>", "text/html")
    # # you can set any other options on msg here, then...
    # msg.send()
    sms = ghasedak.Ghasedak("drefrf")

    sms.send({
        'message': 'Hello, World! from X api',
        'receptor': 'Xnum',
        'linenumber': 'x',
        'senddate': '',
        'checkid': ''
    })

    content = {'message': 'Hello, World! from X api'}
    # return Response(content)
    return JsonResponse(content)
示例#8
0
import ghasedak
from flask import Flask
from scraper import eachCountry
import os

app = Flask(__name__)
sms = ghasedak.Ghasedak(os.environ.get('SMS_API_KEY', ' '))


@app.route('/stats/<country>')
def getCountryStats(country):
    """Return the statistics of each country.
    """
    countryStats = eachCountry(country)
    sms.send({
        'message': countryStat['Deaths'],
        'receptor': '09056368477',
        'linenumber': '10008566'
    })
    return 'SMS sent.'