Giter Club home page Giter Club logo

Comments (5)

thomasleveil avatar thomasleveil commented on July 22, 2024

Have you tried editing the .ini file with a text editor capable of inserting ASCII control characters ?

You could give a try with Notepad++.

B3 also understand plugin config files expressed as XML files like the two equivalent examples below

[settings]
minplayers: 3
suicide_penalty_percent: 0.05
<configuration>
        <settings name="settings">
                <set name="minplayers">3</set>
                <set name="suicide_penalty_percent">0.05</set>
        </settings>
</configuration>

But that won't be a solution in your case as the XML spec forbid the use of ASCII control characters.

Another solution might be modify the CS:GO B3 parser to convert Quake3 color codes into CS:GO color codes.
For reference:

#define S_COLOR_BLACK        "^0"
#define S_COLOR_RED        "^1"
#define S_COLOR_GREEN        "^2"
#define S_COLOR_YELLOW        "^3"
#define S_COLOR_BLUE        "^4"
#define S_COLOR_CYAN        "^5"
#define S_COLOR_MAGENTA        "^6"
#define S_COLOR_WHITE        "^7"

as found at https://github.com/ioquake/ioq3/blob/master/code/qcommon/q_shared.h#L408

from big-brother-bot.

syrm avatar syrm commented on July 22, 2024

I propose this patch :

--- csgo.py.org 2014-01-10 20:53:08.960555829 +0100
+++ csgo.py     2014-01-10 20:58:30.340569128 +0100
@@ -591,12 +591,16 @@
         return mlist


+    def colorMessage(self, m):
+        return chr(int(m.group(1)))
+
     def say(self, msg):
         """\
         broadcast a message to all players
         """
         if msg and len(msg.strip()):
             template = 'sm_say %s'
+            msg = re.sub('\^([2-9])', self.colorMessage, msg)
             if "B3 Say" in self.sm_plugins:
                 template = 'b3_say %s'
             else:
@@ -611,6 +615,7 @@
         """
         if msg and len(msg.strip()):
             template = 'sm_hsay %s'
+            msg = re.sub('\^([2-9])', self.colorMessage, msg)
             if "B3 Say" in self.sm_plugins:
                 template = 'b3_hsay %s'
             else:
@@ -626,6 +631,7 @@
         if not client.hide: # do not talk to bots
             if msg and len(msg.strip()):
                 template = 'sm_psay #%(guid)s "%(msg)s"'
+                msg = re.sub('\^([2-9])', self.colorMessage, msg)
                 if "B3 Say" in self.sm_plugins:
                     template = 'b3_psay #%(guid)s "%(msg)s"'
                 else:
@@ -1105,4 +1111,4 @@
             return matches[0]
         else:
             # multiple matches, provide suggestions
-            return matches
\ No newline at end of file
+            return matches

from big-brother-bot.

thomasleveil avatar thomasleveil commented on July 22, 2024

can't you make this a pull request against BigbrotherBot/[email protected] ?

from big-brother-bot.

thomasleveil avatar thomasleveil commented on July 22, 2024

a more DRY implementation would be

@staticmethod
def colorMessage(msg):
    return re.sub("\^([2-9)])", lambda m: chr(int(m.group(1))), msg)

then its usage would just be

msg = self.colorMessage(msg)

Is there a reason why you don't convert ^0 and ^1 ?
also \x09 is the same as \t or the horizontal tab character. Is this an issue with CS:GO ?
finally, according to this document the color character needs to be preceded by a space, in that case shouldn't the be

def colorMessage(msg):
    return re.sub(" ?\^([2-9])", lambda m: " " + chr(int(m.group(1))), msg)

from big-brother-bot.

danielepantaleone avatar danielepantaleone commented on July 22, 2024

Color codes have been removed from the CS:GO parser in this commit: a6cd5cb
I guess we can close this issue as well.

from big-brother-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.