input = self._adminPlugin.parseUserCmd(data) if not input: client.message('^7Invalid data, try !help tell') return False clients = self.console.clients.getList() for c in clients: if c.maxLevel >= self._admin_level: c.message('^5%s^7: %s' % (client.name, input[0])) return True if __name__ == '__main__': from b3.fake import fakeConsole from b3.fake import joe, simon, moderator, superadmin import time p = MessengerPlugin(fakeConsole) p.onStartup() joe.connects(cid=1) simon.connects(cid=2) moderator.connects(cid=3) superadmin.connects(cid=4) joe.says('!tell 2 hola') print "-------------------------" joe.says('!telladmin ayuda') print "-------------------------"
from b3.config import XmlConfigParser conf = XmlConfigParser() conf.loadFromString(""" <configuration plugin="poweradminbf3"> <settings name="commands"> <set name="changeteam-ct">0</set> </settings> </configuration> """) p = Poweradminbf3Plugin(fakeConsole, conf) p.onLoadConfig() p.onStartup() simon.connects("simon") simon.teamId = 1 joe.connects('Joe') joe.teamId = 1 jack = FakeClient(fakeConsole, name="Jack", exactName="Jack", guid="azerazerzarazrzae", groupBits=1) jack.connects('Jack') jack.teamId = 1 superadmin.connects('superadmin') superadmin.teamId = 2 print "Joe's group is " + joe.maxGroup.name print "Jack's group is " + jack.maxGroup.name print "Simon's group is " + simon.maxGroup.name
conf.loadFromString(""" [commands] weaponrestrict: 80 restricted-rw: 0 [messages] warn_kick_message: 'Using %s is not allowed on this server. Please type !rw to see a list of restricted weapons' [punish_method] punish_method: 1 warn_duration: 1h [restricted_weapons] restricted_weapons: RPG-7, SMAW, M320, M26Mass """) # make B3 think it has a config file on the filesystem conf.fileName = os.path.join(os.path.dirname(__file__), '../extplugins/conf/weaponrestrict.ini') p = Weaponrestrictbf3Plugin(fakeConsole, conf) p.onLoadConfig() p.onStartup() joe.connects(cid=1) simon.connects(cid=7) print "----------- Testing Punish Method Set as Kick ------------" joe.kills(simon, 'M320') time.sleep(5) print "----------- Testing Punish Method Set as Warn ------------" p.punish_method = 2 p.warn_duration = '2h' joe.kills(simon, 'M320')
<!-- The purge action takes place once a day at the time define below. Default time is midnight --> <set name="hour">0</set> <!-- hour between 0 and 23 --> <set name="min">0</set> <!-- min between 0 and 59 --> </settings> </configuration> """) p = ChatloggerPlugin(fakeConsole, conf1) p.onLoadConfig() p.onStartup() joe.connects(1) simon.connects(3) joe.says("sql injec;tion ' test") joe.sendsPM("sql; injection ' test", simon) joe.says("!help sql injection ' test;") joe.name = "j'oe" simon.name = "s;m'n" joe.says("sql injection test2") joe.sendsPM("sql injection test2", simon) joe.says("!help sql injection test2") joe.name = "Joe" simon.name = "Simon" while True:
def sendsPM(self, msg, target): print "\n%s PM to %s : \"%s\"" % (self.name, msg, target) self.console.queueEvent( b3.events.Event(b3.events.EVT_CLIENT_PRIVATE_SAY, msg, self, target)) FakeClient.sendsPM = sendsPM p = ChatloggerPlugin(fakeConsole) p.onStartup() time.sleep(2) joe.connects(1) simon.connects(3) joe.says("sql injec;tion ' test") joe.sendsPM("sql; injection ' test", simon) joe.says("!help sql injection ' test;") joe.name = "j'oe" simon.name = "s;m'n" joe.says("sql injection test2") joe.sendsPM("sql injection test2", simon) joe.says("!help sql injection test2") joe.says("holas \" como va") joe.name = "Joe" simon.name = "Simon"
conf.loadFromString(""" <configuration plugin="poweradminbf3"> <settings name="commands"> <set name="changeteam">0</set> </settings> <settings name="preferences"> <set name="no_level_check_level">20</set> </settings> </configuration> """) p = Poweradminbf3Plugin(fakeConsole, conf) p.onLoadConfig() p.onStartup() simon.connects("simon") simon.teamId = 1 moderator.connects('moderator') moderator.teamId = 2 superadmin.connects('superadmin') superadmin.teamId = 2 print "Simon's group is " + simon.maxGroup.name print "Moderator's group is " + moderator.maxGroup.name print "superadmin's group is " + superadmin.maxGroup.name assert p.no_level_check_level == 20 print "\n\n####################################### Simon should not be able to !changeteam Moderator" simon.says("!changeteam Moderator")
<set name="sendername">Your Name</set> <!-- Sender's e-mail address --> <set name="sendermail">[email protected]</set> <!-- Receivers' e-mail addresses (separate with comma (,)) --> <set name="receivers">[email protected], [email protected]</set> <!-- Your SMTP server Example: mail.example.com. For Google that is smtp.gmail.com:587 --> <set name="smtp">mail.example.com</set> <!-- E-mail login name --> <set name="login">login_name</set> <!-- E-mail password --> <set name="password">password</set> <!-- Your E-mail message body --> <set name="emailbody">Attention! A suspicious player detected, better get your ass into the server</set> </settings> </configuration> ''') p = AimbotdetectorPlugin(fakeConsole, conf) p.onStartup() print '------------------------------' joe.connects(cid=1) joe.ip = '111.222.333.444' superadmin.connects(cid=3) moderator.connects(cid=5) simon.connects(cid=7) joe.kills(superadmin) print '------------------------------' joe.kills(superadmin) print '------------------------------' joe.kills(superadmin)