Skip to content

Instantly share code, notes, and snippets.

@oskopek
Last active May 19, 2019 09:35
Show Gist options
  • Save oskopek/8eec57762901f6017b26 to your computer and use it in GitHub Desktop.
Save oskopek/8eec57762901f6017b26 to your computer and use it in GitHub Desktop.
Xchat away script reloaded
#
# Away module for XChat.
#
# Author: Michal Prochowski <michal@prochowski.pl>
# Author: Ondrej Skopek <oskopek@oskopek.com>
# URL: http://github.com/mablo/xchat-scripts
#
# Copyright(c) 2012 Michal Prochowski
# Copyright(c) 2015 Ondrej Skopek
# License: MIT
#
# Installation:
# Copy script to ~/.config/xchat2/ directory (loads by default) or load module in XChat.
#
# Usage:
# /awayo - back
# /awayo suffix - away with suffix added to your nick
#
# Recommended: add hooks in Settings > Advanced > Keyboard Shortcuts
# For example: F6 - Run Command: /awayo away
# For example: F7 - Run Command: /awayo lunch
# For example: F8 - Run Command: /awayo
#
# Configuration:
delimeter = '_' # delimeter to add/remove suffixes from your nick
#
__module_name__ = 'Away script'
__module_version__ = '0.4'
__module_description__ = 'Away module'
import xchat
def is_away():
return None != xchat.get_info('away')
def find_nick_base(nickname):
delimeter_index = nickname.find(delimeter)
if delimeter_index == -1:
return nickname
else:
return nickname[0:delimeter_index]
def awayo(word, wordEol, userData):
nickname = xchat.get_info('nick')
base_nick = find_nick_base(nickname)
if len(word) == 1:
if is_away():
xchat.command('BACK')
if nickname != base_nick:
xchat.command('NICK ' + base_nick)
xchat.prnt('Back: ' + base_nick)
elif len(word) == 2:
reason = word[1]
future_nick = base_nick + delimeter + reason
if is_away():
if xchat.get_info('away') != reason:
xchat.command('AWAY ' + reason)
else:
xchat.command('AWAY ' + reason)
if nickname != future_nick:
xchat.command('NICK ' + future_nick)
xchat.prnt('Away: ' + future_nick)
else:
xchat.prnt('Invalid syntax: ' + wordEol[0])
return xchat.EAT_ALL
xchat.hook_command('awayo', awayo)
@dextro67
Copy link

Thanks for this script. I was really helpful when I was using xchat. I wish there was something similar for weechat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment