/***********************************************************************
X3 ChangeLog
+2009-10-05 Henrik Stuart <evilnet@hstuart.dk>
+
+ * src/mod-python.c: Expose Python services module as _svc to follow normal
+ Python naming conventions for C extensions.
+
2009-10-05 Henrik Stuart <evilnet@hstuart.dk>
* src/mod-python.c: Remove unused function.
/* ---------------------------------------------------------------------- *
Some hooks you can call from modpython.py to interact with the
- service, and IRC. These emb_* functions are available as svc.*
+ service, and IRC. These emb_* functions are available as _svc.*
in python.
*/
emb_dump(UNUSED_ARG(PyObject *self), PyObject *args)
{
/* Dump a raw string into the socket
- usage: svc.dump(<P10 string>)
+ usage: _svc.dump(<P10 string>)
*/
char *buf;
int ret = 0;
emb_send_target_privmsg(UNUSED_ARG(PyObject *self), PyObject *args)
{
/* Send a privmsg
- usage: svc.send_target_privmsg(<servicenick_from>, <nick_to>, <message>)
+ usage: _svc.send_target_privmsg(<servicenick_from>, <nick_to>, <message>)
*/
int ret = 0;
char *servicenick;
emb_send_target_notice(UNUSED_ARG(PyObject *self), PyObject *args)
{
/* send a notice
- usage: svc.send_target_notice(<servicenick_from>, <nick_to>, <message>)
+ usage: _svc.send_target_notice(<servicenick_from>, <nick_to>, <message>)
*/
int ret = 0;
char *servicenick;
emb_get_user(UNUSED_ARG(PyObject *self), PyObject *args)
{
/* Get a python object containing everything x3 knows about a user, by nick.
- usage: svc.get_user(<nick>)
+ usage: _svc.get_user(<nick>)
*/
char *nick;
struct userNode *user;
emb_get_channel(UNUSED_ARG(PyObject *self), PyObject *args)
{
/* Returns a python dict object with all sorts of info about a channel.
- usage: svc.get_channel(<name>)
+ usage: _svc.get_channel(<name>)
*/
char *name;
struct chanNode *channel;
emb_get_account(UNUSED_ARG(PyObject *self), PyObject *args)
{
/* Returns a python dict object with all sorts of info about an account.
- usage: svc.get_account(<account name>)
+ usage: _svc.get_account(<account name>)
*/
char *name;
struct handle_info *hi;
}
Py_Initialize();
- Py_InitModule("svc", EmbMethods);
+ Py_InitModule("_svc", EmbMethods);
/* TODO: get "modpython" from x3.conf */
pName = PyString_FromString("modpython");
base_module = PyImport_Import(pName);
# - provide helper functions for scripts to do common things like msg a person or a channel,
# reply, etc.
-import svc
+import _svc
import math
self.target = target #the channel message was in (if public)
def send_target_privmsg(self, source, target, message):
- svc.send_target_privmsg(source, target, "%s "%(message))
+ _svc.send_target_privmsg(source, target, "%s "%(message))
def reply(self, message):
""" Send a private reply to the user using convenience values"""
return 0
def join(self, irc, channel, nick):
- #user = svc.get_user(nick)
+ #user = _svc.get_user(nick)
#print "DEBUG: handler.join()"
return self.plugins.callhandler("join", irc, [channel, nick], [channel, nick])
# anoy module
-import svc
+import _svc
class Annoy:
# irc.send_target_privmsg("x3", channel, "%s joined %s:%s "%(nick, channel, self.test))
def nick_change(self, irc, nick, old_nick):
- svcinfo = svc.get_info()
+ svcinfo = _svc.get_info()
# opserv pm #theops that someones nick changed
irc.send_target_privmsg(svcinfo["opserv"], "#theops", "%s changed nick to %s"%(old_nick, nick) )
def dance(self, irc, args):
nick = irc.caller
- user = svc.get_user(nick)
+ user = _svc.get_user(nick)
reply = "Ok,"
if(user and "account" in user):
irc.reply(reply)
def nickof(self, irc, bot):
- info = svc.get_info()
+ info = _svc.get_info()
if(bot and bot in info.keys()):
irc.reply("%s has nick %s"%(bot, info[bot]))
# anoy module
-import svc
+import _svc
import re
import fileinput
import random
def dance(self, irc, args):
nick = irc.caller
- user = svc.get_user(nick)
+ user = _svc.get_user(nick)
reply = "Ok,"
if(user and "account" in user):
irc.reply(reply)
def nickof(self, irc, bot):
- info = svc.get_info()
+ info = _svc.get_info()
if(bot and bot in info.keys()):
irc.reply("%s has nick %s"%(bot, info[bot]))