Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
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!

Author Topic: MoreSpam plugin  (Read 4072 times)

Offline d0nin380

  • Full Member
  • ***
  • Posts: 56
MoreSpam plugin
« on: March 24, 2011, 03:42:57 AM »
This is the first plugin i wrote for b3 and being a not-so-good python programmer all the suggstions/comments are welcome.

The plugin was written for CoD Black Ops on b3 v. 1.4.2b and have not been tested in any other game or b3 version.
Python v.2.6.6

Well all the information about the plugin are below.

->Plugin Download<-

Quote
   
#       README-MoreSpam.txt
#       Plugin for B3 (www.bigbrotherbot.com)
#      
#       Copyright 2011 d0nin380 <d0nin380<at>gmail<dot>com>
#      
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#      
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#      
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

Description:
   A very basic plugin to add custom say-commands just by editing the config file.
   Check the MoreSpam.xml for details.
   You can rename or delete the existing cmds and add ones you want.
   
   Make sure your responses "name" settings are the same as the commands and commands-p2p "name" settings INCLUDING the aliases.
   
   help-messages "name" settings must be without the alias.
   
   ***NOTE*** The plugin will NOT work if you change the names of the sections. ***NOTE***
   
   

Installation:
   1. Unzip the content of this package into your B3 folder. It will
   place the MoreSpam.py file in b3/extplugins and the config file MoreSpam.xml in
   your b3/extplugins/conf folder.

   2. Open MoreSpam.xml with your texteditor and edit it to your liking.

   3. Open your B3.xml file (in b3/conf) and add the next line in the
   <plugins> section of the file:

      <plugin config="@b3/extplugins/conf/MoreSpam.xml" name="MoreSpam" />

   4. Restart your b3
   
Support:
   Support will ONLY be provided in http://forum.bigbrotherbot.net/releases/morespam-plugin/ so do not email me or anybody else your support questions.
   
# CHANGELOG
#   2011/03/23 - 1.1.0 - d0nin380
#   * Initial Release

MoreSpam.py
Code: python [Select]

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#       MoreSpam.py
#      
#       Copyright 2011 d0nin380 d0nin380[at]gmail[dot]com>
#      
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#      
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#      
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

__version__ = '1.0.0'
__author__ = 'd0nin380'

import b3, re, b3.events, random

class MorespamPlugin(b3.plugin.Plugin):
def startup(self):
"""
Plugin for b3 to spam messages like !ns !owned !lol etc...
"""
self._adminPlugin = self.console.getPlugin('admin')
self._p2p_cmddict = {}
self._cmddict = {}
self._helpdict = {}
self._sections = ['commands', 'commands-p2p', 'responses', 'help-messages']
self._failed_section = ""
if not self._adminPlugin:
self.error('Could not find admin plugin')
return False

#Make sure all the sections needed are in the xml file.
for section in self._sections:
if section in self.config.sections():
pass
else:
self._failed_section=section
self.warning("Plugin did not start because of missing section [%s] in the config file." % self._failed_section)
return False

try:
for cmd in self.config.options('commands-p2p'):
_response = self.config.get('responses', cmd)
level = self.config.get('commands-p2p', cmd)
sp = cmd.split('-')
alias = None
if len(sp) == 2:
cmd, alias = sp

func = self.getCmd(cmd)
if func:
try:
func.__func__.__doc__ = self.config.get("help-messages", cmd)
except Exception, msg:
self.debug("%s No help message set in MoreSpam.xml." % msg)
func.__func__.__doc__ = None
self._adminPlugin.registerCommand(self, cmd, level, func, alias)
self._p2p_cmddict[cmd] = _response.split(',')
except Exception, msg:
self.debug("Something is wrong with your MoreSpam.xml section %s. Some commands may not work." % msg)

try:
for cmd in self.config.options('commands'):
_response = self.config.get('responses', cmd)
level = self.config.get('commands', cmd)
sp = cmd.split('-')
alias = None
if len(sp) == 2:
cmd, alias = sp
func = self.getCmd(cmd)
if func:
try:
func.__func__.__doc__ = self.config.get("help-messages", cmd)
except Exception, msg:
self.debug("%s No help message set in MoreSpam.xml." % msg)
func.__func__.__doc__ = None
self._adminPlugin.registerCommand(self, cmd, level, func, alias)
self._cmddict[cmd] = _response
except Exception, msg:
self.debug("Something is wrong with your MoreSpam.xml section %s. Some commands may not work." % msg)

self.debug('Started')

def getCmd(self, cmd):
cmd = 'cmd_handler'
func = getattr(self, cmd)
return func

def cmd_handler(self, data, client=None, cmd=None):
__doc__ = "help msg for: %s" % cmd
m = self._adminPlugin.parseUserCmd(data)
if cmd.command in self._p2p_cmddict.keys():
if not m:
client.message('^7Invalid parameters, you must supply a player name')
return False
sclient = self._adminPlugin.findClientPrompt(m[0], client)
if sclient:
self.console.say('^2%s ^3says: %s %s' % (client.name,\
random.choice(self._p2p_cmddict[cmd.command]),\
sclient.name))

else:
client.message(self._cmddict[cmd.command])



MoreSpam.xml
Code: xml [Select]

<configuration plugin="MoreSpamPlugin">
<!--
Set your custom Player to Player-say commands here.
These commands take a player name(or part of it) i.e. !lol d0nin380
Anything after '-' in the name is an alias.
The number "2" in <set name="lol">2</set> is the access level, check plugin_admin.xml for available levels.
-->
<settings name="commands-p2p">
<set name="lol">2</set>
<set name="sitdown-sd">2</set>
<set name="niceshot-ns">2</set>
</settings>

<!--
Set in these settings the commands you want ppl to be able to see in PM.
!forum will pm the user the same message as if you typed !spam forum.
Anything after '-' in the name is an alias.
The number "0" in <set name="forum">0</set> is the access level, check plugin_admin.xml for available levels.
-->
<settings name="commands">
<set name="forum">0</set>
<set name="ts">2</set>
</settings>

<!--
***SET ALL YOUR RESPONSES IN HERE***. Multiple random entries comma separated or just a single response.
responses/name must be the same as commands-p2p/name or commands/name
Remeber to add the command alias here.
-->
<settings name="responses">
<set name="lol">That was hilarious, I cannot stop laughing, You are so funny, You made my day</set>
<set name="niceshot-ns">Nice shot, Awesome shot, That was a heck of a shot</set>
<set name="sitdown-sd">Sit down</set>
<set name="forum">Our forum is located @: www.tce-massa.com/forum</set>
<set name="ts">^2Our public ^3TS3(voicechat)^7: ^2tce-massa.com:9987</set>
</settings>

<!--
Add your help messages here.
When an user types !help lol, B3 will PM them "!lol PlayerName".
If you leave the help-message empty, B3 will PM the user just "!lol"
-->
<settings name="help-messages">
<set name="lol"> PlayerName</set>
<set name="niceshot"> PlayerName or !ns PlayerName</set>
<set name="sitdown"> PlayerName or !sd PlayerName</set>
<set name="forum"> - Display the location of our forum</set>
<set name="ts"> - Display the information of our TeamSpeak 3 voicechat.</set>
</settings>

</configuration>
« Last Edit: March 24, 2011, 10:33:46 PM by d0nin380 »

Offline MaSTaKiLLaH

  • Newbie
  • *
  • Posts: 2
Re: MoreSpam plugin
« Reply #1 on: February 22, 2013, 06:11:36 PM »
Awesome plugin, exactly what I was looking for.
Works with 1.9.0 beta and BF3 perfectly.

Thanks.

Offline d0nin380

  • Full Member
  • ***
  • Posts: 56
Re: MoreSpam plugin
« Reply #2 on: February 22, 2013, 08:58:12 PM »
Awesome plugin, exactly what I was looking for.
Works with 1.9.0 beta and BF3 perfectly.

Thanks.

Glad you like it! If you have any problems or ideas how to make it better just let me know and I'll see what I can do..

Offline d0nin380

  • Full Member
  • ***
  • Posts: 56
Re: MoreSpam plugin
« Reply #3 on: April 02, 2013, 03:53:29 AM »
Plugin updated

Quote
# CHANGELOG
# 2011/03/23 - 1.0.0 - d0nin380
# * Initial Release
# 31/03/2013 - 1.0.1 - d0nin380
# * Fixed plugin name
# * multiple entries separated by semicolon instead of comma
#

 


Rate this page +1 at Google Search