There is a guide to converting bot scripts from version 1 of the Pywikibot framework called trunk or compat to the new version 3+, so called rewrite or core. Refer compat-to-core conversion Manual for further instructions.
There is also a helper script which does a lot of changes automatically. Just call it:
pwb.py update_script [<script to convert>]
and follow the instructions and hints.
Ask at compat to core support request for any Pywikibot compat to core migration support.