async def on_command_error(self, ctx, e): try: if isinstance(e, commands.CommandOnCooldown): if ctx.command.name == "mine": if await self.db.fetch_item( ctx.author.id, "Efficiency I Book") is not None: e.retry_after -= 0.5 if "haste ii potion" in self.v.chuggers.get( ctx.author.id, []): e.retry_after -= 1 elif "haste i potion" in self.v.chuggers.get( ctx.author.id, []): e.retry_after -= 0.5 seconds = round(e.retry_after, 2) if seconds <= 0.05: await ctx.reinvoke() return time = cooldown_logic(ctx, seconds) await self.bot.send( ctx, random.choice(ctx.l.misc.cooldown_msgs).format(time)) else: await asyncio.gather(*handle_error(self, ctx, e)) except discord.errors.Forbidden: pass except BaseException as e: if not isinstance(getattr(e, "original", None), discord.errors.Forbidden): await self.debug_error(ctx, e)
def profile(request): user = request.user error = request.GET.get('error', None) if request.method=='POST': try: user.skype_name = request.POST.get('skype_name') user.first_name = request.POST.get('first_name') user.last_name = request.POST.get('last_name') if (request.FILES.get('picture')): print "trying to update picture" user.picture = request.FILES['picture'] print request.FILES['picture'] user.save(); return redirect(reverse('home')) except IntegrityError: handle_error('profile', 'invalid_profile') return render(request, 'users/profile.html', {"error": string_for(error)})
def activate(request, activation_UUID): try: user = User.objects.get(activation_UUID = activation_UUID) print activation_UUID user.is_active = True user.save() return redirect('home') except: error = "invalid_activation_url" return handle_error('login', error)
def signup(request): password = request.POST.get('user[password]') email = request.POST.get('user[email]') skype_name = request.POST.get('user[skypename]') try: User.objects.create_user(email=email,password=password, skype_name=skype_name) user = authenticate(email=email, password=password) login(request, user) return redirect('home') except IntegrityError: return handle_error('login', "user_exists")