17 Commits
irc ... 0.5.0

Author SHA1 Message Date
James Booth
aef8541135 syscmd.py: Make newlines configurable
issue #9
2016-11-13 21:52:41 +00:00
James Booth
018f369ff4 Update README 2016-11-13 17:28:56 +00:00
James Booth
9bc1cbc8a1 Update README 2016-11-13 17:26:46 +00:00
James Booth
6569ad66d5 Restructure project 2016-11-13 17:02:22 +00:00
James Booth
4f91f5cf67 paste.py: newline option only for multiline text
issue #5
2016-11-13 16:15:53 +00:00
James Booth
55530de6b6 paste,py: add newline option
issue #5
2016-11-13 15:41:50 +00:00
James Booth
39f5a03e78 imgur.py screenshot on OSX 2016-10-09 22:50:23 +01:00
James Booth
cd92ab06d3 Merge remote-tracking branch 'dotoole/imgur_screenshot' 2016-10-09 22:23:00 +01:00
Dolan O'Toole
9506e24609 adding requirements comment 2016-10-09 22:00:23 +01:00
Dolan O'Toole
da276cb2e8 added screenshot subcommand to imgur plugin 2016-10-09 21:56:25 +01:00
James Booth
18c2fc0654 Merge remote-tracking branch 'dotoole/imgur_plugin' 2016-09-20 00:24:32 +01:00
Dolan O'Toole
b578b5d720 dealing with ~ in path and file not found 2016-09-19 00:29:08 +01:00
Dolan O'Toole
b8f03164ee simple image sharing in chatrooms using Imgur 2016-09-18 23:50:17 +01:00
James Booth
409c383937 sounds.py allow for certain rooms 2016-09-18 23:36:26 +01:00
James Booth
16e6d7257a Add on|off setting to sounds.py 2016-09-18 21:58:38 +01:00
James Booth
9be0cdf568 Add sounds.py 2016-09-18 21:36:07 +01:00
James Booth
009a5c79a3 Add resource to chat message plugin hooks 2016-08-10 21:38:57 +01:00
25 changed files with 566 additions and 329 deletions

View File

@@ -1,59 +1,22 @@
profanity-plugins
=================
Plugin support for Profanity is currently in development.
* The `master` branch of Profanity now includes support for C and Python plugins.
* The `plugins` branch contains additional support for Ruby and Lua, but is unstable.
For a list of outstanding issues before releasing 0.5.0, see: https://github.com/boothj5/profanity/milestones/0.5.0
* [Website documentation](http://www.profanity.im/plugins.html)
Building Profanity with plugin support
--------------------------------------
Additional dependencies required:
Dependencies required:
```
autoconf-archive
libtool
```
Plus the development packages for supported languages:
For Python plugins the following is also required:
```
python-dev
lua-dev
ruby-dev
```
Build with:
```
./bootstrap.sh
./configure
make
sudo make install
```
After building, run `profanity -v` to see which language support is available, example output:
```
Profanity, version 0.5.0dev.plugins-python.63a7316
Copyright (C) 2012 - 2016 James Booth <boothj5web@gmail.com>.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Build information:
XMPP library: libmesode
Desktop notification support: Enabled
OTR support: Enabled
PGP support: Enabled
C plugins: Enabled
Python plugins: Enabled
```
Installing plugins
@@ -62,51 +25,17 @@ Installing plugins
Use the `/plugins install` command, e.g.
```
/plugins install ~/projects-git/profanity-plugins/say.py
/plugins install ~/projects-git/profanity-plugins/stable/say.py
```
See the `/help plugins` command for further plugin management options.
More help on plugins
--------------------
Branches
--------
* `/plugins` - Shows a list of loaded plugins.
* `/help commands plugins` - Shows commands defined by plugins
* `/help <plugin_cmd>` - Show help for a plugin command, e.g. `/help browser`
Plugin themes
-------------
The plugins API includes functions to print themed output to the console or a plugins window. The themes need to be added to
```
~/.local/share/profanity/plugin_themes
```
For example ([syscmd.py](https://github.com/boothj5/profanity-plugins/blob/master/syscmd.py) plugin):
```
[system]
command=cyan
result=green
```
Plugin settings
---------------
The plugins API also includes functions to read and write settings. The settings are stored in:
```
~/.local/share/profanity/plugin_settings
```
For example ([say.py](https://github.com/boothj5/profanity-plugins/blob/master/say.py) plugin):
```
[say]
args=-v english -s 120
enabled=active
```
* `0.5.0`: Maintenance branch for plugins compatible with the current Profanity release 0.5.0
* `0.5.1`: Development for the next Profanity patch release 0.5.1
* `master`: Development for the next Profanity major release 0.6.0
Developing plugins
------------------
@@ -117,10 +46,3 @@ API Documentation:
* [C API](http://www.profanity.im/plugins/c/html/profapi_8h.html)
* [C hooks](http://www.profanity.im/plugins/c/html/profhooks_8h.html)
Example test plugins (Ruby and Lua examples might not be up to date):
* [tests/test-c-plugin.c](https://github.com/boothj5/profanity-plugins/blob/master/tests/test-c-plugin/test-c-plugin.c)
* [tests/python-test.py](https://github.com/boothj5/profanity-plugins/blob/master/tests/python-test.py)
* [tests/RubyTest.rb](https://github.com/boothj5/profanity-plugins/blob/master/tests/RubyTest.rb)
* [tests/luatest.lua](https://github.com/boothj5/profanity-plugins/blob/master/tests/luatest.lua)

View File

@@ -1,27 +0,0 @@
rm -rf ~/.local/share/profanity/plugins/*
cp ascii.py ~/.local/share/profanity/plugins/.
cp syscmd.py ~/.local/share/profanity/plugins/.
cp paste.py ~/.local/share/profanity/plugins/.
cp browser.py ~/.local/share/profanity/plugins/.
cp platform-info.py ~/.local/share/profanity/plugins/.
cp say.py ~/.local/share/profanity/plugins/.
cp whoami.py ~/.local/share/profanity/plugins/.
cp wikipedia-prof.py ~/.local/share/profanity/plugins/.
cp clients.py ~/.local/share/profanity/plugins/.
cp presence_notify.py ~/.local/share/profanity/plugins/.
cp tests/python-test.py ~/.local/share/profanity/plugins/.
cd pid
make clean
make
cp pid.so ~/.local/share/profanity/plugins/.
cd ..
cd tests/test-c-plugin
make clean
make
cp test-c-plugin.so ~/.local/share/profanity/plugins/.
cd ../..

View File

@@ -10,12 +10,12 @@ bot_session = {}
bot_state = False
def prof_post_chat_message_display(jid, message):
def prof_post_chat_message_display(barejid, resource, message):
if bot_state:
if jid not in bot_session:
bot_session[jid] = bot.create_session()
response = bot_session[jid].think(message)
prof.send_line("/msg " + jid + " " + response)
if barejid not in bot_session:
bot_session[barejid] = bot.create_session()
response = bot_session[barejid].think(message)
prof.send_line("/msg " + barejid + " " + response)
def _cmd_chatterbot(state):

View File

@@ -1,27 +0,0 @@
"""
Paste the contents of the clipboard when in a chat or room window.
Dependencies:
pip install future
sudo apt-get python-tk (or python3-tk)
"""
import prof
import tkinter as tk
def _cmd_paste():
root = tk.Tk(baseName="")
root.withdraw()
result = root.clipboard_get()
prof.send_line(u'\u000A' + result)
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/paste"
]
description = "Paste contents of clipboard."
args = []
examples = []
prof.register_command("/paste", 0, 0, synopsis, description, args, examples, _cmd_paste)

View File

@@ -78,44 +78,44 @@ def prof_init(version, status, account_name, fulljid):
prof.register_command("/browser", 0, 1, synopsis, description, args, examples, _cmd_browser)
def prof_on_chat_win_focus(jid):
def prof_on_chat_win_focus(barejid):
prof.completer_clear("/browser")
if jid in _links:
prof.completer_add("/browser", _links[jid])
if barejid in _links:
prof.completer_add("/browser", _links[barejid])
def prof_on_room_win_focus(room):
def prof_on_room_win_focus(barejid):
prof.completer_clear("/browser")
if room in _links:
prof.completer_add("/browser", _links[room])
if barejid in _links:
prof.completer_add("/browser", _links[barejid])
def _process_message(jid, current_jid, message):
def _process_message(barejid, current_jid, message):
links = re.findall(r'(https?://\S+)', message)
if (len(links) > 0):
if jid not in _links:
_links[jid] = []
# add to list of links for jid
if barejid not in _links:
_links[barejid] = []
# add to list of links for barejid
for link in links:
if link not in _links[jid]:
_links[jid].append(link)
if link not in _links[barejid]:
_links[barejid].append(link)
# add to autocompleter if message for current window
if current_jid == jid:
prof.completer_add("/browser", _links[jid])
# set last link for jid
_lastlink[jid] = links[len(links)-1]
if current_jid == barejid:
prof.completer_add("/browser", _links[barejid])
# set last link for barejid
_lastlink[barejid] = links[len(links)-1]
def prof_post_chat_message_display(jid, message):
def prof_post_chat_message_display(barejid, resource, message):
current_jid = prof.get_current_recipient()
_process_message(jid, current_jid, message)
_process_message(barejid, current_jid, message)
def prof_post_room_message_display(room, nick, message):
def prof_post_room_message_display(barejid, nick, message):
current_jid = prof.get_current_muc()
_process_message(room, current_jid, message)
_process_message(barejid, current_jid, message)
def prof_on_room_history_message(room, nick, message, timestamp):
def prof_on_room_history_message(barejid, nick, message, timestamp):
current_jid = prof.get_current_muc()
_process_message(room, current_jid, message)
_process_message(barejid, current_jid, message)

View File

@@ -18,13 +18,13 @@ def _emote(input_str):
return result
def prof_pre_chat_message_display(jid, message):
def prof_pre_chat_message_display(barejid, resource, message):
return _emote(message)
def prof_pre_room_message_display(room, nick, message):
def prof_pre_room_message_display(barejid, nick, message):
return _emote(message)
def prof_pre_priv_message_display(room, nick, message):
def prof_pre_priv_message_display(barejid, nick, message):
return _emote(message)

61
stable/imgur.py Normal file
View File

@@ -0,0 +1,61 @@
"""
Requires imgur API
pip install imgurpython
Requires scrot installed for screenshot (on linux)
sudo apt-get install scrot
Uses built in screencapture on OSX
"""
import prof
import subprocess
import sys
from os import path
from imgurpython import ImgurClient
from imgurpython.helpers.error import ImgurClientError
client_id = '19c4ba3fc2c26ef'
client_secret = 'dd5b0918a2f5d36391d574bd2061c50b47bade63'
client = ImgurClient(client_id, client_secret)
def _cmd_imgur(arg1):
if arg1 == "screenshot":
file_path = "/tmp/_prof_screenshot.png"
if sys.platform == "darwin":
subprocess.call("screencapture " + file_path, shell=True)
else:
subprocess.call("scrot " + file_path, shell=True)
else:
try:
file_path = path.expanduser(arg1)
except IOError as ioe:
prof.cons_show('Could not find file at ' + file_path)
return
try:
data = client.upload_from_path(file_path, config=None, anon=True)
prof.send_line(data['link'])
except ImgurClientError as e:
prof.log_error('Could not upload to Imgur - ' + e.error_message)
prof.log_error('Imgur status code - ' + e.status_code)
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/imgur <file_path>",
"/imgur screenshot"
]
description = "Upload an image or screenshot to imgur and send the link"
args = [
[ "<file_path>", "full path to image file" ],
[ "screenshot", "upload a full screen capture" ]
]
examples = [
"/imgur ~/images/cats.jpg",
"/imgur screenshot"
]
prof.register_command("/imgur", 1, 1, synopsis, description, args, examples, _cmd_imgur)
prof.completer_add("/imgur", [ "screenshot" ])

60
stable/paste.py Normal file
View File

@@ -0,0 +1,60 @@
"""
Paste the contents of the clipboard when in a chat or room window.
Dependencies:
pip install future
sudo apt-get python-tk (or python3-tk)
"""
import prof
import tkinter as tk
def _cmd_paste(arg1=None, arg2=None):
if not arg1:
root = tk.Tk(baseName="")
root.withdraw()
result = root.clipboard_get()
newline = prof.settings_boolean_get("paste", "newline", True)
if len(result.splitlines()) > 1 and newline:
prof.send_line(u'\u000A' + result)
else:
prof.send_line(result)
return
if arg1 == "newline":
if not arg2:
prof.cons_show("")
newline = prof.settings_boolean_get("paste", "newline", True)
if newline:
prof.cons_show("paste.py newline: on")
else:
prof.cons_show("paste.py newline: off")
elif arg2 == "on":
prof.settings_boolean_set("paste", "newline", True)
prof.cons_show("paste.py newline enabled.")
elif arg2 == "off":
prof.settings_boolean_set("paste", "newline", False)
prof.cons_show("paste.py newline disabled.")
else:
prof.cons_bad_cmd_usage("/paste")
return
prof.cons_bad_cmd_usage("/paste")
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/paste",
"/paste newline on|off"
]
description = "Paste contents of clipboard."
args = [
[ "newline on|off", "Send newline before multiline clipboard text, defaults to on" ]
]
examples = []
prof.register_command("/paste", 0, 2, synopsis, description, args, examples, _cmd_paste)
prof.completer_add("/paste", [ "newline" ])
prof.completer_add("/paste newline", [ "on", "off" ])

View File

@@ -20,27 +20,27 @@ def say(message):
os.system("echo '" + message + "' | espeak " + args + " 2>/dev/null")
def prof_post_chat_message_display(jid, message):
def prof_post_chat_message_display(barejid, resource, message):
enabled = prof.settings_string_get("say", "enabled", "off")
current_recipient = prof.get_current_recipient()
if enabled == "on" or (enabled == "active" and current_recipient == jid):
say(jid + " says " + message)
if enabled == "on" or (enabled == "active" and current_recipient == barejid):
say(barejid + " says " + message)
return message
def prof_post_room_message_display(room, nick, message):
def prof_post_room_message_display(barejid, nick, message):
enabled = prof.settings_string_get("say", "enabled", "off")
current_muc = prof.get_current_muc()
if enabled == "on":
say(nick + " in " + room + " says " + message)
elif enabled == "active" and current_muc == room:
say(nick + " in " + barejid + " says " + message)
elif enabled == "active" and current_muc == barejid:
say(nick + " says " + message)
return message
def prof_post_priv_message_display(room, nick, message):
def prof_post_priv_message_display(barejid, nick, message):
# TODO add get current nick hook for private chats
if enabled:
say(nick + " says " + message)

198
stable/sounds.py Normal file
View File

@@ -0,0 +1,198 @@
"""
Play sounds on various events.
Requires mpg123 to be installed on the host system:
sudo apt-get install mpg123
brew install mpg123
"""
import subprocess
from os.path import expanduser
import prof
def _play_sound(soundfile):
if soundfile.startswith("~/"):
soundfilenew = soundfile.replace("~", expanduser("~"), 1)
else:
soundfilenew = soundfile
subprocess.Popen(["mpg123", "-q", soundfilenew])
def _cmd_sounds(arg1=None, arg2=None, arg3=None):
if not arg1:
prof.cons_show("")
enabled = prof.settings_boolean_get("sounds", "enabled", False)
chatsound = prof.settings_string_get("sounds", "chat", None)
roomsound = prof.settings_string_get("sounds", "room", None)
privatesound = prof.settings_string_get("sounds", "private", None)
roomlist = prof.settings_string_list_get("sounds", "rooms")
if chatsound or roomsound or privatesound:
if enabled:
prof.cons_show("Sounds: ON")
else:
prof.cons_show("Sounds: OFF")
if chatsound:
prof.cons_show(" Chat : " + chatsound)
if roomsound:
prof.cons_show(" Room : " + roomsound)
if roomlist and len(roomlist) > 0:
for room in roomlist:
prof.cons_show(" " + room)
else:
prof.cons_show(" All rooms")
if privatesound:
prof.cons_show(" Private : " + privatesound)
else:
prof.cons_show("No sounds set.")
return
if arg1 == "on":
prof.settings_boolean_set("sounds", "enabled", True)
prof.cons_show("Sounds enabled")
return
if arg1 == "off":
prof.settings_boolean_set("sounds", "enabled", False)
prof.cons_show("Sounds disabled")
return
if arg1 == "set":
if arg2 == "chat":
prof.settings_string_set("sounds", "chat", arg3)
prof.cons_show("Set chat sound: " + arg3)
elif arg2 == "room":
prof.settings_string_set("sounds", "room", arg3)
prof.cons_show("Set room sound: " + arg3)
elif arg2 == "private":
prof.settings_string_set("sounds", "private", arg3)
prof.cons_show("Set private sound: " + arg3)
else:
prof.cons_bad_cmd_usage("/sounds")
return
if arg1 == "clear":
if arg2 == "chat":
prof.settings_string_set("sounds", "chat", "")
prof.cons_show("Removed chat sound.")
elif arg2 == "room":
prof.settings_string_set("sounds", "room", "")
prof.cons_show("Removed room sound.")
elif arg2 == "private":
prof.settings_string_set("sounds", "private", "")
prof.cons_show("Removed private sound.")
else:
prof.cons_bad_cmd_usage("/sounds")
return
if arg1 == "rooms":
if arg2 == "add":
if not arg3:
prof.cons_bad_cmd_usage("/sounds")
else:
prof.settings_string_list_add("sounds", "rooms", arg3)
prof.cons_show("Sounds enabled for room: " + arg3)
elif arg2 == "remove":
if not arg3:
prof.cons_bad_cmd_usage("/sounds")
else:
prof.settings_string_list_remove("sounds", "rooms", arg3)
roomlist = prof.settings_string_list_get("sounds", "rooms")
if roomlist and len(roomlist) > 0:
prof.cons_show("Sounds disabled for room: " + arg3)
else:
prof.cons_show("Empty room list for sounds, playing in all rooms.")
elif arg2 == "clear":
prof.settings_string_list_clear("sounds", "rooms")
prof.cons_show("Cleared sounds room list, playing in all rooms.")
else:
prof.cons_bad_cmd_usage("/sounds")
return
prof.cons_bad_cmd_usage("/sounds")
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/sounds",
"/sounds on|off",
"/sounds set chat <file>",
"/sounds set room <file>",
"/sounds set private <file>",
"/sounds clear chat",
"/sounds clear room",
"/sounds clear private",
"/sounds rooms add <roomjid>"
]
description = "Play mp3 sounds on various Profanity events. Calling with no args shows current sound files."
args = [
[ "on|off", "Enable or disable playing sounds." ],
[ "set chat <file>", "Path to mp3 file to play on chat messages." ],
[ "set room <file>", "Path to mp3 file to play on room messages." ],
[ "set private <file>", "Path to mp3 file to play on private room messages." ],
[ "clear chat", "Remove the sound for chat messages." ],
[ "clear room", "Remove the sound for room messages." ],
[ "clear private", "Remove the sound for private messages." ],
[ "rooms add <roomjid>", "Add the room to the list that will play the room sound."],
[ "rooms remove <roomjid>", "Remove the room from the list that will play the room sound."],
[ "rooms clear", "Clear the room list, all rooms will play sounds on new messages."]
]
examples = [
"/sounds set chat ~/sounds/woof.mp3",
"/sounds set room ~/sounds/meow.mp3",
"/sounds set private ~/sounds/shhh.mp3",
"/sounds remove private",
"/sounds rooms add myroom@conference.server.org",
"/sounds on"
]
prof.register_command("/sounds", 0, 3, synopsis, description, args, examples, _cmd_sounds)
prof.completer_add("/sounds", [ "set", "clear", "on", "off", "rooms" ])
prof.completer_add("/sounds set", [ "chat", "room", "private" ])
prof.completer_add("/sounds clear", [ "chat", "room", "private" ])
prof.completer_add("/sounds rooms", [ "add", "remove", "clear" ])
def prof_post_chat_message_display(barejid, resource, message):
enabled = prof.settings_boolean_get("sounds", "enabled", False)
if not enabled:
return
soundfile = prof.settings_string_get("sounds", "chat", None)
if not soundfile:
return
_play_sound(soundfile)
def prof_post_room_message_display(barejid, nick, message):
enabled = prof.settings_boolean_get("sounds", "enabled", False)
if not enabled:
return
soundfile = prof.settings_string_get("sounds", "room", None)
if not soundfile:
return
roomlist = prof.settings_string_list_get("sounds", "rooms")
if roomlist and (barejid not in roomlist):
return
_play_sound(soundfile)
def prof_post_priv_message_display(barejid, nick, message):
enabled = prof.settings_boolean_get("sounds", "enabled", False)
if not enabled:
return
soundfile = prof.settings_string_get("sounds", "private", None)
if soundfile:
_play_sound(soundfile)

129
stable/syscmd.py Normal file
View File

@@ -0,0 +1,129 @@
"""
Allow running system commands in a plugin window, or send result to recipient
Theme options in ~/.local/share/profanity/plugin_themes
[system]
command=magenta
result=green
"""
import prof
import subprocess
system_win = "System"
def _get_result(command):
return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()
def _handle_win_input(win, command):
prof.win_show_themed(win, "system", "command", None, command)
prof.win_show(win, "")
result = _get_result(command)
split = result.splitlines()
for s in split:
prof.win_show_themed(win, "system", "result", None, s)
prof.win_show(win, "")
def create_win():
if prof.win_exists(system_win) == False:
prof.win_create(system_win, _handle_win_input)
def _handle_send(command=None):
if command == None:
prof.cons_bad_cmd_usage("/system")
return
room = prof.get_current_muc()
recipient = prof.get_current_recipient()
if room == None and recipient == None:
prof.cons_show("You must be in a chat or muc window to send a system command")
prof.cons_alert()
return
result = _get_result(command)
newline = prof.settings_boolean_get("system", "newline", True)
if len(result.splitlines()) > 1 and newline:
prof.send_line(u'\u000A' + result)
else:
prof.send_line(result)
def _handle_exec(command=None):
if command == None:
prof.cons_bad_cmd_usage("/system")
return;
create_win()
prof.win_focus(system_win)
_handle_win_input(system_win, command)
def _handle_newline(setting=None):
if not setting:
prof.cons_show("")
newline = prof.settings_boolean_get("system", "newline", True)
if newline:
prof.cons_show("syscmd.py newline: on")
else:
prof.cons_show("syscmd.py newline: off")
return
if setting == "on":
prof.settings_boolean_set("system", "newline", True)
prof.cons_show("syscmd.py newline enabled.")
return
if setting == "off":
prof.settings_boolean_set("system", "newline", False)
prof.cons_show("syscmd.py newline disabled.")
return
prof.cons_bad_cmd_usage("/paste")
def _cmd_system(arg1=None, arg2=None):
if not arg1:
create_win()
prof.win_focus(system_win)
return;
if arg1 == "newline":
_handle_newline(arg2)
return
if arg1 == "send":
_handle_send(arg2)
return
if arg1 == "exec":
_handle_exec(arg2)
return
prof.cons_bad_cmd_usage("/system")
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/system",
"/system newline on|off",
"/system exec <comman>",
"/system send <command>"
]
description = "Run a system command, calling with no arguments will open or focus the system window."
args = [
[ "newline on|off", "Send newline before multiline command output, defaults to on" ],
[ "exec <command>", "Execute a command" ],
[ "send <command>", "Send the result of the command to the current recipient or room" ]
]
examples = [
"/system exec ls -l",
"/system send uname -a"
]
prof.register_command("/system", 0, 2, synopsis, description, args, examples, _cmd_system)
prof.completer_add("/system", [ "exec", "send", "newline" ])
prof.completer_add("/system newline", [ "on", "off" ])

View File

@@ -1,79 +0,0 @@
"""
Allow running system commands in a plugin window, or send result to recipient
Theme options in ~/.local/share/profanity/plugin_themes
[system]
command=magenta
result=green
"""
import prof
import subprocess
system_win = "System"
def _get_result(command):
return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()
def _handle_win_input(win, command):
prof.win_show_themed(win, "system", "command", None, command)
prof.win_show(win, "")
result = _get_result(command)
split = result.splitlines()
for s in split:
prof.win_show_themed(win, "system", "result", None, s)
prof.win_show(win, "")
def create_win():
if prof.win_exists(system_win) == False:
prof.win_create(system_win, _handle_win_input)
def _cmd_system(arg1=None, arg2=None):
if not arg1:
create_win()
prof.win_focus(system_win)
elif arg1 == "send":
if arg2 == None:
prof.cons_bad_cmd_usage("/system")
else:
room = prof.get_current_muc()
recipient = prof.get_current_recipient()
if room == None and recipient == None:
prof.cons_show("You must be in a chat or muc window to send a system command")
prof.cons_alert()
else:
result = _get_result(arg2)
prof.send_line(u'\u000A' + result)
elif arg1 == "exec":
if arg2 == None:
prof.cons_bad_cmd_usage("/system")
else:
create_win()
prof.win_focus(system_win)
_handle_win_input(system_win, arg2)
else:
prof.cons_bad_cmd_usage("/system")
def prof_init(version, status, account_name, fulljid):
synopsis = [
"/system",
"/system exec <comman>",
"/system send <command>"
]
description = "Run a system command, calling with no arguments will open or focus the system window."
args = [
[ "exec <command>", "Execute a command" ],
[ "send <command>", "Send the result of the command to the current recipient or room" ]
]
examples = [
"/system exec ls -l",
"/system send uname -a"
]
prof.register_command("/system", 0, 2, synopsis, description, args, examples, _cmd_system)
prof.completer_add("/system", [ "exec", "send" ])

View File

@@ -565,72 +565,72 @@ def prof_on_disconnect(account_name, fulljid):
prof.win_show(plugin_win, "fired -> prof_on_disconnect: " + account_name + ", " + fulljid)
def prof_pre_chat_message_display(jid, message):
def prof_pre_chat_message_display(barejid, resource, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_chat_message_display: " + jid + ", " + message)
prof.win_show(plugin_win, "fired -> prof_pre_chat_message_display: " + barejid + "/" + resource + ", " + message)
def prof_post_chat_message_display(jid, message):
def prof_post_chat_message_display(barejid, resource, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_chat_message_display: " + jid + ", " + message)
prof.win_show(plugin_win, "fired -> prof_post_chat_message_display: " + barejid + "/" + resource + ", " + message)
def prof_pre_chat_message_send(jid, message):
def prof_pre_chat_message_send(barejid, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_chat_message_send: " + jid + ", " + message)
prof.win_show(plugin_win, "fired -> prof_pre_chat_message_send: " + barejid + ", " + message)
def prof_post_chat_message_send(jid, message):
def prof_post_chat_message_send(barejid, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_chat_message_send: " + jid + ", " + message)
prof.win_show(plugin_win, "fired -> prof_post_chat_message_send: " + barejid + ", " + message)
def prof_pre_room_message_display(room, nick, message):
def prof_pre_room_message_display(barejid, nick, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_room_message_display: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_pre_room_message_display: " + barejid + ", " + nick + ", " + message)
def prof_post_room_message_display(room, nick, message):
def prof_post_room_message_display(barejid, nick, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_room_message_display: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_post_room_message_display: " + barejid + ", " + nick + ", " + message)
def prof_pre_room_message_send(room, message):
def prof_pre_room_message_send(barejid, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_room_message_send: " + room + ", " + message)
prof.win_show(plugin_win, "fired -> prof_pre_room_message_send: " + barejid + ", " + message)
def prof_post_room_message_send(room, message):
def prof_post_room_message_send(barejid, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_room_message_send: " + room + ", " + message)
prof.win_show(plugin_win, "fired -> prof_post_room_message_send: " + barejid + ", " + message)
def prof_on_room_history_message(room, nick, message, timestamp):
def prof_on_room_history_message(barejid, nick, message, timestamp):
prof.win_create(plugin_win, _handle_win_input)
if timestamp:
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message + ", " + timestamp)
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + barejid + ", " + nick + ", " + message + ", " + timestamp)
else:
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_on_room_history_message: " + barejid + ", " + nick + ", " + message)
def prof_pre_priv_message_display(room, nick, message):
def prof_pre_priv_message_display(barejid, nick, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_priv_message_display: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_pre_priv_message_display: " + barejid + ", " + nick + ", " + message)
def prof_post_priv_message_display(room, nick, message):
def prof_post_priv_message_display(barejid, nick, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_priv_message_display: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_post_priv_message_display: " + barejid + ", " + nick + ", " + message)
def prof_pre_priv_message_send(room, nick, message):
def prof_pre_priv_message_send(barejid, nick, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_pre_priv_message_send: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_pre_priv_message_send: " + barejid + ", " + nick + ", " + message)
def prof_post_priv_message_send(room, nick, message):
def prof_post_priv_message_send(barejid, nick, message):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_post_priv_message_send: " + room + ", " + nick + ", " + message)
prof.win_show(plugin_win, "fired -> prof_post_priv_message_send: " + barejid + ", " + nick + ", " + message)
def prof_on_message_stanza_send(stanza):
@@ -687,6 +687,6 @@ def prof_on_chat_win_focus(barejid):
prof.win_show(plugin_win, "fired -> prof_on_chat_win_focus: " + barejid)
def prof_on_room_win_focus(roomjid):
def prof_on_room_win_focus(barejid):
prof.win_create(plugin_win, _handle_win_input)
prof.win_show(plugin_win, "fired -> prof_on_room_win_focus: " + roomjid)
prof.win_show(plugin_win, "fired -> prof_on_room_win_focus: " + barejid)

View File

@@ -744,163 +744,163 @@ prof_on_disconnect(const char * const account_name, const char * const fulljid)
}
char*
prof_pre_chat_message_display(const char * const jid, const char *message)
prof_pre_chat_message_display(const char * const barejid, const char *const resource, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_chat_message_display: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, jid, message);
char buf[strlen(str) + strlen(barejid) + 1 + strlen(resource) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s/%s, %s", str, barejid, resource, message);
prof_win_show(plugin_win, buf);
return NULL;
}
void
prof_post_chat_message_display(const char * const jid, const char *message)
prof_post_chat_message_display(const char * const barejid, const char *const resource, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_chat_message_display: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, jid, message);
char buf[strlen(str) + strlen(barejid) + 1 + strlen(resource) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s/%s, %s", str, barejid, resource, message);
prof_win_show(plugin_win, buf);
}
char*
prof_pre_chat_message_send(const char * const jid, const char *message)
prof_pre_chat_message_send(const char * const barejid, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_chat_message_send: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, jid, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, barejid, message);
prof_win_show(plugin_win, buf);
return NULL;
}
void
prof_post_chat_message_send(const char * const jid, const char *message)
prof_post_chat_message_send(const char * const barejid, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_chat_message_send: ";
char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, jid, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, barejid, message);
prof_win_show(plugin_win, buf);
}
char*
prof_pre_room_message_display(const char * const room, const char * const nick, const char *message)
prof_pre_room_message_display(const char * const barejid, const char * const nick, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_room_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
return NULL;
}
void
prof_post_room_message_display(const char * const room, const char * const nick, const char *message)
prof_post_room_message_display(const char * const barejid, const char * const nick, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_room_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
}
char *
prof_pre_room_message_send(const char * const room, const char *message)
prof_pre_room_message_send(const char * const barejid, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_room_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, room, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, barejid, message);
prof_win_show(plugin_win, buf);
return NULL;
}
void
prof_post_room_message_send(const char * const room, const char *message)
prof_post_room_message_send(const char * const barejid, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_room_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, room, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s", str, barejid, message);
prof_win_show(plugin_win, buf);
}
void
prof_on_room_history_message(const char * const room, const char *const nick, const char *const message, const char *const timestamp)
prof_on_room_history_message(const char * const barejid, const char *const nick, const char *const message, const char *const timestamp)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_room_history_message: ";
if (timestamp == NULL) {
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
} else {
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 2 + strlen(timestamp) + 1];
sprintf(buf, "%s%s, %s, %s, %s", str, room, nick, message, timestamp);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 2 + strlen(timestamp) + 1];
sprintf(buf, "%s%s, %s, %s, %s", str, barejid, nick, message, timestamp);
prof_win_show(plugin_win, buf);
}
}
char *
prof_pre_priv_message_display(const char * const room, const char * const nick, const char *message)
prof_pre_priv_message_display(const char * const barejid, const char * const nick, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_priv_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
return NULL;
}
void
prof_post_priv_message_display(const char * const room, const char * const nick, const char *message)
prof_post_priv_message_display(const char * const barejid, const char * const nick, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_priv_message_display: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
}
char *
prof_pre_priv_message_send(const char * const room, const char * const nick, const char *message)
prof_pre_priv_message_send(const char * const barejid, const char * const nick, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_pre_priv_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
return NULL;
}
void
prof_post_priv_message_send(const char * const room, const char * const nick, const char *message)
prof_post_priv_message_send(const char * const barejid, const char * const nick, const char *message)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_post_priv_message_send: ";
char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
char buf[strlen(str) + strlen(barejid) + 2 + strlen(nick) + 2 + strlen(message) + 1];
sprintf(buf, "%s%s, %s, %s", str, barejid, nick, message);
prof_win_show(plugin_win, buf);
}
@@ -1027,11 +1027,11 @@ prof_on_chat_win_focus(const char *const barejid)
}
void
prof_on_room_win_focus(const char *const roomjid)
prof_on_room_win_focus(const char *const barejid)
{
prof_win_create(plugin_win, handle_win_input);
char *str = "fired -> prof_on_room_win_focus: ";
char buf[strlen(str) + strlen(roomjid) + 1];
sprintf(buf, "%s%s", str, roomjid);
char buf[strlen(str) + strlen(barejid) + 1];
sprintf(buf, "%s%s", str, barejid);
prof_win_show(plugin_win, buf);
}