Skip to content

Commit

Permalink
added OS detection for cool stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Ultrabenosaurus committed Feb 19, 2016
1 parent fbdbd25 commit 211f421
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
24 changes: 18 additions & 6 deletions EasyXdcc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
__module_name__ = "EasyXdcc"
__module_version__ = "1.1"
__module_version__ = "1.2"
__module_description__ = "Xdcc Queues"
__module_author__ = "Bouliere Tristan <[email protected]>"
import xchat, os, time, pprint
__module_contributor__ = "Ultrabenosaurus <https://github.com/Ultrabenosaurus/EasyXdcc>"
import xchat, os, time, pprint, platform

class t_bot:
def __init__(self, name, serv, chan):
Expand Down Expand Up @@ -431,22 +432,33 @@ def lauch_dl(userdata):
bot_context.command('msg '+getattr(bot, 'name')+' xdcc send #'+str(bot.pop()))
return 1

def check_dirs(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)

comp = platform.system()
my_hook = None
queue = bot_queue()

try:
cmd = os.popen("whoami")
try:
user = cmd.readlines()
user = user[0].strip("\n")
# comment the following line if you're not on Windows
user = user.split("\\")[1]
if 'Windows' == comp:
user = user.split("\\")[1]
finally:
cmd.close()
except IOError:
pass
#sav_file = "/home/"+user+"/.xchat2/EasyXdcc.queue" # use this line for Linux environments
sav_file = "C:/Users/"+user+"/AppData/Roaming/HexChat/addons/EasyXdcc.queue" # use this line for Windows Vista+ environments

if 'Windows' == comp:
sav_dir = "C:/Users/"+user+"/.config/EasyXdcc/"
else:
sav_dir = "/home/"+user+"/.config/EasyXdcc/"
check_dirs(sav_dir)
sav_file = sav_dir + "queue"

xchat.hook_command("XDCC", idx_EasyXdcc, help="/XDCC <cmd>")
xchat.command ("MENU -p5 ADD EasyXdcc")
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The original is by [Bouliere Tristan](mailto:[email protected]) and c

Simply copy `EasyXdcc.py` to your IRC client's plugins folder. Original version designed for XChat 2, my version is tested and working in HexChat 2.10.1. May or may not work in any other client.

Some lines near the bottom of the file need to be toggled depending on your OS, they are commented so check them before using.
~~Some lines near the bottom of the file need to be toggled depending on your OS, they are commented so check them before using.~~ OS detection is now in place to handle paths properly! Yay!

Confirm it is loaded and active in your client's plugin manager.

Expand All @@ -34,43 +34,43 @@ If it doesn't start downloading stuff for you automatically enter `/XDCC START`
```
Queue a pack :
/XDCC ADD [bot_name] [n°_pack]
Queue a pack list :
/XDCC ADDL [bot_name] [n°_pack_beg] [n°_pack_end]
Queue non-sequential pack list :
/XDCC ADDM [bot_name] [n°_pack_1] [n°_pack_2] [...]
See pack queue :
/XDCC QUEUE
See pack queue for a bot :
/XDCC QUEUE [bot_name]
Withdraw a pack from queue :
/XDCC RMP [bot_name] [n°pack]
Withdraw a pack list from queue :
/XDCC RMPL [bot_name] [n°pack_beg] [N°pack_end]
Withdraw a non-sequential pack list from queue :
/XDCC RMPM [bot_name] [n°_pack_1] [n°_pack_2] [...]
Withdraw a bot from queue :
/XDCC RMBOT [bot_name]
Stop EasyXdcc :
/XDCC STOP
Start EasyXdcc :
/XDCC START
Save Queue :
/XDCC SAVE
Load Queue :
/XDCC LOAD
Delete saved Queue file :
/XDCC PURGE
```

0 comments on commit 211f421

Please sign in to comment.