Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here
NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

You are here: Big Brother Bot ForumAdd-OnsPlugins Discussion (Moderator: MordyT)Need help with Puddi plugin
Pages: [1]   Go Down
  Print  
Author Topic: Need help with Puddi plugin  (Read 778 times) Bookmark and Share
Beta Testers
*
OS: Windows
Type: Owner dedicated server(s)
Gameservers: alterIW
Posts: 652
Offline Offline
WWW
« on: April 22, 2011, 10:15:56 AM »

I posted this on the alterIW forums but got no reply, so I figured I'd give it a go here.

I am using the Puddi plugin: http://alteriw.net/viewtopic.php?f=95&t=57844

I want to modify it so the reason is inserted into the database and displayed in Echelon. Here are the instructions I was given to do this:

Quote
Replace the last if-else statement (in the plugin's .py file) with the following:
Code:
   if puddi:
    self.info("Client %s is puddi - %s." % (client.name, reason) )
    client.kick(reason=kick_reason, silent=True)
    taggedReason = 'PUDDI - %s'%reason
    q = 'UPDATE penalties SET reason = "%s" WHERE client_id = %s AND type = "Kick" ORDER BY id DESC LIMIT 1'%(taggedReason, client.id)
    self.console.storage.query(q)
    else:
    self.info("%s - ok" % client.name)

The cheater won't know the real kick reason, but you'll be able to search for all PUDDI kick reasons in Echelon.

Using that code causes this error in B3:

Code:
110418 12:16:28 CRITICAL Error loading plugin: unexpected indent (report.py, line 52)
Traceback (most recent call last):
File "C:\b3\tdm\b3\parser.py", line 554, in loadPlugins
pluginModule = self.pluginImport(plugins[s]['name'], plugins[s]['path'])
File "C:\b3\tdm\b3\parser.py", line 667, in pluginImport
return imp.load_module(name, fp, pathname, description)
File "C:\b3\tdm\b3\extplugins\report.py", line 52
if puddi:
^
IndentationError: unexpected indent

Can I get a little help with this, please?
Logged

Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3484
Online Online
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #1 on: April 22, 2011, 10:22:09 AM »

Quote
unexpected indent
means you mixed tabs and spaces for indenting your code. Use a text editor which allows you to see blank characters (notepad++ for instance)
Logged

Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #2 on: April 22, 2011, 10:36:14 AM »

Grosskopf if you get it please let me know. that I also use the plugin and I'm interested

thx
« Last Edit: April 22, 2011, 10:39:14 AM by LiKaNtRoP » Logged
Beta Testers
*
OS: Windows
Type: Owner dedicated server(s)
Gameservers: alterIW
Posts: 652
Offline Offline
WWW
« Reply #3 on: April 23, 2011, 02:41:56 PM »

means you mixed tabs and spaces for indenting your code. Use a text editor which allows you to see blank characters (notepad++ for instance)

I did use Notepad++. I copied the code directly and pasted it, so there must be a problem with the code itself that I was told to put in there.
Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1098
Offline Offline
« Reply #4 on: April 23, 2011, 02:49:45 PM »

I did use Notepad++. I copied the code directly and pasted it, so there must be a problem with the code itself that I was told to put in there.

It looks like there is too much indent on the if puddi: line or not enough on the rest of the lines
« Last Edit: April 23, 2011, 02:51:27 PM by 82ndAB.Bravo17 » Logged
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #5 on: April 23, 2011, 04:21:35 PM »

hey mate  I was bored and though I am not coder but just comparing the 2 codes (original from lmaobox and yours) i see some important differences (seems like your code out for a previous version) so I tried to combine the 2 codes respecting the original as much as possible and..... I don´t know if it works (if the plugin records the reason in the database) but I get the plugin loaded and the bot started

110423 18:49:27   INFO   trying external plugin directory : C:\UserFiles\likantrop\CoDMW2\b3\extplugins
110423 18:49:27   BOT       ReportPlugin: Loading config @conf\report.xml for ReportPlugin
110423 18:49:27   INFO   ReportPlugin: we are ready to eliminate puddi
110423 18:49:27   DEBUG   Register Event: Stop Process: ReportPlugin
110423 18:49:27   DEBUG   Register Event: Program Exit: ReportPlugin
110423 18:49:27   BOT       Plugin report (1.0c - lmaobox) loaded

I know I know the Debug says stop process and program exit bla bla bla... but all my plugins say that and are working.  I checked  Huh


my combination

Code:
       if puddi:
          self.info("Client %s is denied - %s." % (client.name, reason) )
  client.kick(reason=kick_reason, silent=True)
          taggedReason = 'PUDDI - %s'%reason
          q = 'UPDATE penalties SET reason = "%s" WHERE client_id = %s AND type = "Kick" ORDER BY id DESC LIMIT 1'%(taggedReason, client.id)
          self.console.storage.query(q)
          self.console.write('%s %s %s' % ( action, client.cid, kick_reason ))
        else:
          self.info("%s - ok" % client.name)

sorry for my english im spanish and have to combine my very limited knowledge and the google translator so some phrases may not have much sense to you  Embarrassed

greetings
« Last Edit: April 23, 2011, 07:24:22 PM by LiKaNtRoP » Logged
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #6 on: April 24, 2011, 01:29:13 AM »

tested and working  but now the plugin send 2  rcon commands  Huh

110423 23:08:29   INFO   ReportPlugin: Client [PROTOTYPE] is denied - infraction-auto-native-wallhack.
110423 23:08:29   VERBOSE   RCON sending (93.93.65.39:28971) clientkick 10
110423 23:08:30   VERBOSE   RCON sending (93.93.65.39:28971) tempbanclient 10 EXE_DNSFAILURE



[attachment deleted by maintenance]
« Last Edit: April 24, 2011, 02:06:13 AM by LiKaNtRoP » Logged
Moderator
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #7 on: April 24, 2011, 10:30:15 AM »

That second line is the a tempban from puddi
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #8 on: April 24, 2011, 10:40:06 AM »

yes I know both are from puddi, because if not kick the bot can not record in the database i think. but if the bot send a kick command first..... maybe tempban command is useless because player is out  Huh so maybe he can reconnect instantly (bad thing) i´m seeing the B3 auto kicks/bans list in echelon and no one has reconnected after being excluded but..... I Don´t know maybe is coincidence
« Last Edit: April 24, 2011, 11:07:16 AM by LiKaNtRoP » Logged
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #9 on: April 28, 2011, 04:47:44 PM »

ok I hope I can explain myself properly because English is not my native language and I have to help myself with google translator so sorry for this.

in the picture attached, the left is the original plugin and the right is modified to record the event in the database so I can see through echelon.



Uploaded with ImageShack.us

but I have one problem with this:

the portion of code marked with a black line (this is not modified) makes the bot send a rcon command which depending on whether the player is marked as a cheat or not this can be a tempbanclient or a simply kick with reason (heartbeat-timeout or not-registered-with-lsp)

the portion of code marked as red (added code) makes the bot send a kick command (and is sent first) and record the event in the database with the portion of code marked with a blue line (added code)

the result is this:

case 1) should result in a 3600s tempbanclient

110428 12:31:35   INFO   ReportPlugin: Client penisnasejankin is denied - infraction-auto-kidebr.
110428 12:31:35   VERBOSE   RCON sending (93.93.65.39:28971) clientkick 0
110428 12:31:36   DEBUG   Storage: setClientPenalty data {'time_edit': 1304011896, 'keyword': None, 'type': 'Kick', 'admin_id': 0, 'reason': 'EXE_DNSFAILURE', 'inactive': 0, 'data': '', 'client_id': 348, 'time_add': 1304011896, 'time_expire': 0}
110428 12:31:36   VERBOSE   RCON sending (93.93.65.39:28971) tempbanclient 0 EXE_DNSFAILURE

case 2)  should result in a clientkick informing the player with the reason heartbeat-timeout

110428 12:35:20   INFO   ReportPlugin: Client Sinobi is denied - heartbeat-timeout.
110428 12:35:20   VERBOSE   RCON sending (93.93.65.39:28971) clientkick 4
110428 12:35:21   DEBUG   Storage: setClientPenalty data {'time_edit': 1304012121, 'keyword': None, 'type': 'Kick', 'admin_id': 0, 'reason': 'heartbeat-timeout', 'inactive': 0, 'data': '', 'client_id': 351, 'time_add': 1304012121, 'time_expire': 0}
110428 12:35:21   VERBOSE   RCON sending (93.93.65.39:28971) clientkick 4 heartbeat-timeout

as result of this, the event is properly recorded in the database but the default rcon commands are useless because the command sent by the portion of code marked with the red line

what I want is connect the portion of code marked with the blue line with the portion of code marked with the black line and remove the portion of code marked with the red line so that the event is recorded in the database and  the bot send the good rcon commands

anyone know if this is possible and how could I do this?

thanks in advance and sorry for the big post

greetings
« Last Edit: April 28, 2011, 04:50:53 PM by LiKaNtRoP » Logged
Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3484
Online Online
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #10 on: April 29, 2011, 12:33:24 AM »

I would do the following :

Code: python
    def puddi_check(self, client, first_try, authed=True):
       if not client:
         return
       xuid = int(client.guid, 16)
       opener = urllib2.build_opener()
       valid = opener.open('%s/clean/%s' % (self.server, xuid)).read() == 'valid'
       puddi = False
       
       if not valid:      
         reason = opener.open('%s/cleanExt/%s' % (self.server, xuid)).read()
         reason = reason.split('\r\n')[1] #2nd line is the reason
         if 'infraction' in reason:
           client.tempban(duration="1h", reason=reason, keyword="PUDDI", data=reason)
         elif first_try and 'heartbeat-timeout' in reason:
           if not authed:
             time.sleep(30)
             self.puddi_check(client, False)
           return
         else:
           client.kick(reason=reason, keyword="PUDDI", data=reason)
       else:
         self.info("%s - ok" % client.name)
Logged

Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #11 on: April 29, 2011, 03:03:34 AM »

Then you propose to return to the original plugin changing the rcon command Tempbanclient (with the server) by a tempban (with the bot) to be able to record  the penalty in the database. is this correct?

I think it could work, heartbeat-timeout still will be only kicked right?
« Last Edit: April 29, 2011, 03:14:47 AM by LiKaNtRoP » Logged
Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #12 on: April 29, 2011, 03:51:01 AM »

is this correct? i want the players kicked by heartbeat-timeout can see the real reason when they are kicked but  the cheaters only can see the fake reason (or nothing i don´t care)

Code: python
__version__ = '1.0c'
__author__  = 'lmaobox'

import b3
from b3 import clients
import b3.events
import b3.plugin
from b3 import functions
import urllib2
import time

class ReportPlugin(b3.plugin.Plugin):
   def onLoadConfig(self):
     self.info("we are ready to eliminate puddi")
     self.server = 'http://server.alteriw.net:13000'
     self.ban_reason = 'EXE_DNSFAILURE'
   
   def startup(self):
     self.registerEvent(b3.events.EVT_CLIENT_AUTH)
     self.registerEvent(b3.events.EVT_CLIENT_JOIN)
   
   def onEvent(self, event):
     if event.type == b3.events.EVT_CLIENT_JOIN:
       self.puddi_check(event.client, True)
     elif event.type == b3.events.EVT_CLIENT_AUTH:
       self.puddi_check(event.client, True, authed=False)
             
   def puddi_check(self, client, first_try, authed=True):
       if not client:
         return
       xuid = int(client.guid, 16)
       opener = urllib2.build_opener()
       valid = opener.open('%s/clean/%s' % (self.server, xuid)).read() == 'valid'
       puddi = False
       
       if not valid:      
         reason = opener.open('%s/cleanExt/%s' % (self.server, xuid)).read()
         reason = reason.split('\r\n')[1] #2nd line is the reason
         if 'infraction' in reason:
           client.tempban(duration="1h", reason=reason, keyword="PUDDI", data=reason)
           kick_reason = self.ban_reason
         elif first_try and 'heartbeat-timeout' in reason:
           if not authed:
             time.sleep(30)
             self.puddi_check(client, False)
           return
         else:
           action = 'clientkick'
           kick_reason = reason
         puddi = True
           
       if puddi:
         self.info("Client %s is denied - %s." % (client.name, reason) )
         self.console.write('%s %s %s' % ( action, client.cid, kick_reason ))
       else:
         self.info("%s - ok" % client.name)
« Last Edit: April 29, 2011, 04:01:51 AM by LiKaNtRoP » Logged
Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3484
Online Online
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #13 on: April 29, 2011, 07:40:30 AM »

well, keep a close eye on your b3.log and see how it act in such cases
Logged

Jr. Member
**
OS: Windows
Type: Owner dedicated server(s)
Gameservers: CoD6
Posts: 47
Offline Offline
« Reply #14 on: April 29, 2011, 08:55:50 AM »

ok it works


tempban example

110429 11:18:40   VERBOSE   Parsing Event: Client Authenticated: ReportPlugin
110429 11:18:40   VERBOSE   RCON sending (93.93.65.39:28971) clientkick 16
110429 11:18:41   VERBOSE   RCON sending (93.93.65.39:28971) say ^0(^2b3^0)^7: Rihak^7 was temp banned for 1.0 hour^7 infraction-auto-kidebr
110429 11:18:41   DEBUG   Storage: setClientPenalty data {'time_edit': 1304093921, 'keyword': '', 'time_expire': 1304097521, 'admin_id': 0, 'reason': 'infraction-auto-kidebr', 'inactive': 0, 'data': 'infraction-auto-kidebr', 'client_id': 887, 'duration': 60.0, 'time_add': 1304093921, 'type': 'TempBan'}
110429 11:18:41   INFO   ReportPlugin: Client Rihak is denied - infraction-auto-kidebr.

kick for heartbeat-timeout example

110429 11:19:36   INFO   ReportPlugin: Client Time's Heart is denied - heartbeat-timeout.
110429 11:19:36   VERBOSE   RCON sending (93.93.65.39:28971) clientkick 16 heartbeat-timeout


thank you very much  Grin
Logged
Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal