Migration Guide#
From 1.0.x to 2.0#
DisCapTy has been created to be a supplementary tools for discord.py
, however, its owner had announced that this library would not be supported anymore. From here, many peoples has created forks of this library, which was making DisCapTy completely unusable for others library.
This thought has dragged me to think about what DisCapTy should be & become. As such, it has been decided that DisCapTy should NOT be related to discord.py
anymore but as a standalone library with no restriction on where it could be used.
The most important points are:
Deprecating generating Captcha in the
discapty.Captcha
class, but rather in adiscapty.Generator
subclass.Featuring
discapty.Challenge
&discapty.CaptchaQueue
.Added more specific errors to the library.
A documentation has been created.
Rewrite of Captcha class#
The discapty.Captcha
object does not longer generates the Captcha object anymore, what does is a generator.
There is no exact alternative to generates the Captcha object in the same place as the Captcha class, since now the Captcha class only include the Captcha object and its code.
However, you can do this:
Regarding diff block
The “-” represent the old version, the “+” represent the actual, new version.
--- /home/docs/checkouts/readthedocs.org/user_builds/discapty/checkouts/2.0/docs/source/docs/source/code_sample/captcha_object/captcha_object_20.old.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/discapty/checkouts/2.0/docs/source/docs/source/code_sample/captcha_object/captcha_object_20.py
@@ -1,7 +1,10 @@
import discapty
-captcha = discapty.Captcha("whezzy")
-captcha_object = captcha.generate_captcha()
+code = "My code"
+generator = discapty.WheezyGenerator()
+
+captcha_object = generator.generate(code)
+captcha = discapty.Captcha(code, captcha_object)
# Checking the code
-is_correct = captcha.verify_code(user_input)
+is_correct: bool = captcha.check(user_input)
Removal of .setup
function#
Along with the rewrite of the Captcha class, the .setup
function has been removed, instead, parameters can be provided to a generator when initializing a generator class.
--- /home/docs/checkouts/readthedocs.org/user_builds/discapty/checkouts/2.0/docs/source/docs/source/code_sample/generator_init/gen_init_20.old.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/discapty/checkouts/2.0/docs/source/docs/source/code_sample/generator_init/gen_init_20.py
@@ -1,4 +1,4 @@
import discapty
-captcha = discapty.Captcha("wheezy")
-captcha.setup(width=200, height=100)
+generator = discapty.WheezyGenerator(width=200, height=100)
+# Do the rest...
Added Challenge
class#
The discapty.Challenge
class is the new preferred way to create Captcha now. You can read more about challenges here: Introduction to Challenges - Creating a Challenge
To use Challenge
rather than the old Captcha
, you can do these changes:
--- /home/docs/checkouts/readthedocs.org/user_builds/discapty/checkouts/2.0/docs/source/docs/source/code_sample/captcha_to_challenge/c_to_c.old.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/discapty/checkouts/2.0/docs/source/docs/source/code_sample/captcha_to_challenge/c_to_c.py
@@ -1,9 +1,8 @@
-import discapty
+from discapty import Challenge, WheezyGenerator
-captcha = discapty.Captcha("whezzy")
-captcha.setup(width=200, height=100)
+challenge = Challenge(WheezyGenerator(width=200, height=100))
-captcha_object = captcha.generate_captcha()
+captcha_object = challenge.begin()
# Checking the code
-is_correct = captcha.verify_code(user_input)
+is_correct = challenge.check(user_input)