Browse Source

Made script work with both 2.7 and 3

Teknikode 2 years ago
parent
commit
852ab65f5c
2 changed files with 20 additions and 11 deletions
  1. 4
    2
      Hexchat/README.md
  2. 16
    9
      Hexchat/teknik.py

+ 4
- 2
Hexchat/README.md View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 ### Installation
4 4
 
5
-* Make sure Hexchat is installed with the Python 3 plugin
5
+* Make sure Hexchat is installed with the Python plugin (both 2 and 3 supported)
6 6
 * Install the [teknik](https://git.teknik.io/Teknikode/Teknik-Python) module
7 7
   * `pip install teknik`
8 8
 * Copy the scripts to the 'addon' folder for Hexchat
@@ -10,4 +10,6 @@
10 10
 
11 11
 ### Usage
12 12
 
13
-To use it, simply type `/teknik` which will bring up a file dialog prompt.  Select the file you want to upload, and then once it's done, the generated link will be put into the input box of hexchat.
13
+To use it, simply type `/teknik upload` which will bring up a file dialog prompt.  Select the file you want to upload, and then once it's done, the generated link will be put into the input box of hexchat.
14
+
15
+You can also manually specify the file to upload as an argument, and set addon configuration settings.

+ 16
- 9
Hexchat/teknik.py View File

@@ -4,22 +4,29 @@ __module_description__ = "Interact with the Teknik Services, including file uplo
4 4
 
5 5
 import_success = True
6 6
 
7
-import tkinter as tk
8
-from tkinter.filedialog import askopenfilename
7
+try:
8
+  import Tkinter as tk
9
+except ImportError:
10
+  import tkinter as tk
11
+
12
+try:
13
+  from tkinter.filedialog import askopenfilename
14
+except ImportError:
15
+  from tkFileDialog import askopenfilename
9 16
 
10 17
 try:
11
-    import hexchat
18
+  import hexchat
12 19
 except ImportError:
13
-    print('This script must be run under Hexchat.')
14
-    print('Get Hexchat now at: https://hexchat.github.io/')
15
-    import_ok = False
20
+  print('This script must be run under Hexchat.')
21
+  print('Get Hexchat now at: https://hexchat.github.io/')
22
+  import_success = False
16 23
 
17 24
 # Requires Install
18 25
 try:
19
-    from teknik import uploads as teknik
26
+  from teknik import uploads as teknik
20 27
 except ImportError as e:
21
-    print('Missing package(s) for %s: %s' % (__module_name__, e))
22
-    import_ok = False
28
+  print('Missing package(s) for %s: %s' % (__module_name__, e))
29
+  import_success = False
23 30
 
24 31
 def teknik_prompt():
25 32
   # Prompt for a file

Loading…
Cancel
Save