def main(): """ Entry point, initializes everything """ # Setup the translation table, mapping latin characters to their Unicode # fullwidth equivalents. global FW_TABLE FW_TABLE = dict(zip(range(0x21, 0x7F), range(0xFF01, 0xFF5F))) # Handle space specially. FW_TABLE[0x20] = 0x3000 weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", # Shutdown callback function "", # Charset (blank for utf-8) ) # Command callbacks weechat.hook_command( # command name "fw", # description "Translates latin characters to their fullwidth equivalents.", # arguments "text", # description of arguments " text: text to be full-width'd", # completions "", "fw_cb", "")
def register(): weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '') weechat.hook_print('', 'irc_332', '', 1, 'print_332', '') weechat.hook_print('', 'irc_topic', '', 1, 'print_topic', '') weechat.hook_signal('*,irc_in2_332', 'irc_in2_332', '') weechat.hook_signal('*,irc_in2_topic', 'irc_in2_topic', '')
def Register(): weechat.register(TRIV['register']['script_name'], TRIV['register']['author'], TRIV['register']['version'], TRIV['register']['license'], TRIV['register']['description'], TRIV['register']['shutdown_function'], TRIV['register']['charset'])
def main(): """ Entry point, initializes everything """ weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", # Shutdown callback function "", # Charset (blank for utf-8) ) # Default values for settings default_settings = { 'dbfile': os.path.join( weechat.info_get("weechat_dir", ""), "emojis-db.dat") } # Apply default configuration values if anything is unset for option, default in default_settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default) # Hook callbacks weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "configuration_cb", "") weechat.hook_command_run("/input return", "transform_cb", "") weechat.hook_command_run("/input complete*", "complete_cb", "") #weechat.hook_modifier("input_text_display", "collapse_cb", "") # Command callbacks weechat.hook_command( # command name SCRIPT_NAME, # description " display :common_name: with its emoji equivalent", # arguments "reload" " || add <name> <emoji>" " || show <emoji>", # description of arguments " name: emoji name, sans colons\n" "emoji: text that replaces :name:\n", # completions "reload || add || show %(emoji_name)", "emojis_cb", "") weechat.hook_completion("emoji_name", "Emoji name", "emoji_name_completion_cb", "") dbfile = weechat.config_get_plugin("dbfile") weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile)) try: load_emojis(dbfile) except IOError as e: weechat.prnt("", "%s%s: Database file %s is missing or inaccessible." \ % (weechat.prefix("error"), SCRIPT_NAME, dbfile)) raise e # TODO: handle this better instead of brutally aborting
def main(): """Main entry""" weechat.register(NAME, AUTHOR, VERSION, LICENSE, DESC, '', '') weechat.hook_completion('replacer_plugin', 'Try to match last word with ' 'those in replacement map keys, and replace it ' 'with value.', 'replace_cb', '') weechat.hook_completion('completion_cb', 'Complete replacement map keys', 'completion_cb', '') weechat.hook_command(COMMAND, DESC, "[add <word> <text>|del <word>]", __doc__ % {"command": COMMAND}, 'add|del %(completion_cb)', 'replace_cmd', '')
def __init__(self): ''' Creates the script instance and add hook, unfortunately it is not possible to use mathods as callbacks. ''' weechat.register("SystrayIcon", "Ziviani", "0.1", "GPLv2", "Systray icon for weechat.", "_shutdown_plugin", "") weechat.hook_print("", "irc_privmsg", "", 1, "_highlight_msg_cb", "")
def main(): """ Entry point, initializes everything """ weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESCRIPTION, "", # Shutdown callback function "", # Charset (blank for utf-8) ) # Default values for settings default_settings = { 'dbfile': os.path.join( weechat.info_get("weechat_dir", ""), "emojis-db.dat") } # Apply default configuration values if anything is unset for option, default in default_settings.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default) # Hook callbacks weechat.hook_config( "plugins.var.python." + SCRIPT_NAME + ".*", "configuration_cb", "") weechat.hook_command_run("/input return", "transform_cb", "") weechat.hook_command_run("/input complete*", "complete_cb", "") # Command callbacks weechat.hook_command( "reloademojis", "reload emojis from file", "", "", "", "reload_emojis_cb", "") dbfile = weechat.config_get_plugin("dbfile") weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile)) try: load_emojis(dbfile) except IOError as e: weechat.prnt( "", "%s%s: Database file %s is missing or inaccessible." % (weechat.prefix("error"), SCRIPT_NAME, dbfile)) raise e # TODO: handle this better instead of brutally aborting
def main(): if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): version = int(weechat.info_get("version_number", "")) or 0 # unset unused setting from older versions of script if weechat.config_is_set_plugin("display_unit"): weechat.prnt("", "Option plugins.var.python.bandwidth.display_unit no longer used, removing.") weechat.config_unset_plugin("display_unit") # set default settings for option in SCRIPT_SETTINGS.iterkeys(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, SCRIPT_SETTINGS[option][0]) if version >= 0x00030500: weechat.config_set_desc_plugin(option, SCRIPT_SETTINGS[option][1]) # ensure sane refresh_rate setting if int(weechat.config_get_plugin("refresh_rate")) < 1: weechat.prnt( "", "{}Invalid value for option plugins.var.python.bandwidth.refresh_rate, setting to default of {}".format( weechat.prefix("error"), SCRIPT_SETTINGS["refresh_rate"][0] ), ) weechat.config_set_plugin("refresh_rate", SCRIPT_SETTINGS["refresh_rate"][0]) # create the bandwidth monitor bar item weechat.bar_item_new("bandwidth", "bandwidth_item_cb", "") # update it every plugins.var.python.bandwidth.refresh_rate seconds weechat.hook_timer(int(weechat.config_get_plugin("refresh_rate")) * 1000, 0, 0, "bandwidth_timer_cb", "")
def main(): if not weechat.register("emote", "Keith Smiley", "1.0.0", "MIT", "Paste awesome unicode!", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("emote", "Paste awesome unicode!", "", "", "|".join(mappings.keys()), "emote", "")
def go_main(): """Entry point.""" if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, 'go_unload_script', ''): return weechat.hook_command( SCRIPT_COMMAND, 'Quick jump to buffers', '[term(s)]', 'term(s): directly jump to buffer matching the provided term(s) single' 'or space dilimited list (without argument, list is displayed)\n\n' 'You can bind command to a key, for example:\n' ' /key bind meta-g /go\n\n' 'You can use completion key (commonly Tab and shift-Tab) to select ' 'next/previous buffer in list.', '%(buffers_names)', 'go_cmd', '') # set default settings version = weechat.info_get('version_number', '') or 0 for option, value in SETTINGS.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, value[0]) if int(version) >= 0x00030500: weechat.config_set_desc_plugin( option, '%s (default: "%s")' % (value[1], value[0])) weechat.hook_info('go_running', 'Return "1" if go is running, otherwise "0"', '', 'go_info_running', '')
def main(): if not weechat.register("edit", "Keith Smiley", "1.0.0", "MIT", "Open your $EDITOR to compose a message", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("edit", "Open your $EDITOR to compose a message", "", "", "", "edit", "")
def main(): if not weechat.register("giphy", "Keith Smiley", "1.0.0", "MIT", "Insert a random giphy URL", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("giphy", "Insert a random giphy URL", "", "", "", "giphy", "")
def weechat_script(): settings = {"host": "localhost", "port": "4321", "icon": "utilities-terminal", "pm-icon": "emblem-favorite"} if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): for (kw, v) in settings.items(): if not w.config_get_plugin(kw): w.config_set_plugin(kw, v) w.hook_print("", "notify_message", "", 1, "on_msg", "") w.hook_print("", "notify_private", "", 1, "on_msg", "private") w.hook_print("", "notify_highlight", "", 1, "on_msg", "") # Not sure if this is needed
def main(): if not weechat.register("imgur", "Keith Smiley", "1.0.0", "MIT", "Upload an image to imgur", "", ""): return weechat.WEECHAT_RC_ERROR if not weechat.config_get_plugin(CLIENT_ID): weechat.config_set_plugin(CLIENT_ID, "Set imgur client ID") weechat.hook_command("imgur", "Pass the current buffer to urlview", "", "", "filename", "imgur", "")
def main(): if distutils.spawn.find_executable("urlview") is None: return weechat.WEECHAT_RC_ERROR if not weechat.register("urlview", "Keith Smiley", "1.0.2", "MIT", "Use urlview on the current buffer", "", ""): return weechat.WEECHAT_RC_ERROR weechat.hook_command("urlview", "Pass the current buffer to urlview", "", "", "", "urlview", "")
def main(): if not weechat.register("terminal_notifier", "Keith Smiley", "1.1.0", "MIT", "Get OS X notifications for messages", "", ""): return weechat.WEECHAT_RC_ERROR if distutils.spawn.find_executable("osascript") is None: return weechat.WEECHAT_RC_OK weechat.hook_signal("weechat_pv", "notify", "") weechat.hook_signal("weechat_highlight", "notify", "") return weechat.WEECHAT_RC_OK
def init(): ok = import_ok and weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "") if not ok: return # Set default settings for option, default_value in settings.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) return True
def main(): if weechat.register(Script.NAME, Script.AUTHOR, Script.VERSION, Script.LICENSE, Script.DESCRIPTION, "CallbackPluginUnloaded", ""): plugin.SetDefaultOptions() plugin.SetCommands() plugin.RegisterTimer("vk-auth", 60 * 1000, 60, 0, "CallbackVkAuth", "") ## TODO: look into how to make this callback co-exist with vk-fetch-updates ## plugin.RegisterTimer("vk-fetch-friends", 10 * 60 * 1000, 30, 0, "CallbackVkFetchFriends", "") plugin.RegisterTimer("vk-fetch-updates", 5 * 1000, 10, 0, "CallbackVkFetchUpdates", "") ## Do not wait for the timers to be triggered in 60s CallbackVkAuth(None, -1) CallbackVkFetchFriends(None, -1)
def main(): """Main""" if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC,'', ''): return for option, (default_value, description) in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) if description: weechat.config_set_desc_plugin(option, description) weechat.hook_command(SCRIPT_COMMAND, SCRIPT_DESC, '', '', '%(buffers_names)', 'np_cb', '')
def weechat_script(): settings = {'host' : "localhost", 'port' : "4321", 'icon' : "utilities-terminal", 'pm-icon' : "emblem-favorite", 'urgency_default' : 'critical', 'display_time_default' : '10000', 'display_time_highlight' : '30000', 'display_time_private_highlight' : '0'} if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): for (kw, v) in settings.items(): if not w.config_get_plugin(kw): w.config_set_plugin(kw, v) w.hook_print("", "notify_message", "", 1, "on_msg", "") w.hook_print("", "notify_private", "", 1, "on_msg", "private") w.hook_print("", "notify_highlight", "", 1, "on_msg", "") # Not sure if this is needed
def main_weechat(): """Main function, called only in WeeChat.""" if not weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): return theme_config_init() theme_config_read() theme_init() weechat.hook_command( SCRIPT_COMMAND, 'WeeChat theme manager', 'list [<text>] || info|show [<theme>] || install <theme>' ' || installfile <file> || update || undo || backup || save <file>' ' || restore || export [-white] <file>', ' list: list themes (search text if given)\n' ' info: show info about theme (without argument: for current ' 'theme)\n' ' show: show all options in theme (without argument: for ' 'current theme)\n' ' install: install a theme from repository\n' 'installfile: load theme from a file\n' ' update: download and unpack themes in themes directory\n' ' undo: undo last theme install\n' ' backup: backup current theme (by default in ' '~/.weechat/themes/_backup.theme); this is done the first time script ' 'is loaded\n' ' save: save current theme in a file\n' ' restore: restore theme backuped by script\n' ' export: save current theme as HTML in a file (with "-white": ' 'use white background in HTML)\n\n' 'Examples:\n' ' /' + SCRIPT_COMMAND + ' save /tmp/flashcode.theme => save current ' 'theme', 'list' ' || info %(filename)' ' || show %(filename)' ' || install %(themes)' ' || installfile %(filename)' ' || update' ' || undo' ' || save %(filename)' ' || backup' ' || restore' ' || export -white|%(filename) %(filename)', 'theme_cmd', '')
def init(self): if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): global SAVEPATH SAVEPATH = os.path.join(weechat.info_get('weechat_dir',''),'darktower','adfilter') if not os.path.exists(SAVEPATH): os.makedirs(SAVEPATH) self.saveFile = os.path.join(SAVEPATH,'adfilter.DT') self.exceptFile = os.path.join(SAVEPATH,'AFexceptions.DT') weechat.hook_command("adfilter", "Dark Tower AdFilter Commands", "[COMMANDS]", "[COMMANDS DETAIL]", "[COMPLETION]", "AdFilter", "command_cb:") weechat.hook_modifier("irc_in_PRIVMSG", "AdFilter","privmsg_event:") self.loadAds() self.loadExceptions()
def main(): if not weechat.register('hipchat', 'Joakim Recht <*****@*****.**>', '1.0', 'MIT', 'Hipchat utilities', '', ''): return rooms_set_default_settings() rooms_reset_stored_sort_order() get_token() weechat.hook_command( 'hipchat', 'Hipchat utilities', '[rooms | autojoin | whois <user> | fullnames | nicks [<pattern>]]', 'rooms: List rooms\nautojoin: List autojoin rooms\nwhois <user>: Get information ' 'about a specific user - either @mention or email\nfullnames: Force populate full ' 'names in nicklists in all channels\nnicks <pattern>: List users, optionally by pattern. ' 'Use * in pattern as wildcard match.\n', 'rooms|autojoin|whois|fullnames|nicks', 'hipchat_cmd', '') weechat.hook_completion('hipchat_mentions', 'Mentions', 'complete_mention', '') if weechat.config_get_plugin('enable_fullnames') == 'on': nicklist_download() weechat.hook_signal('nicklist_nick_added', 'update_fullname_join', '') weechat.hook_signal('hipchat_nicks_downloaded', 'show_nicks_cb', '')
def register(): global last_notification last_notification = 0 w.register('weepushover', 'adtac', '0.1', 'MIT', description, '', '')
import weechat import time import telegram bot = telegram.Bot(token='ADD YOUR TOKEN HERE') weechat.register("jackPing", "FlashCode", "1.0", "GPL3", "OH NO", "", "") weechat.prnt("", "Use without jack2 permition is not allowed") def i_am_author_of_message(buffer, nick): """Am I (the current WeeChat user) the author of the message?""" return weechat.buffer_get_string(buffer, 'localvar_nick') == nick def nick_that_sent_message(tags, prefix): for tag in tags: if tag.startswith('nick_'): return tag[5:] if prefix.startswith(('~', '&', '@', '%', '+', '-', ' ')): return prefix[1:] return prefix #process messages def message(data, bufferp, tm, tags, display, is_hilight, prefix, msg): nick = nick_that_sent_message(tags.split(','), prefix) if (is_hilight or weechat.buffer_get_string(bufferp, 'localvar_type') == 'private') and not(i_am_author_of_message(bufferp, nick)): mes = '<' + nick_that_sent_message(tags.split(','), prefix) + '>: ' +msg if weechat.buffer_get_string(bufferp, 'localvar_type') != 'private': mes = weechat.buffer_get_string(bufferp, 'short_name') + ': ' + mes bot.send_message(chat_id=SET CHAT ID, text=mes) return weechat.WEECHAT_RC_OK
# path to scripts scriptPath = "" # signal hook to catch path to scripts loadSigHook = None # file that stores all nick/key/addr # is it append # \todo replace with ENCRYPTED key/value store storeFile = None # stream processor stream = pss.Stream() # all weechat scripts must run this as first function weechat.register("pss", "lash", PSS_VERSION, "GPLv3", "single-node pss and swarm feeds chat", "pss_stop", "") # writes to weechat console # levels: # 1 = info # 2 = in # 3 = out # 255 = debug def wOut(level, oBufs, prefix, content): pfxString = "" if len(oBufs) == 0: oBufs = [""]
# Ported to Weechat 0.3.0 by: Sharn - <sharntehnub AT gmail DOT com) # And from: notifo_notify # Author: SAEKI Yoshiyasu <*****@*****.**> # Homepage: http://bitbucket.org/laclefyoshi/weechat/ # This plugin send push notifications to your iPhone or Android smartphone # by using Notifo.com mobile application/services # Requires Weechat 1.0.0 # Released under GNU GPL v2 # # 2017-03-27, Francisco Jordano <*****@*****.**> # version 0.1: send web push notifications. It will use vapi and or gcm, which data # will need to be provided via configuration object. import weechat, string, urllib, urllib2, json weechat.register("webpush", "francisco.jordano", "0.1", "GPL", "webpush: Send webpush notifications about your private messages and highlights.", "", "") configuration = { "endpoint": "", "key": "", "authSecret": "", "webpushProxy": "", "vapidPublicKey": "", "vapidPrivateKey": "", "vapidSubject": "" } for option, default_value in configuration.items(): if weechat.config_get_plugin(option) == "": weechat.prnt("", weechat.prefix("error") + "webpush: Please set option: %s" % option) weechat.prnt("", "webpush: /set plugins.var.python.webpush.%s STRING" % option)
for e in v['Entries']: if e['Buffer'] != None: message = unicodedata.normalize('NFKD', e['Buffer']).encode( 'ascii', 'ignore') weechat.prnt(smsbuffer, "<- %s: %s" % (contact, message)) # Delete SMS loc = [] for m in x: sm.DeleteSMS(m['Folder'], m['Location']) return weechat.WEECHAT_RC_OK # plugin registration if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENCE, SCRIPT_DESC, 'shutdown_function', ''): # WeeSMS buffer creation smsbuffer = weechat.buffer_new('weesms', 'buffer_input_cb', '', 'buffer_close_cb', '') weechat.buffer_set(smsbuffer, 'WeeSMS', '- SMS -') # Nick list initialization contacts = weechat.nicklist_add_group(smsbuffer, '', 'contacts', '', 1) nicklist_init() # /reload_contacts command hook = weechat.hook_command('reload_contacts', "Reload CSV phonebook", '', '', '', 'reload_contacts_cb', '') # Initialize Gammu sm = gammu_init()
VERSION = "1.0" NAME = "autoauth" AUTHOR = "Kolter" DELIMITER = "|@|" import_ok = True try: import weechat except: print "Script must be run under weechat. http://www.weechat.org" import_ok = False import re weechat.register(NAME, AUTHOR, VERSION, "GPL2", "Auto authentification while changing nick", "", "") weechat.hook_signal("*,irc_in2_notice", "auth_notice_check", "") weechat.hook_command( "autoauth", "Auto authentification while changing nick", "{ add $nick $pass [$server=current] | del $nick [$server=current] | list | cmd [$command [$server=current]] }", " add : add authorization for $nick with password $pass for $server\n" " del : del authorization for $nick for $server\n" " list : list all authorization settings\n" " cmd : command(s) (separated by '|') to run when identified for $server\n" " %n will be replaced by current nick in each command", "add|del|list|cmd %- %S %S", "auth_command", "") def auth_cmdlist(): cmd = ''
# -*- coding: utf-8 -*- import weechat import os.path import datetime userlist = './userlist' debug = True weechat.register('hal', 'hal9000', '6.6.6', 'GPL3', 'HAL Script', '', '') users = [] def timer_cb(data, remaining_calls): current = weechat.current_buffer() global users if os.path.isfile(userlist): weechat.prnt(current, 'HAL\tReading ' + userlist) file = open(userlist, 'r') users = file.readlines() else: weechat.prnt(current, "HAL\tUsing default user list") users = [ '*!*@82-197-212-247.dsl.cambrium.nl', '*!*@80-101-145-252.ip.xs4all.nl', '*!*@2a01:238:4350:ff00:c53e:c819:422a:2511' ] if debug:
#w.prnt("", "%s: %s" % (c, r.body["ok"] and "ok" or "not ok")) except: w.prnt("", "Error while setting unread marker on %s" % c) w.prnt("", "%d channels marked as read" % len(channels)) return w.WEECHAT_RC_OK def conga(data, buffer, command): il = w.infolist_get("buffer", "", "") pronted = False if il: while w.infolist_next(il): if not pronted: w.prnt("", w.infolist_fields(il)) pronted = True w.prnt("", "2. %i - %i - %i - %i - %s" % (w.infolist_integer(il, "first_line_not_read"), w.infolist_integer(il, "num_displayed"), w.infolist_integer(il, "lines_hidden"), w.infolist_integer(il, "num_history"), w.infolist_string(il, "name"))) w.infolist_free(il) return w.WEECHAT_RC_OK if __name__ == "__main__": w.register("slack", "*****@*****.**", "0.1", "MIT", "Pitiful slack integration", "", "") #w.hook_command_run("/input set_unread*", "conga", "") w.hook_command_run("/input set_unread*", "unread_cb", "") users = {u['id']: u['name'] for u in slack.users.list().body["members"]} private_groups = {g['name']: g['id'] for g in slack.groups.list().body["groups"]} all_channels = {c['name']: c['id'] for c in slack.channels.list().body["channels"]} all_channels.update({users[i["user"]]: i["id"] for i in slack.im.list().body["ims"] if i["user"] in users}) all_channels.update(private_groups) #w.prnt("", "hai %d" % len(all_channels)) #w.prnt("", str(all_channels))
VERSION="1.1" NAME="autoauth" AUTHOR="Kolter" DELIMITER="|@|" import_ok = True try: import weechat except: print "Script must be run under weechat. http://www.weechat.org" import_ok = False import re weechat.register (NAME, AUTHOR, VERSION, "GPL2", "Auto authentification while changing nick", "", "") weechat.hook_signal("*,irc_in2_notice", "auth_notice_check", "") weechat.hook_command( "autoauth", "Auto authentification while changing nick", "{ add $nick $pass [$server=current] | del $nick [$server=current] | list | cmd [$command [$server=current]] | ns [$Nick[!username[@host]]] [$server=current] }", " add : add authorization for $nick with password $pass for $server\n" " del : del authorization for $nick for $server\n" " list : list all authorization settings\n" " cmd : command(s) (separated by '|') to run when identified for $server\n" " %n will be replaced by current nick in each command\n" " ns : set NickServ mask (or part of mask) for $server, the NickServ nick is mandatory", "add|del|list|cmd %- %S %S", "auth_command", ""
def main(): global dbc dbc = DBusClient() weechat.register(name, author, version, license, desc, "", "") weechat.hook_command(command, desc, "", "", "", "ws_command", "") weechat.prnt("", "%s | %s" % (name, author))
#!/usr/bin/env python2 import weechat import subprocess from os import path import json weechat.register("weecrypt", "shak-mar", "0.1", "None", "asymmetric encryption for weechat using gpg", "", "") channel_whitelist = [] gpg_identifiers = {} max_length = 300 buffers = {} config_path = "~/.weecrypt.json" failed_messages = [] # Load the configuration if path.isfile(path.expanduser(config_path)): with open(path.expanduser(config_path)) as f: config = json.loads(f.read()) channel_whitelist = config["channels"] gpg_identifiers = config["gpg_identifiers"] else: weechat.prnt("", "Error: Cant find configuration file at: %s." % config_path) # Retrieve your own nick def my_nick(server_name):
if option == 'delay' or option == 'timeout': if int(OPTIONS['delay']) > 0 or int(OPTIONS['timeout']) > 0: remove_hooks() install_hooks() else: remove_hooks() # user switched timer off return weechat.WEECHAT_RC_OK def print_usage(data, buffer, args): weechat.prnt(buffer, "%s\t%s: script already running..." % ( string_eval_expression(weechat.config_string(weechat.config_get("weechat.look.prefix_error"))), SCRIPT_NAME) ) return weechat.WEECHAT_RC_OK # ================================[ main ]=============================== if __name__ == '__main__': if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENCE, SCRIPT_DESC, '',''): weechat.hook_command(SCRIPT_NAME,SCRIPT_DESC, '', 'You have to edit options with: /set *keepnick*\n' 'I suggest using /iset script or /fset plugin.\n', '', 'print_usage', '') version = weechat.info_get("version_number", "") or 0 if int(version) >= 0x00040200: if int(OPTIONS['delay'][0]) > 0 and int(OPTIONS['timeout'][0]) > 0: init_options() install_hooks() weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' ) else:
mode = "minbif" # set 'bitlbee' or 'minbif' to select gateway type minbifChannel = "&minbif" minbifServer = "minbif" bitlbeeChannel = "&bitlbee" bitlbeeServer = "bitlbee" facebookhostname = "chat.facebook.com" minbifBuffer = "%s.%s" % (minbifServer, minbifChannel) bitlbeeBuffer = "%s.%s" % (bitlbeeServer, bitlbeeChannel) nicksToRename = set() import weechat import re weechat.register("facebook_rename", "crwl", "1.1.2", "Public Domain", "Renames Facebook usernames when using Bitlbee or Minbif", "", "") def message_join_minbif(data, signal, signal_data): signal_data = signal_data.split() channel = signal_data[2] hostmask = signal_data[0] nick = hostmask[1:hostmask.index('!')] username = hostmask[hostmask.index('!') + 1:hostmask.index('@')] server = hostmask[hostmask.index('@') + 1:] if server.find(':') > 1: server = server[:+server.index(':')] if channel == minbifChannel and nick == username and nick[ 0] == '-' and server == facebookhostname:
try: null, srvmsg = args.split(" PRIVMSG ", 1)# kchannel, query = srvmsg.split(" :" + trigger + " ", 1) except ValueError, e: #weechat.prnt(e) return weechat.WEECHAT_RC_OK kserver = str(server.split(",",1)[0]) query = query.replace(" ", "%20") autoc_url = 'url:http://autocomplete.wunderground.com/aq?query=' + query + '&format=JSON' #print(autoc_url) #debug autoc_hook = weechat.hook_process(autoc_url, 30 * 1000, "wu_autoc", "") else: pass return weechat.WEECHAT_RC_OK weechat.register("weatherbot", "deflax", VERSION, "GPL3", "WeatherBot using the WeatherUnderground API", "", "") weechat.hook_signal("*,irc_in_privmsg", "triggerwatch", "data") def config_cb(data, option, value): """Callback called when a script option is changed.""" global enabled, units, trigger, apikey if option == "plugins.var.python." + SCRIPT_NAME + ".units": units = value if option == "plugins.var.python." + SCRIPT_NAME + ".enabled": enabled = value if option == "plugins.var.python." + SCRIPT_NAME + ".trigger": trigger = value if option == "plugins.var.python." + SCRIPT_NAME + ".apikey": apikey = value return weechat.WEECHAT_RC_OK weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "") for option, default_value in script_options.items(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value)
except Exception: print("This script must be run under WeeChat.") print("Get WeeChat now at: https://weechat.org") quit() import re name = "unwanted_msg" author = "nesthib <*****@*****.**>" version = "0.2" license = "GPL" description = "Avoid sending misformatted commands as messages" shutdown_function = "" charset = "" w.register(name, author, version, license, description, shutdown_function, charset) settings = { 'regexp' : ' +/', # if the pattern matches the beginning of the line, the message will be blocked 'warning_buffer': 'current', # if set to current/server/weechat will print warning on current/server/weechat buffer. Disable warning if unset } for opt, val in settings.items(): if not w.config_is_set_plugin(opt): w.config_set_plugin(opt, val) def my_modifier_cb(data, modifier, modifier_data, string): if unwanted_pattern.match(string): if options['warning_buffer'] == 'current': output = w.current_buffer() elif options['warning_buffer'] == 'server': server = w.buffer_get_string(w.current_buffer(), 'localvar_server')
# # http://www.opensource.org/licenses/mit-license.php # # Revision log: # 0.2.3 Changed weechat.prnt to weechat.prnt_date_tags where messages # are not a direct result from user input; errors get tagged with # irc_error and notify_message, messages get tagged with # notify_message. # # 0.2.2 Version from Bit Shift import weechat import string import feedparser weechat.register("weemustfeed", "Bit Shift <*****@*****.**>", "0.2.3", "MIT", "RSS/Atom/RDF aggregator for weechat", "", "") default_settings = {"interval": "300", "feeds": ""} weemustfeed_buffer = None weemustfeed_timer = None fetch_hooks = {} updating = set() partial_feeds = {} help_message = """ COMMANDS: a <name> <url> Add a feed with display name of <name> and URL of <url>. d <name> Delete the feed with display name <name>. u <name> <url> Update the feed with display name <name> to use URL <url>. l List all feeds known to WeeMustFeed.
import weechat as w SCRIPT_NAME = "noirccolors" SCRIPT_AUTHOR = "Fredrick Brennan <*****@*****.**>" SCRIPT_VERSION = "0.1" SCRIPT_LICENSE = "Public domain" SCRIPT_DESC = "Remove IRC colors from buffers with the localvar 'noirccolors' set. To disable IRC colors in the current buffer, type /buffer set localvar_noirccolors true. You can also set this with autosetbuffer. :)" w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '') def my_modifier_cb(data, modifier, modifier_data, string): if w.buffer_get_string(w.buffer_search('irc', modifier_data.split(";")[1]), "localvar_noirccolors") == "true": try: nick, message = string.split("\t") except ValueError, e: return string return "%s\t%s" % (nick, w.string_remove_color(message, "")) else: return string hook = w.hook_modifier("weechat_print", "my_modifier_cb", "")
def fn_configchange(data, option, value): global settings fields = option.split(".") myOption = fields[-1] try: settings[myOption] = value alert("Option {0} is now {1}:".format(myOption, settings[myOption])) except KeyError: errMsg("There is no option named %s" % myOption) return w.WEECHAT_RC_OK if __name__ == "__main__" and import_ok: if w.register(SCR_NAME, SCR_AUTHOR, SCR_VERSION, SCR_LICENSE, SCR_DESC, "", ""): # synchronize weechat- and scriptsettings for option, default_value in settings.items(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, default_value) else: settings[option] = w.config_get_plugin(option) w.hook_print("", "", "", 1, "fn_privmsg", "") # catch prvmsg w.hook_config("plugins.var.python." + SCR_NAME + ".*", "fn_configchange", "") # catch configchanges w.hook_command( SCR_COMMAND, SCR_DESC, "[enabled] [n] [text]", """ Available options are: - enabled: can be "on" or "off" (controls auto responds) - respondAfterMinutes: integer (in minutes), after which responderText is sent again
spvec = pvec(40) for i in range(10): spvec.pick() last_color = '00' def gen_prefix(): global last_color color = choice(COLORS) while color == last_color: color = choice(COLORS) last_color = color return ' ' * spvec.pick() + '\3' + color def cmd_shibe(data, buf, args): weechat.command(buf, gen_prefix() + args) return weechat.WEECHAT_RC_OK if __name__ == '__main__': import weechat weechat.register(NAME, AUTHOR, VERSION, LICENSE, DESC, '', '') weechat.hook_command('shibe', CMD_DESC, CMD_ARGS, CMD_ARGS_DESC, '', 'cmd_shibe', '')
if not get_config_boolean('show_in_whois') or not check_database(): return WEECHAT_RC_OK nick, user, host = signal_data.split()[3:6] server = signal[:signal.find(',')] #debug('%s | %s | %s' %(data, signal, signal_data)) host = get_ip_from_userhost(user, host) print_country(host, find_buffer(server, nick), quiet=True, broken=True, nick=nick) return WEECHAT_RC_OK ### main if import_ok and weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): # colors color_delimiter = weechat.color('chat_delimiters') color_chat_nick = weechat.color('chat_nick') color_reset = weechat.color('reset') # pretty [SCRIPT_NAME] script_nick = '%s[%s%s%s]%s' % (color_delimiter, color_chat_nick, SCRIPT_NAME, color_delimiter, color_reset) weechat.hook_signal('*,irc_in2_311', 'whois_cb', '') # /whois weechat.hook_signal('*,irc_in2_314', 'whois_cb', '') # /whowas weechat.hook_command( 'country', cmd_country.__doc__, 'update | (nick|ip|uri)', " update: Downloads/updates ip database with country codes.\n"
for getter in (mpd_query, mpv_query): try: playing, title = getter() except FileNotFoundError: continue if playing and title is not None: break if title is not None: return f"/me np: {title}" def copy_title(): title = get_title() if title is not None: subprocess.run(["wl-copy"], input=title.encode(), check=True) def weechat_np(data, buffer, args): title = get_title() if title is not None: weechat.command(buffer, title) return weechat.WEECHAT_RC_OK if weechat is not None: weechat.register("nowplaying", "Streetwalrus", "0.1", "The game", "Now playing", "", "") weechat.hook_command("np", "Now playing", "", "", "", "weechat_np", "") elif __name__ == "__main__": copy_title()
""" chanlist = "" t = value.replace(' ', '').split(",") for chan in t: if 2 <= len(chan) and ("#" == chan[0] or "#" == chan[chan.find(".#")+1]): chanlist = chanlist + chan + "," chanlist=chanlist[:-1] #remove the trailing comma weechat.config_set_plugin("whitelist", chanlist) weechat.prnt("", "Chanpriority list set to: '{0}'".format(chanlist)) return weechat.WEECHAT_RC_OK if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): if not weechat.config_is_set_plugin("whitelist"): weechat.config_set_plugin("whitelist", "") else: get_whitelist("", "", "") def on_join(data, signal, signal_data): """Used as callback, called when you join a channel If the channel joined is in the whitelist then its buffer will be prioritized """ (chan, network, buffer) = join_meta(data, signal, signal_data) if network + "." + chan in whitelist or chan in whitelist:
except Exception: print("This script must be run under WeeChat.") print("Get WeeChat now at: https://weechat.org") quit() import re name = "unwanted_msg" author = "nesthib <*****@*****.**>" version = "0.2" license = "GPL" description = "Avoid sending misformatted commands as messages" shutdown_function = "" charset = "" w.register(name, author, version, license, description, shutdown_function, charset) settings = { 'regexp': ' +/', # if the pattern matches the beginning of the line, the message will be blocked 'warning_buffer': 'current', # if set to current/server/weechat will print warning on current/server/weechat buffer. Disable warning if unset } for opt, val in settings.items(): if not w.config_is_set_plugin(opt): w.config_set_plugin(opt, val) def my_modifier_cb(data, modifier, modifier_data, string): if unwanted_pattern.match(string): if options['warning_buffer'] == 'current':
def weechat_init(): """Main function.""" weechat.register('SCRIPT_NAME', 'SCRIPT_AUTHOR', 'SCRIPT_VERSION', 'SCRIPT_LICENSE', 'SCRIPT_DESCRIPTION', '', '') weechat.hook_command('SCRIPT_NAME', '', '', '', '', 'cmd_test_cb', '')
'Public', 'Private', 'Action', 'Notice', 'Invite', 'Highlight', 'Server', 'Channel', 'DCC', 'WeeChat' ] if len(hostname) == 0: hostname = '' if len(password) == 0: password = '' growl = GrowlNotifier(applicationName=name, hostname=hostname, password=password, notifications=notifications, applicationIcon=icon) try: growl.register() except Exception as error: weechat.prnt('', 'growl: {0}'.format(error)) STATE['growl'] = growl STATE['icon'] = icon # Register hooks. weechat.hook_signal('irc_server_connected', 'cb_irc_server_connected', '') weechat.hook_signal('irc_server_disconnected', 'cb_irc_server_disconnected', '') weechat.hook_signal('upgrade_ended', 'cb_upgrade_ended', '') weechat.hook_print('', '', '', 1, 'cb_process_message', '') if __name__ == '__main__' and IMPORT_OK and weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''): main()
"window": ("/window *", "command_run_window"), } hooks = {} # input before command /go (we'll restore it later) saved_input = "" saved_input_pos = 0 # last user input (if changed, we'll update list of matching buffers) old_input = None # matching buffers buffers = [] buffers_pos = 0 if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "go_unload_script", ""): weechat.hook_command("go", "Quick jump to buffers", "[name]", "name: directly jump to buffer by name (without argument, list is displayed)\n\n" + "You can bind command to a key, for example:\n" + " /key bind meta-g /go\n\n" + "You can use completion key (commonly Tab and shift-Tab) to select " + "next/previous buffer in list.", "%(buffers_names)", "go_cmd", "") for option, default_value in settings.items(): if weechat.config_get_plugin(option) == "": weechat.config_set_plugin(option, default_value) weechat.hook_info("go_running", "Return '1' if go is running", "", "info_go_running", "") def info_go_running(data, info_name, arguments): global hooks if "modifier" in hooks:
return whois_regex # Formatting and colour functions/utilities. def fmt_nick(nick): """Format nick in colours for output colouring""" green = w.color('green') reset = w.color('reset') nick_col = w.color(w.info_get("irc_nick_color_name", nick)) return "{}[{}{}{}]{}".format(green, nick_col, nick, green, reset) if import_ok and w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): settings = { "compare_only_on_command": ["off", "Specifically require {} for comparisons?".format(SCRIPT_COMMAND)], "ignored_servers": ["", "Servers to ignore comparisons with, comma separated."], "output_priority": ["shared", "How to display output? smart, shared, not_shared"], "sorting": ["none", "Ensure sorting shared channel WHOIS output? none, alpha, alpha_ignore_case"], "verbose_output": ["on", "Also show output when all or none channels are shared"] } for option, default_value in settings.items(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, default_value[0]) w.config_set_desc_plugin(option, default_value[1]) w.hook_command( SCRIPT_COMMAND,
# * better WSL handling i guess import sys from string import Template import weechat as wc import json import os import pyimgur import re import socket import time reload(sys) sys.setdefaultencoding('utf-8') #what a hack NAME = 'mpv_np' wc.register(NAME, 'janoosh', '1.2', 'BSD-2c', 'mpv now playing with optional screenshot (and WSL support)', '', '') # import pybuffer # debug, install pybuffer script to use # debug = pybuffer.debugBuffer(globals(), "mpv_np") def config(*args, **kwargs): options = { 'mpv_socket' : '/tmp/mpvsocket', 'screenshot_path_capture' : '/tmp/mpv-screenshot.jpg', 'screenshot_path_upload' : '', # leave empty unless using WSL; refer to readme 'imgur_client_id' : 'client_id_here', # REMEMBER TO FILL THIS IN 'format' : 'is watching \x02$mediatitle\x02 $bar [$playbacktime/$duration]\x02', 'format-ss' : '$url \x02$mediatitle\x02 $bar [$playbacktime/$duration]\x02' } for option, default in options.items(): if not wc.config_is_set_plugin(option): wc.config_set_plugin(option, default)
title = metadata_short['data'].encode('utf-8') all = '%s' % MPV['message'] + title weechat.command(weechat.current_buffer(), all) return weechat.WEECHAT_RC_OK if 'album' in metadata['data']: title = metadata['data']['title'].encode('utf-8') artist = metadata['data']['artist'].encode('utf-8') np = artist + ' ' + title all = '%s' % MPV['message'] + np weechat.command(weechat.current_buffer(), all) return weechat.WEECHAT_RC_OK else: return weechat.WEECHAT_RC_ERROR except: weechat.prnt( '', '%s: mpv socket not properly configurated or mpv is not running' % MPV['SCRIPT_NAME']) return weechat.WEECHAT_RC_ERROR weechat.register(MPV['SCRIPT_NAME'], "llua", "0.1", "The Beer-ware License", "Now Playing for mpv", "", "") set_default_options() load_options() weechat.hook_config('plugins.var.python.' + MPV['SCRIPT_NAME'] + '.*', 'reload_options_cb', '') weechat.hook_command(MPV['SCRIPT_COMMAND'], "Now Watching", "", "/%s" % MPV['SCRIPT_COMMAND'], "", "mpv_msg", "")
if channel_key is None: return args # encrypt message encrypted = encrypt(message, channel_key, channelname) returning = pre + ":" + "!ENC " + encrypted return returning # register script with weechat, set config if __name__ == "__main__": try: import weechat if weechat.register( SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"): weechat_dir = weechat.info_get("weechat_dir", "") version = weechat.info_get("version_number", "") or 0 if int(version) < 0x00030000: weechat.prnt("", "%s%s: WeeChat 0.3.0 is" " required for this script." % (weechat.prefix("error"), SCRIPT_NAME)) else: for option, default_value in script_options.iteritems(): if not weechat.config_is_set_plugin(option): weechat.config_set_plugin(option, default_value) weechat.hook_modifier("irc_in_privmsg", "weechat_msg_decrypt", "")
0.3 - 2011-03-11, Sebastien Helleu <*****@*****.**>: get python 2.x binary for hook_process (fix problem when python 3.x is default python version) 0.2 - using hook_process for last.fm call (prevents hang) - using ?limit=1 in last.fm call (faster, more efficient) 0.1 - initial script """ import weechat import feedparser weechat.register("lastfm", "Adam Saponara", "0.4", "GPL3", "Sends your latest Last.fm track to the current buffer", "", "") defaults = { "lastfm_username" : "nobody", "command" : "/me is listening to %s" } cmd_hook_process = "" cmd_buffer = "" cmd_stdout = "" cmd_stderr = "" for k, v in defaults.iteritems(): if not weechat.config_is_set_plugin(k): weechat.config_set_plugin(k, v)
def script_unload(): write_database() channel_stats.close() return WEECHAT_RC_OK # default settings settings = { 'path' :'%h/chanstat', 'average_period':'30', 'show_peaks' :'on', 'show_lows' :'on', } if __name__ == '__main__' and import_ok and \ weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, 'script_unload', ''): # colors color_delimiter = weechat.color('chat_delimiters') color_chat_nick = weechat.color('chat_nick') color_reset = weechat.color('reset') color_peak = weechat.color('green') color_low = weechat.color('red') color_avg = weechat.color('brown') color_bold = weechat.color('white') # pretty [chanop] script_nick = '%s[%s%s%s]%s' %(color_delimiter, color_chat_nick, SCRIPT_NAME, color_delimiter, color_reset) for opt, val in settings.iteritems():
#!/usr/bin/python3 import weechat, re # Globals SCRIPT_NAME = "rc_nick" # Initialize weechat.register("rc_nick", "pigs", "1.0", "MIT", "Rocket Chat name changer", "", "") weechat.config_set_plugin("nick_format", "%s") # :[email protected] PRIVMSG #channel :this is a message def get_nick(string): return string[1:string.index('!')] def get_message(string): return ' '.join(string.split(' ')[3:])[1:] def get_channel(string): return string.split(' ')[2] def get_server(string): return string.split(' ')[0][string.index('!'):][1:] def build_privmsg(nick, server, channel, message):
import json import os import random import re import sqlite3 import struct import sys import textblob import time import urllib import weechat reload(sys) sys.setdefaultencoding('utf8') weechat.register("hankbot", "ceph", "2.7.1", "GPL3", "hankbot", "", "") def get_hank_home(): infolist = weechat.infolist_get("python_script", "", "hankbot") fname = "~/hank/hank.py" while weechat.infolist_next(infolist): fname = weechat.infolist_string(infolist, "filename") weechat.infolist_free(infolist) return os.path.dirname(os.path.realpath(fname)) HANK_HOME = get_hank_home() IMGUR_CLIENT_ID = "fe0966af56cc0f0" IMGUR_CLIENT_SECRET = "cf14e4b09a9ae536ce21fc235e2f310fc97968f2" YOUTUBE_API_KEY = "AIzaSyAiYfOvXjvhwUFZ1VPn696guJcd2TJ-Lek" SQLITE_DB = HANK_HOME + "/hank.db" USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, " \
NAME = "join.py" AUTHOR = "Osiris" VERSION = ".1" LICENSE = "GPL2" import weechat weechat.register(NAME, AUTHOR, VERSION, LICENSE, "Joins my favorite channels", "", "") myChannelFile = open("/root/.weechat/python/myChannelList.txt", "r") for channel in myChannelFile: buffer = weechat.info_get("irc_buffer", "freenode,#weechat") weechat.command(buffer, "/join " + channel)
import weechat as w import time SCRIPT_NAME = "buffer_autoclose" SCRIPT_AUTHOR = "xt <*****@*****.**>" SCRIPT_VERSION = "0.3" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Automatically close inactive private message buffers" settings = { "interval": "5", # How often in minutes to check "age_limit": "30", # How old in minutes before auto close "ignore": "", # Buffers to ignore (use full name: server.buffer_name) } if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): for option, default_value in settings.iteritems(): if not w.config_is_set_plugin(option): w.config_set_plugin(option, default_value) w.hook_timer(int(w.config_get_plugin("interval")) * 1000 * 60, 0, 0, "close_time_cb", "") def get_all_buffers(): """Returns list with pointers of all open buffers.""" buffers = [] infolist = w.infolist_get("buffer", "", "") while w.infolist_next(infolist): buffer_type = w.buffer_get_string(w.infolist_pointer(infolist, "pointer"), "localvar_type") if buffer_type == "private": # we only close private message buffers for now buffers.append(w.infolist_pointer(infolist, "pointer")) w.infolist_free(infolist)
cmd = parts[0] args = parts[1:] if not cmd in COMMANDS: weechat.prnt(buf, "Unknown command " + cmd) return weechat.WEECHAT_RC_ERROR try: COMMANDS[cmd](buf, *args) return weechat.WEECHAT_RC_OK except CommandException as ex: weechat.prnt(buf, 'Error: {}'.format(ex)) return weechat.WEECHAT_RC_ERROR weechat.register(SCRIPT_NAME, "rcorre", "0.1", "MIT", "Spark Client", "", "") api = CiscoSparkAPI() rooms = {room.title: room for room in api.rooms.list()} listener = EventListener() listener.connect() weechat.hook_command( # Command name and description 'spark', '', # Usage '[command] [command options]', # Description of arguments 'Commands:\n' + '\n'.join(['history']) + '\nUse /spark help [command] to find out more\n',