-1

I'm trying to write a Python script that does something with the inputs from the IRC chat that is connected to twitch.

However, when I do import hexchat, python keeps telling me there is no module named hexchat. I'm using Pycharm btw. I just want to be able to use the functionality in the hexchat module. Any help would be appreciated!

JJGong
  • 129
  • 2
  • 11

3 Answers3

0

You need to first download and install Hex Chat module from here Downloads and then do the import hexchat.

For Linux - sudo apt-get install hexchat

Documentation for Python API is here Documentation

python
  • 4,403
  • 13
  • 56
  • 103
0

You load scripts inside hexchat. Window > Plugins and Scripts > Load.

TingPing
  • 2,129
  • 1
  • 12
  • 15
  • How can I load a script if I can't import hexchat in the first place to write my script to begin with? Sorry, I'm utterly confused, am I missing something? – JJGong Jan 08 '16 at 19:13
  • When hexchat loads the script it provides the module. – TingPing Jan 09 '16 at 19:42
  • 1
    Hi, I tried it but I get this error: "Unknown file type C:\Users\Yicheng Gong\Desktop\twitch\irc_script.py. Maybe you need to install the Perl or Python plugin? Usage: LOAD [-e] , loads a plugin or script" How exactly do you download the Python Plugin? I went to https://hexchat.github.io/downloads.html, downloaded Hexchat 2.10.2, Python 2.7.10 for scripts, and even source. and this is inside the script(just for testing for now): import hexchat __module_name__ = "helloworld" __module_version__ = "1.0" __module_description__ = "Python module example" hexchat.prnt("Hi everyone!") – JJGong Jan 10 '16 at 01:36
  • The Python plugin is an install option in HexChat's installer. – TingPing Jan 10 '16 at 10:51
  • Hi TingPing, thanks I was able to load the script, but my python interpreter still can't find the module. Is this suppose to happen? It says can't find hexchat module, but I can load in a simple script that says hi to the chat and it works – JJGong Jan 12 '16 at 05:50
  • Yes, only hexchat has the module, it is internal. – TingPing Jan 12 '16 at 11:52
0

I was having this issue on Windows 10 but I managed to resolve it by loading .py scripts in Hexchat like the below:

/py load "C:\where\your\file\is.py"

You also want to have module info in your .py file too otherwise Hexchat will complain:

__module_name__ = "helloworld"
__module_version__ = "1.0"
__module_description__ = "Python module example"
N00b Pr0grammer
  • 4,503
  • 5
  • 32
  • 46
IO_Madness
  • 11
  • 1