Parsing PuTTY IRC Chat - python

So I want to make a program to monitor an irc chat and send the user an email if their name is mentioned.
I'm wondering if it is possible to output the irc chat messages to a txt file? I'd like to use Python if possible.
The irc chat is a WeeChat. I'm not going to lie, I haven't been programming very long so I'm pretty clueless. I also had the idea of capturing the memory with Cheat Engine but that seems like a pretty terrible solution and I'd prefer if it can run on Linux. I also had a look at mIRC scripting which could work maybe?
UPDATE:
I can log the output of the chat using PuTTY logging feature, however the output is really hard to read and parse:
22[33m:[39m12[33m:[39m07 [1m[32m#[36mUSERNAMECENSORED[0m [32m| [39m"Two software developers are required, for[7C[34m│[1m[39m[32m#[0mUSER[58D[32m| [39mstudent summer positions, to write RESTful web [34m│[1m[39m[32m#[0mUSER[32m| [39mservices in Python using the Django REST[9C[34m│[1m[39m[34m [0mUSER[6;20H[32m| [39mframework. The application being developed is a [34m│[1m[39m[34m [0mdanielrb[7;20H[32m| [39mfinancial accounting system. Therefore, a[8C[34m│[1m[39m[34m [0mDee[56D
[32m| [39mknowledge of accounting is a distinct advantage. [34m│[1m[39m[34m [0meoghanc[60D[32m| [39mApplicants will be required to attend an[9C[34m│[1m[39m[34m [0mUser[10;20H[32m| [39minterview which will include technical[11C[34m│[1m[39m[34m [0mME[59D[32m| [39massignments. As well as training and experience, [34m│[1m[39m[34m [0mmtlight[60D
[32m| [39mthe[46C[34m│[1m[39m[34m [0mshane
22[33m:[39m12[33m:[39m09 [1m[32m#[36mUser[0m [32m| [39mpositions offer €400 per week for the successful [34m│[1m[39m[34m [0msherkin[60D[32m| [39mcandidates."[37C[34m│[1m[39m[34m [0myensil22[33m:[39m17[33m:[39m03 [1m[32m#[36mUSER[0m [32m| [39mIt's only two months of work (approx) though :/ [34m│
[39m22[33m:[39m27[33m:[39m52 [1m[32m#
How would I parse this so I can tell when a user is mentioned and read the message as a string?

Related

is there a way to read iphone messages through python?

I am working on a project that requires the program to take in text received via SMS. But, whenever I look on the internet, I find services like twilio, which works only through an external number. That is, one may send a text to the twilio number so that the python program may receive and process it.
For my purposes, I intend people texting me through my personal number, and python accessing the body of that text for processing. Is there any way to do this? (PS: i don't have a mac)
You might want to look into this. It’s not in python, but there having a solution in python isn’t that simple, hence not that popular

How do I keep my code obfuscated from my enterprise client?

Software these days can be separated into two categories: runs on client infrastructure (like in the case of enterprise software, like Splunk or Tibco), OR runs on the infrastructure of a software provider (like in the case of Facebook, where you need to use their API to access the backend).
In the first category, the client pays for a license and receives the software to run on their own machines on their premises of choice. The client IS in possession of the actual code and software.
In the second category, the software resides somewhere external and can be accessed only by an API. The client is NOT in possession of the software and can only use it to the extent allowed by the API.
My question is: in the first category above, how is the actual code kept hidden from the client?
Let's say I've built a really awesome analysis engine in Python for analyzing output logs. A corporate client is interested in using it for their internal applications. However, they insist that my engine must run on their own machines for security reasons. If I succumb and give them my Python code, then I will risk my intellectual property.
In that case, do I need to rewrite all my code into a compiled language like C++ to obfuscate it during compile time? Or is there a way to keep it in Python but secure the source code it in another way?
Update:
Given the answers below, in that case, would the more efficient pathway to developing a client-hosted application (i.e.: first category above) be to write a proof of concept in a more convenient language like Python first, and then take those ideas and rewrite it into C++?
The short answer is that you pretty much can't. You can do workarounds, but in the end almost anyone can reverse engineer your code no matter how you obfuscate it.
Your best bet might be to use something like PyInstaller and see if you can only include .pyc files. That doesn't protect you all the way, but it at least makes it a pain to reverse. You might even be able to find an obfuscater to run it first, but I don't know much about that part.
Similar to #gabeappleton's suggestion above, compile the Python code into an EXE. I use cx_freeze quite regularly and have good success. It's pretty well documented and reasonable support on these forums.

Speech recognition for python, raspberry pi

This is a really big ask but I have tried for about 4 months now trying to get this to work. So, I am creating a personal assistant using a raspberry pi 3 model B and python (I know they are not the best of choices). Most of it works apart from the main feature, the speech to text (STT). I would like it to convert all spoken words to text and when you finish a sentence I would like it to enter and finish so the text can be processed as a string. Do you have any suggestions on what I could use to do this or any links to help me.
Thanks in advance.
I have completed similar project to yours recently.
If internet connection is not a problem for you, I would suggest using Wit.ai. It has nice Python API, or you could use it through HTTP API.
Your assistant would have to record speech, then send data to remote API and receive response with text as an answer.
Take into account, that STT process is quite complex, so trying to solve it with local solutions might be a bit too much to cope with for Raspberry. What's more, you would have to (probably) prepare vocabularies, etc. Using remote STT service, you don't have to do that.
If you cannot, or do not want to use remote service, you can always try CMU Sphinx. But for that, you need somebody else to help you with it, as I have no experience using it whatsoever.

Using BaseHTTPServer as server and integrating another language in

Is it possible to use Python to make a server and use another coding language to create a client side program? I'm using Director 8.5/10 (Made by Adobe, much similar to FlashPlayer) and the server on this scripting language is quite bad. I'm mainly looking for something that will point me in the right direction on what to search for, haven't had much luck w/ google. The server I apparently used last time (found an old .py script I had) utilized the BaseHTTPServer module. Is this the one I should be using for basic data transfer of .txt files for a game?
If worst comes to worse than I'll probably use Java/C++ but I'm hoping I will not have to. Director compiles the source code to a .exe (called a projector) or a shockwave file if that makes any difference. I'm tired of using multiusr.xtra for Director, not only is it slow it only allocates 1000 connections. Any help is much appreciated
Yes, you can create a server and a client in totally different languages and on totally different platforms as long as they exchange data in an agreed upon format. Generally these days the format of choice is JSON though XML was a popular format in the past. Understand that in both cases you're not sending "files" but text data.
You may want to read up on RESTful APIs which are a standard way of representing web services these days.

newbie: writing backend code for website

I am usually working in fields of machine learning and hence my background is mostly in stats/ML and no formal web background.
Usually for my project, I work on python which is connected to my local mysql db... to fetch data adn everything.
Now, my work is mostly complete.. everything is console based..
(like traditional programs).
How do I integrate it on the front end. I understand that this is more like a server side scripting.
So, lets take an example of google.
In the front end.. someone enters a search query.. and in the backend lets say there is a program in C++ which executes that query.
How did this interaction takes place.. if front end is written in lets say php..
I assume shell execution of program is a bad bad way to run programs.. ??
Any suggestion will be greatly appreciated.
Thanks
As suggested by Ignacio, you will first need to design API for your project. This is basically clearly laying out what (and how) queries will be supported for your project.
You don't need shell execution and neither need to learn PHP. Since your project is in Python, you can use Python Web-frameworks like Django, Web2Py.
The first thing to do is to develop an API for your library. From there you can develop multiple frontends that use the same API in order to present it multiple ways.
Decouple your user interface logic from your business logic, then reuse the business logic libraries in an application that accepts input over HTTP instead of the console. Django is a popular web framework that will take care of a lot of the front end concerns for you, or you can use something like CGI if you prefer to be a bit closer to the bare metal. The Python Wiki has a section on web programming that you might find useful.

Categories