def setComment(self, message=""): """ set user comment """ if not self._session: self._log("can't set comment to %s: no valid session id" % message, 1) return False if not self._established: self._log( "can't set comment to %s: connection not established" % message, 1) return False if len(message) > 128: # longer comments would require handling RequestBlob messages self._log("can't set comment: too long (>128 bytes)", 1) return False pbMess = pb2.UserState() pbMess.session = self._session pbMess.comment = message pbMess.channel_id = self._channelId if not self._sendMessage(pbMess): self._log("failed to send comment package", 1) return False return True
def _joinChannel(self, channel): """ join a channel by name """ if not self._session: self._log("can't join channel: no valid session id", 1) return False try: cid = self._channelIds[channel] except: self._log("can't join channel " + channel + ": unknown id.", 1) return False self._log( "sending package to join channel " + channel + " (id " + str(cid) + ")", 2) pbMess = pb2.UserState() pbMess.session = self._session pbMess.channel_id = cid if not self._sendMessage(pbMess): self._log("failed to send join package", 1) return False self._channelId = cid self._connectionEstablished()