Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions txircd/modules/ircv3/batch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from twisted.plugin import IPlugin
from txircd.module_interface import IModuleData, ModuleData
from zope.interface import implements
from txircd.ircbase import IRCBase
import random, string

class Batch(ModuleData):
Expand Down Expand Up @@ -32,15 +33,15 @@ def fullUnload(self):
def addCapability(self, user, capList):
capList.append("batch")

def startBatch(self, user, batchName, batchType, batchParameters):
def startBatch(self, user, batchName, batchType, *batchParameters):
if "capabilities" not in user.cache or "batch" not in user.cache["capabilities"]:
return
uniqueReferenceTagParts = [ random.choice(string.ascii_letters) ]
for i in range(2, 10):
uniqueReferenceTagParts.append(random.choice(string.ascii_letters + string.digits))
uniqueReferenceTag = "".join(uniqueReferenceTagParts)
IRCBase.sendMessage(user, "BATCH", "+{}".format(uniqueReferenceTag), batchType, *batchParameters)
user.cache["currentBatch"] = uniqueReferenceTag
user.sendMessage("BATCH", "+{}".format(uniqueReferenceTag), batchType, *batchParameters)

def addBatchTag(self, user, command, args, kw):
if "currentBatch" in user.cache:
Expand All @@ -49,11 +50,11 @@ def addBatchTag(self, user, command, args, kw):
else:
kw["tags"] = { "batch": user.cache["currentBatch"] }

def endBatch(self, user, batchName, batchType, batchParameters):
def endBatch(self, user, batchName, batchType, *batchParameters):
if "currentBatch" not in user.cache:
return
uniqueReferenceTag = user.cache["currentBatch"]
del user.cache["currentBatch"]
user.sendMessage("BATCH", "-{}".format(uniqueReferenceTag))
IRCBase.sendMessage(user, "BATCH", "-{}".format(uniqueReferenceTag))

batch = Batch()
6 changes: 3 additions & 3 deletions txircd/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def handleCommand(self, command, params, prefix, tags):
if not self.ircd.runActionFlagTrue("commandunknown", self, command, params, {}):
self.sendMessage(irc.ERR_UNKNOWNCOMMAND, command, "Unknown command")

def createMessageBatch(self, batchName, batchType, batchParameters = None):
def createMessageBatch(self, batchName, batchType, *batchParameters):
"""
Start a new message batch with the given batch name, type, and list of parameters.
If a batch with the given name already exists, that batch will be overwritten.
Expand All @@ -206,10 +206,10 @@ def sendBatch(self, batchName):
return
batchType = self._messageBatches[batchName]["type"]
batchParameters = self._messageBatches[batchName]["parameters"]
self.ircd.runActionStandard("startbatchsend", self, batchName, batchType, batchParameters)
self.ircd.runActionStandard("startbatchsend", self, batchName, batchType, *batchParameters)
for messageData in self._messageBatches[batchName]["messages"]:
self.sendMessage(messageData[0], *messageData[1], **messageData[2])
self.ircd.runActionStandard("endbatchsend", self, batchName, batchType, batchParameters)
self.ircd.runActionStandard("endbatchsend", self, batchName, batchType, *batchParameters)

def startErrorBatch(self, batchName):
"""
Expand Down