Closed LeoAlt8 closed 1 year ago
Thank you very much for pointing this out. The issue was related to a wrong order of loading the modules. I have fixed that and you can create configuration files now.
Furthermore, I have replaced the cross to make Willowbot more compatible with international character sets.
Kind regards, Weidengeist
Windows and Ubuntu
A fix for this issue has been uploaded right now.
"Twitch's authorization page for access tokens" - does not open
Windows and Ubuntu
Can you tell me which page to open?
There was some legacy code in one of the modules that required an oauth in the config file. However, those oauths have been externalized to the logins file, so it won’t be present in the config file anymore. I have removed the check for an oauth in the config file. The new version is up now.
I apologize for the inconvenience.
I deleted all files and did everything from the beginning.
The issue was that the bot tried to retrieve information that needs a valid oauth without having one. I have fixed that.
Can you fill it in manually?
The received data needs to be entered in logins.py?
Yes, indeed. You may put it into you logins.py
manually. I will fix the add routine some time later.
Does anything need to be changed in the file config.py
?
Only the default botname
should be adjusted. The other keys may keep their values. However, the botname
value can be overwritten by using --login [your bot account]
as Willowbot option.
And launching a bot (mine) on a friend's channel.
I'll cancel access by token for now, so that after you fix everything, I can check from the very beginning. OK?
Win11
The browser does not open. I can't check for Ubuntu right now.
This is a strange behaviour. Willowbot should at least establish a local server to provide a platform for the oauth token website integrated in Willowbot. Unfortunately, I cannot reproduce this issue on my Linux machine; I don’t have a Windows machine to test this. My guess is that some Windows 11 security measures prevent Willowbot from starting the server and a path variable for the default browser is missing so that Willowbot/Python does not know what the default browser is nor how to open it.
Please check this behaviour on other operating systems if you can and check both your path variable as well as maybe your firewall configuration. You need to allow localhost
on port 3000.
To test the webbrowser
module of your Python installation, you may try to start Python on your command line, do an import webbrowser
and open an arbitrary website by typing e.g. webbrowser.open("https://duckduckgo.com/")
. If this does not work either, the issue is probably not Willowbot-related.
To test the
webbrowser
module of your Python installation, you may try to start Python on your command line, do animport webbrowser
and open an arbitrary website by typing e.g.webbrowser.open("https://duckduckgo.com/")
. If this does not work either, the issue is probably not Willowbot-related.
This works for me. The search engine has opened. 🔼🔼🔼
Launched a bot on Ubuntu. I requested a token, the browser did not open, as on Windows.
Two more things you can here:
./modules
directory, you can find oauthTokenRedirectPage.html
. Try to open this page with your default browser. If this fails, there might be some incompatibility in the HTML code. If you have other browsers available, you may try those as well. An ungoogled Chromium browser and Firefox (latest version each) work for me.>>> import webbrowser
>>> webbrowser.open("/This/path/leads/to/Willowbot/modules/oauthTokenRedirectPage.html")
If both tests open your browser and the oauth template page appears, the next step would be checking how the Willowbot program flows in this section for your configuration.
2. If the test above succeeds for you, do the same in Python:
- Navigate to the Willowbot root directory. In the
./modules
directory, you can findoauthTokenRedirectPage.html
.
Please repeat step 2 and replace all backslashes (\
) with a slash (/
), as Python does not know backslashes without being used in escape sequences. Alternatively, you can precede your path to the HTML file with r
like this:
webbrowser.open(r"C:\Users\And\So\On\Willowbot\modules\oauthTokenRedirectPage.html")
The version mentioned first would be:
webbrowser.open("C:/Users/And/So/On/Willowbot/modules/oauthTokenRedirectPage.html")
A third syntax possibility is escaping the backslashes:
webbrowser.open("C:\\Users\\And\\So\\On\\Willowbot\\modules\\oauthTokenRedirectPage.html")
Here's what I opened. The same when opening the file manually.
If you need to do the same on Ubuntu, then I can only tomorrow.
Windows will suffice for now.
I have just updated the cliOptions.py
file so that it will output the target URL in the terminal so that it can be copied and pasted into the browser manually. If even the URL does not show for you, something must be quite off here.
Unfortunately it doesn't work for me. And the previous version of the bot will not work? Is it possible to return it? Or has twitch introduced some restrictions?
What exactly does not work for you? Is there no URL output when using Willowbot with the --token get
option? Which platforms have been tested?
A rollback would be possible, but it would strictly limit Willowbot’s capabilities. Twitch changed the API usage in February this year and externalized various formerly IRC commands to they own API endpoints. You can find a full list of the externalized commands in Twitch’s migration guide. It contains commands like /delete
, /ban
, /announce
, /shoutout
, and /timeout
. To use the commands of this new API endpoint, a new kind of access token is required. Without that, Willowbot is restricted to simply grab the messages and print a reaction – no auto-deletion, no auto-ban, only simple text messages. You can still generate tokens of the old generation and it will work with Willowbot, but those are close to worthless.
More interesting is the reason why your browser doesn’t show up while there are no issues on my side.
Is there no URL output when using Willowbot with the
--token get
option? Which platforms have been tested?
Yes, it doesn't open. Tried on Windows 11 and Ubuntu 22.04. And I do not have the necessary knowledge to find the cause. And I really like your bot. As far as I understand, testing on a VPS will not work, because you need a browser? And is it generally impossible to run on a VPS with access only through the console?
Willowbot should actually show you the URL from where you can retrieve the token in its most recent version. Doesn’t Willowbot do that? The message should look like this:
Trying to open
https://id.twitch.tv/oauth2/authorize?response_type=token&redirect_uri=http://localhost:3000&client_id=e5kdpgd2bbnbj1u5gbjpzeq7vsgwup&scope=channel_editor+channel_commercial+channel:manage:broadcast+channel:manage:moderators+channel:manage:vips+channel:manage:raids+channel:moderate+channel:read:redemptions+channel:read:subscriptions+chat:edit+chat:read+moderator:manage:announcements+moderator:manage:automod+moderator:manage:banned_users+moderator:manage:blocked_terms+moderator:manage:chat_messages+moderator:manage:chat_settings+moderator:manage:shoutouts+moderator:read:blocked_terms+user:manage:chat_color+user:manage:whispers+user:read:follows+whispers:edit+whispers:read
The URL is neither unique nor secret; you can just copy it from above to generate a token. But if you have the most recent Willowbot version and not even this URL shows up, the program does not flow as it should, which is pretty odd. Not showing the URL means that Willowbot runs in a completely unintended and unexpected way on your machine(s).
I have not tested Willowbot via a VPS, but you will need a local browser – at least for generating the token. However, the actual Willowbot usage can probably happen on a VPS.
Addendum: If you use this URL manually, the redirection will not work, as the Willowbot local server will not run to provide you its webpage. You will have to copy the resulting token from the redirection URL. It’s the hash parameter #access_token=
in the URL.
What OS, browser, version of Python are you using? I will install on a virtual machine and try it there.
I’m on a Linux machine, but the distribution should not matter, neither should the browser, as Python will choose the default one. I am testing Willowbot with Python 3.9.1. I am almost 100% sure that the issue is related to using the VPS.
You still haven’t answered the question if the URL shows up when you use Willowbot with the --token get
option.
Archive downloaded today.
You still haven’t answered the question if the URL shows up when you use Willowbot with the
--token get
option.
Win11
Ubuntu 22.04
I am almost 100% sure that the issue is related to using the VPS.
I didn't try to run it on a VPS.
Please try the following to find out where Willowbot leaves the expected behaviour. Replace the first 38 lines of your main_cli.py
(including tokenActions(CONFIG, LOGINS)
) with the following code:
import sys
# Subdirectories containing routines, class definitions and other important data.
sys.path.append('lang')
sys.path.append('modules')
sys.path.append('modules_opt')
# Load this module first to get the current language and to be able to shot the help info without having to load the actual config before.
from modules.cliOptions import *
print("1")
getLanguage(feedback = True)
print("2")
if '-h' in sys.argv or '--help' in sys.argv:
showHelp()
if '-cf' in sys.argv or '--configure' in sys.argv:
createConfigFiles()
# Load all the remaining modules.
from modules.basics import checkTimedCommands # Import various general functions from the basics(.py) module in ./modules.
print("3")
from modules.basics import getCommands
print("4")
from modules.basics import getConfig
print("5")
from modules.basics import getLogins
print("6")
from modules.irc import IRC # Import the IRC class from the irc(.py) module in ./modules.
# Suppress output in debug mode.
if inOneshotMode():
globalFeedback = False
else:
globalFeedback = True
print("7")
LOGINS = getLogins(feedback = globalFeedback) # Load all available login oauths.
print("8")
CONFIG = getConfig(feedback = globalFeedback) # Load configuration files.
print("9")
if '-t' in sys.argv or '--token' in sys.argv:
tokenActions(CONFIG, LOGINS)
print("10")
It is basically the same code as before, but some print
commands have been inserted to get feedback points. With the code replaced in your main_cli.py
, run Willowbot with --token get
again and post what it shows.
I replaced.
win11
ubuntu
Okay, we need further information, but I have a clue where I have to look. In line 32 of your new main_cli.py
, there is a block that contains globalFeedback
:
# Suppress output in debug mode.
if inOneshotMode():
globalFeedback = False
else:
globalFeedback = True
Comment everything in this line except for the last one and remove the indentation of the last line. It should look like this in the end (Python is indentation-sensitive):
# Suppress output in debug mode.
#if inOneshotMode():
# globalFeedback = False
#else:
globalFeedback = True
Run the --token get
option again and show me the output.
Is Windows enough for now?
There it is! It is a slight misconception in the default login and config files. I have updated the files now to fix this. You don’t have to download the most recent version immediately. You only have to change IHaveNoName
in your config.py
to IAmYourFirstBot
and your token creation will hopefully succeed.
Thank you very much for your patience to figure this out.
A page should have opened asking you to allow Twitch access?
Yes, indeed. Just authorize this and you will be redirected to your token page.
Edit: This step is documented in the initial setup section of the README.
This page immediately opened, and not with a request for permission ((
This means that you have logged in to a Twitch account in this browser before and the login has been saved to a session cookie of your browser. The token shown now is one for the account you have most recently logged in to.
I deleted everything and downloaded a new archive and did everything from the beginning.
Looks alright so far. However, you have to replace IAmYourFirstBot
in the config.py
file with your actual account name or start Willowbot with the --channel
and/or --login
option (see chapter 2 of the README).
EVERYTHING IS WORKING!!!! 🥰🤩🤪🕺
Great! I will have to streamline the initial setup process a bit more and update the README accordingly. I guess this issue can be closed now.
Could you please tell me how to transfer it to VPS Ubuntu server?
I am sorry. This is beyond my knowledge and not directly linked to Willowbot, so it shouldn’t be discussed here anyway.
I try different OS and everywhere the same answer. Maybe I'm doing something wrong?
Windows 11 + Python 3.9:![image](https://user-images.githubusercontent.com/92355871/229954981-8cf1351b-661b-4bcd-9996-fd1413c7a347.png)
Ubuntu 20.04 + Python 3.11:![image](https://user-images.githubusercontent.com/92355871/229955192-bba1ffe7-89a9-4bf7-8bf8-0fda23c86ac5.png)
Ubuntu 22.04 + Python 3.10:![image](https://user-images.githubusercontent.com/92355871/229955486-0ae38216-ead6-4a3d-b55e-5b78178a74f2.png)
Files are not created. Directories are not created.
P.S. There was another error "UnicodeEncodeError: 'latin-1' codec can't encode character '\u2573' in position 1: ordinal not in range(256)" Changed the cross to
➡️ ![image](https://user-images.githubusercontent.com/92355871/229956348-42c5ddfd-2b8d-4294-bab0-6fe96fb78413.png)
!
in file basics.py