thankyou
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: Telnet plugin  (Read 24527 times)

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Telnet plugin
« on: June 08, 2011, 09:41:53 PM »

description
Makes your B3 bot a telnet server.

You can then connect to your bot with your favorite telnet client and issue B3 commands or chat with online players.

To login through telnet you need to use your B3 id (the one that would start with '@' in-game) and your password. To set your password, either do manually with phpmyadmin (look at table Clients) or use the password plugin : https://github.com/xlr8or/b3-plugin-password/zipball/master

Requires Python 2.7

download - RSS feed
« Last Edit: November 21, 2012, 11:15:14 PM by Courgette »

Offline Freelander

  • XLRstats dev.
  • Dev. Team
  • Hero Member
  • *
  • Posts: 1000
Re: Telnet plugin
« Reply #1 on: June 08, 2011, 11:48:43 PM »
Cool plugin!  ;D

Offline Prez

  • Beta Testers
  • Full Member
  • *
  • Posts: 118
    • cgs-clan.com
Re: Telnet plugin
« Reply #2 on: June 09, 2011, 12:09:04 AM »
Nice! I'll have to check that out.

Offline Hellwing

  • Jr. Member
  • **
  • Posts: 18
  • BsK Legion
    • BaseShock
Re: Telnet plugin
« Reply #3 on: June 09, 2011, 06:10:37 AM »
Awsome!!!
BsK Legion

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Telnet plugin
« Reply #4 on: June 10, 2011, 10:38:12 PM »
v1.4 released. Fix an issue when connecting from putty and assume your passwords are stored encrypted

Offline neatherstalker

  • Jr. Member
  • **
  • Posts: 13
Re: Telnet plugin
« Reply #5 on: July 09, 2011, 02:12:16 AM »
May be a silly question...... but is the ip for this (if none specified) the b3 bots ip? or is it the servers Ip?

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Telnet plugin
« Reply #6 on: July 09, 2011, 02:23:25 AM »
it has to be the b3 bot ip

Offline BetterDeadThanZed

  • Beta Testers
  • Hero Member
  • *
  • Posts: 681
    • Killin Zeds
Re: Telnet plugin
« Reply #7 on: July 09, 2011, 08:14:17 PM »
Dont know how I missed this one. I'll have to install this.

Offline BetterDeadThanZed

  • Beta Testers
  • Hero Member
  • *
  • Posts: 681
    • Killin Zeds
Re: Telnet plugin
« Reply #8 on: July 11, 2011, 03:01:50 AM »
There's something wrong with the plugin. There is no telnet.py file in the "extplugins" folder in the archive. The archive has this format:

conf folder
plugin_telnet.xml

telnet folder
__init__.py
telnetserver.py
-dpkt subfolder
__init__.py
telnet.py

Your readme says nothing about a telnetserver.py file and the telnet.py file is in the wrong folder.

*edit*

Also, I installed the "setpass" plugin and it doesn't seem to do anything after I issue the command:

Code: [Select]
110710 20:50:25	CONSOLE	'305:16 say;01100001b6f95025;1;[GK]GrossKopf;\x15!setpass (password) (username)'
110710 20:50:25 VERBOSE 'Queueing event Say !setpass  (password) (username)'
110710 20:50:25 DEBUG 'AdminPlugin: OnSay handle 5:"!setpass  (password) (username)"'
110710 20:50:25 DEBUG 'AdminPlugin: Handle command !setpass (password) (username)'
« Last Edit: July 11, 2011, 03:06:38 AM by GrossKopf »

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Telnet plugin
« Reply #9 on: July 11, 2011, 07:55:51 AM »
thanks for the report. Readme file updated. It should now read
Quote
copy the telnet folder into b3/extplugins

setpass plugin ? I'm unaware of such a plugin

Offline BetterDeadThanZed

  • Beta Testers
  • Hero Member
  • *
  • Posts: 681
    • Killin Zeds
Re: Telnet plugin
« Reply #10 on: July 11, 2011, 01:54:56 PM »
thanks for the report. Readme file updated. It should now read
setpass plugin ? I'm unaware of such a plugin

I'm referring to the password plugin you linked to in the first post:

Quote
use the password plugin : https://github.com/xlr8or/b3-plugin-password/zipball/master

EIDT

Also, since that's the folder structure, should the b3.xml look like this:

<plugin config="@b3/extplugins/conf/telnet/dpkt/plugin_telnet.xml" name="telnet"/>
« Last Edit: July 11, 2011, 02:03:08 PM by GrossKopf »

Offline Kikker916

  • Full Member
  • ***
  • Posts: 64
Re: Telnet plugin
« Reply #11 on: July 31, 2011, 08:19:50 PM »
Dear Courgette,

I was excited once i saw this plugin  ;D,

i have been testing it,
and found some bug(s) which should be fixed in the main version.

bug #1:
!telnetkick (#id) doesn't work since it searches for connected clients (ingame)

before fix:
Code: [Select]
    def cmd_telnetkick(self, data, client, cmd=None):
        sclient = self.findClientPrompt(cid, client)
        if sclient:
fix:
Code: [Select]
    def cmd_telnetkick(self, data, client, cmd=None):
        sclient = self.findClientPrompt(cid, client)
        if not sclient:
            for k, v in self.telnetClients.iteritems():
                if int(k) == int(cid):
                    sclient = v

        if sclient:

bug #2:
in the code _newClient(self, client):
once a client connect it gets an new number which is taken from the size of already connected players, the problem here is as follows:

client 1 connect > id # 1
client 2 connect > id # 2
client 1 diconnect
client 3 connect > id # 2 (see below)

Code: [Select]
    def _newClient(self, client):
        me = self.telnetClients
        client.cid = len(me) + 1
this code will overwrite already owned values, which make already connected clients 'invisible',

fix:
Code: [Select]
    def onLoadConfig(self):
        self._telnetClientNextId = 1;

        # get the admin plugin so we can register commands
        self._adminPlugin = self.console.getPlugin('admin')
     /////////////
       other part
    /////////////

    def _newClient(self, client):
        me = self.telnetClients
        cid = self._telnetClientNextId
        self._telnetClientNextId += 1

        client.cid = cid
this fix, should give every connected & authenticated client an unique id (1,2,3 ....)
Tip or suggestion:
if you enter random text as message,
it would be nice if b3 verify if the client is allowed to use the !say command,


Just to notice,
i really love this plugin,
just some bugfixes & it would rock.

Greets,
Kikker916
« Last Edit: June 25, 2015, 10:21:58 AM by Kikker916 »

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4882
    • Github repository
Re: Telnet plugin
« Reply #12 on: July 31, 2011, 08:48:41 PM »
Hi,

First thank you for your comments :)

bug #1 : not a bug (or not the one you describe) as the self.findClientPrompt() is a method of the telnet/__init__.py file which looks for clients in self.telnetClients already.
If in your test the !telnetkick command does not find a telnet client, then the bug must be in https://github.com/thomasleveil/b3-plugin-telnet/blob/master/extplugins/telnet/__init__.py#L226 instead. It would be nice to have a b3.log to trace what happened in your test.

bug #2 : I have no time to reproduce / dev a patch / properly test any time soon. A quick untested patch is available at https://gist.github.com/1117071/daf5292f67b41517e6b249a9ae90b4551903094f . Could you please try it out and confirm it does not introduce any regression and fixes this issue ?

Quote
if you enter random text as message,
it would be nice if b3 verify if the client is allowed to use the !say command,
No time for that either however I will welcome any patch that would implement that feature (or better fork the project on github and make a pull request from your github account)

« Last Edit: November 21, 2012, 11:12:54 PM by Courgette »

Offline Kikker916

  • Full Member
  • ***
  • Posts: 64
Re: Telnet plugin
« Reply #13 on: July 31, 2011, 09:47:27 PM »
bug #1 : I found out that the function findClientPrompt() doesn't work,
it keeps returning 'None' as information,
once i edited the function call to 'self.findClientPrompt(m[0], client)'
it was able to kick telnet clients by name.
but i still had the bug once i did '!telnetkick 3' it din't responded.
so for that one, i keep using my old fix.

bug #2 : Solved with your fix.

Issue: this plugin doesn't work on b3 1.4.1.

Issue: this plugin doesn't work on python 2.6.
Code: [Select]
110801 14:55:13	BOT    	'www.bigbrotherbot.net (b3) v1.6.1 [posix] [Sedici]'
110801 14:55:13 BOT    'Python: 2.6.7 (r267:88850, Aug  1 2011, 14:43:28) \n[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]'
110801 14:55:13 BOT    'Default encoding: ascii'
110801 14:55:13 BOT    'Starting Cod2EParser v1.2.5 extended for server *'
110801 14:55:32 DEBUG u'TelnetPlugin: Telnet Client Connected: [66] Selbie!! - *.*.*.*'
110801 14:55:34 INFO 'TelnetPlugin: options : {}'
110801 14:55:34 CONSOLE '66\t: /who'
110801 14:55:34 ERROR 'TelnetPlugin: [\'Traceback (most recent call last):\', \'  File "/b3/extplugins/telnet/telnetserver.py", line 154, in handle\', \'    self.processor.process(l)\', \'  File "/b3/extplugins/telnet/telnetserver.py", line 324, in process\', \'    return func(arg)\', \'  File "/b3/extplugins/telnet/telnetserver.py", line 375, in cmd_who\', \'    since = timedelta(seconds=int(tmp.total_seconds()))\', "AttributeError: \'datetime.timedelta\' object has no attribute \'total_seconds\'"]'
110801 14:55:39 INFO 'TelnetPlugin: options : {}'
110801 14:55:39 CONSOLE '66\t: !telnetlist'
110801 14:55:39 DEBUG 'AdminPlugin: OnSay handle 7:"!telnetlist"'
110801 14:55:39 DEBUG 'AdminPlugin: Handle command !telnetlist'
110801 14:55:39 ERROR 'TelnetPlugin: [\'Traceback (most recent call last):\', \'  File "/b3/extplugins/telnet/telnetserver.py", line 154, in handle\', \'    self.processor.process(l)\', \'  File "/b3/extplugins/telnet/telnetserver.py", line 329, in process\', "    adminPlugin.OnSay(self.plugin.console.getEvent(\'EVT_CLIENT_PRIVATE_SAY\', line, self.client))", \'  File "/b3/plugins/admin.py", line 368, in OnSay\', \'    results = command.execute(data, event.client)\', \'  File "/b3/plugins/admin.py", line 2010, in execute\', \'    self.func(data, client, copy.copy(self))\', \'  File "/b3/extplugins/telnet/__init__.py", line 185, in cmd_telnetlist\', \'    since = timedelta(seconds=int(tmp.total_seconds()))\', "AttributeError: \'datetime.timedelta\' object has no attribute \'total_seconds\'"]'

Idea : I have an 'first' version which isn't perfect but it's working correctly ;)
Code: [Select]
 /* class 'TelnetCommandProcessor' function 'process' file: 'telnetserver.py'
unde the else statement (last one) */

        else:
            adminPlugin = self.plugin.console.getPlugin('admin')
            command = adminPlugin._commands['say']
            if b3.plugins.admin.Command.canUse(command, self.client):
                self.plugin.console.say("[%s] %s" %(self.client.name, line))
            else:
                self.client.message("Sorry, you don't have acces to the command !say")

/* this require to import b3 above in the *.py file */
« Last Edit: August 01, 2011, 02:58:10 PM by Kikker916 / Selbie »

Offline [DAD]GrimReaper

  • Full Member
  • ***
  • Posts: 128
Re: Telnet plugin
« Reply #14 on: August 16, 2011, 06:04:01 PM »
Hi

I am running the 1.7.0 standalone Beta and once I installed the plugin I am receiving the following error:

Code: [Select]
110816 17:02:41	BOT    	'Loading Plugin #20 telnet [M:\\B3_Cod4\\extplugins\\conf\\telnet\\dpkt\\plugin_telnet.xml]'
110816 17:02:41 INFO 'Could not load built in plugin telnet (No module named telnet)'
110816 17:02:41 INFO 'trying external plugin directory : M:\\B3_Cod4\\extplugins'
110816 17:02:41 CRITICAL 'Error loading plugin: No module named SocketServer'
Traceback (most recent call last):
  File "b3\parser.pyo", line 604, in loadPlugins
  File "b3\parser.pyo", line 717, in pluginImport
  File "M:\B3_Cod4\extplugins\telnet\__init__.py", line 53, in <module>
  File "M:\B3_Cod4\extplugins\telnet\telnetserver.py", line 25, in <module>
ImportError: No module named SocketServer

Any Ideas?

 


Rate this page +1 at Google Search