Sorry if my title wasn't clear enough. I'm back for some more guidance!
I'm trying to set up a unique language kicking bot. The chats I moderate have influxes of Russian language chat spammers. So I was trying to set up a bot that kicks someone when they type in Russian. So I set this up:
alias -l russian.words { RETURN Л.Д.э.И }
ON #*:TEXT:*:#: {
IF ($nick isop #) return
VAR %x = $strip($1-) , %i = $numtok($russian.words,46)
WHILE (%i) {
IF ($istok(%x,$gettok($russian.words,%i,46),32)) {
raw -q mode # +b $wildsite
msg # $nick $+ , English in chat, please! Только на английском языке в чате!
msg # /timeout $nick 1
RETURN
}
DEC %i
}
}
The problem is that the bot checks for the russian letters only if they are 'on their own'. If the Russian letters are part of a larger sentence/word, the bot doesn't work.
I believe it's because of the delimiter in the $gettok, which is set at 32 (a space). However, when I change the delimiter to 0 (null), the bot doesn't work at all.
So right now, the only thing the bot kicks are people who use ONLY those specific letters. I want the bot to kick to anyone who uses those letters on their own or when in a sentence/word.
BTW, I've chosen these letters because they are considered the most common Russian letters that do not share the same letters as English.
Any help is appreciated.
try this
paste into a new remote file
on $#*:text:/(Л|Д|э|И)/iS:#:{
if ($nick !isop $chan) {
ban -k $nick 2 English in chat, please! Только на английском языке в чате!
}
}
Related
Below is some code I have written for my ever growing bird-related chat bot.
If I use the mIRC consolse, I can execute the alias blocks (eg. //fchirp [user] ), but for some reason, the bot doesn't acknowledge somebody typing "!chirp" from the main chat window. It doesn't even execute the first //echo statement in the on-text-event.
The weirdest part is: this code worked before and I've been using it regularly. I haven't changed any part of what is shown here aside from the //echo statements which I use for debugging.
addWorms and giveWorms are both aliases I wrote and function correctly on their own. The main issue I'm running into is get the bot to do anything at all when someone types"!chirp". (It should be noted that other unrelated on-text-events earlier in the code work just fine with identical syntax.)
alias fchirp {
/writeini chirp.ini $1 First $adate
/writeini chirp.ini $1 Last $adate
/writeini chirp.ini $1 Count 1
msg $chan /w $1 Welcome to the Nest! Thanks for checking in! :D
addWorms $1
msg $chan /w $1 Type !worms to see how many you have!
//echo -a first chirp
}
alias chirp {
var %a $readini(chirp.ini, $1, Count)
var %count $calc( %a + 1 )
if ( $readini(worms.ini, $1, Breed) == $null ) {
addWorms $1
//echo -a addWorms done
}
if ( $readini(chirp.ini, $1, Last) === $adate ) { msg $chan /w $nick You've already checked in today! BabyRage | halt }
/writeini chirp.ini $1 Last $adate
/writeini chirp.ini $1 Count %count
//echo -a last/count updated
if ( $calc( $readini(chirp.ini, $1, Count) % 5 ) == 0 ) {
giveWorms $1 10
msg $chan /w $1 Welcome back! Lucky day!
}
else {
giveWorms $1 5
msg $chan /w $1 Welcome back! Here's your worms! Don't forget to !hunt ! ^_^
}
//echo -a giveWorms
}
on *:TEXT:!chirp:#: {
//echo -a acknowledged
if ( $readini(chirp.ini, $nick, First) != $null ) {
//echo -a true
chirp $nick
}
else {
//echo -a false
fchirp $nick
}
msg $chan /w $nick Don't forget to !hunt for worms! :D
}
The Event catching can be interfere by two main reasons.
Error
You have an error above your code on the same remote file. e.g. missing bracket or syntax error.
Other event already been captured
mIRC will not process event that already been matched by another pattern on the same file.
example.ini
ON *:TEXT:* dog *: echo -ag This will be called if we wrote the word dog in a sentence.
ON *:TEXT:*:#: echo -ag This will be called
ON *:TEXT:*test*: echo -ag This will never be called. Even if we wrote the word test in sentence.
You can merge your TEXT events to handle both actions, although if they aren't logic related, i would separated them for another remote file.
on *:TEXT:*:#: {
if ($1- == !chirp) {
; In here put your code.
}
; Another code over here..
; Count some stuff in here..
}
Remark: / is useless on alias/popup/remote code, and it is just for identifying text vs commands for console mIRC window.
I am using varnish 4 in front of apache. I need requests made to deutsh.de coming from headers with the preferred language es or ca (unless it also has de or en) to be redirected to spanish.es.
Could somebody provide me with the appropriate syntax?
Thank you
So I managed to put together something in the file used to start varnish:
sub vcl_recv {
if((req.http.Accept-Language !~ "de" || req.http.Accept-Language !~ "en") && (req.http.Accept-Language ~ "es" || req.http.Accept-Language ~ "ca" || req.http.Accept-Language ~ "eu"))
{
return(synth(301,"Moved Permanently"));
}
}
sub vcl_synth {
if(req.http.Accept-Language ~ "es" || req.http.Accept-Language ~ "ca" || req.http.Accept-Language ~ "eu")
{
set resp.http.Location = "http://spanish.es";
return (deliver);
}
}
...This appears to work
I have slightly extended the proposed solution with some regex that guarantees that we dont have german or english as a higher prioritised language configured in the accept-language header.
To explain the regex I think it would be good to keep in mind how such an Accept-Language header might look like: Accept-Language: de-DE,en-US,es
To consider the preferences of the users the used regex searches for the provided language but at the same time ensures that none of the other offered languages will be found before.
The latter is achieved somewhat cryptically with a negative look ahead expression "(^(?!de|en).)*" to ensure that neither de, nor en appears before the "es|ca|eu" entry.
^ # line beginning
.* # any character repeated any number of times, including 0
?! # negative look-ahead assertion
Additionally I have added a check if SSL is already used to achieve the language and SSL switch in one redirect.
With the return(synth(850, "Moved permanently")); you save one if clause in the vcl_synth which will reduce your config a lot especially when you have to do many of those language based redirects.
sub vcl_recv {
if (req.http.X-Forwarded-Proto !~ "(?i)https" && req.http.Accept-Language ~ "^((?!de|en).)*(es|ca|eu)" {
set req.http.x-redir = "https://spanish.es/" + req.url;
return(synth(850, "Moved permanently"));
}
}
sub vcl_synth {
if (resp.status == 850) {
set resp.http.Location = req.http.x-redir;
set resp.status = 301;
return (deliver);
}
}
I'm a person with zero programming skill, thus everything related to programming seems like the hardest thing.
I wanted to auto copy paste between different channels on different network using mIRC, if it matches predefined word. For example:
My predefined word is: hello
If someone in #channelA (on network1) or #channelB (on network2) or #channelC (on network3) says hello, it will appear on #channel4 (on network4) as: said "hello" without channel's name or anything and no duplicate from rest of the networks(if said hello there as well) will appear on network 4's channel, i.e only first one will appear for each keyword.
I have tried searching for a solution and found this:
mIRC bot - copy/paste lines in 2 channels
But it's not helpful to me. Any guidance would be appreciated.
Usually we never built someone a script but asks him for what he done so far and then pointing him the failures or helping him a little bit.
But because the script you mentioned sounds nice, i took the liberty of implementing it myself.
If you not familiar with mSL i suggest you to only touch the following identifiers:FromNetwork, FromChannel, ToNetwork and ToChannel
Code
;###
;### TextPublisher v1
;### Author: Orel Eraki
;### Email: orel.eraki#gmail.com
;###
;### Usage:
;### - Pretty simple, just edit the identifier settings.
;### - For enable/disable change "TextPublisherEnable" identifier to 1 or 0
;### Settings
alias -l TextPublisherEnable return 1
alias -l TextPublisherFormat return ×tamp < &+ &nick &+ > &1-
alias -l TextPublisherMatchText return *text*
alias -l TextPublisherFromNetwork return Network1
alias -l TextPublisherFromChannel return #Channel1
alias -l TextPublisherToNetwork return Network2
alias -l TextPublisherToChannel return #Channel2
;### Functions
alias -l FindNetworkCid {
if ($1) {
var %i = 1, %n = $scon(0), %temp
while (%i <= %n) {
if ($scon(%i).status == connected && $scon(%i).network == $1) {
return $scon(%i).cid
}
inc %i
}
}
return
}
;### Events
on *:text:$($TextPublisherMatchText):$($TextPublisherFromChannel): {
if ($TextPublisherEnable && $network == $TextPublisherFromNetwork) {
var %networkId = $FindNetworkCid($TextPublisherToNetwork)
if (%networkId) {
scid -t1 %networkId if ($TextPublisherToChannel ischan) { msg $TextPublisherToChannel $eval($replace($TextPublisherFormat, &, $chr(36)), 2) }
}
}
}
This might help, Its taken from my Nick Mention and will work with any word you want. It comes up in the room you are in highlighted and also opens a new window and records what/who and time it was said. It may lead you in the direction you are looking for if it is not exactly what you are looking for..
;; Word mention ;;
on *:START: {
window -De #WordMention
echo #WordMention Your word mentioned and what was said goes here
}
on *:text:*:#:{
if (# == $active) halt
if (%me isin $strip($1-)) || ($me isin $strip($1-)) {
if (%mention. [ $+ [ $nick ] ] == $true) halt
echo -a 2,4 # $nick said : $1-
echo #WordMention =======================================
echo #WordMention 0,4 $+ $timestamp $nick said your word at $asctime(h:nn:sstt) in #
echo #WordMention $nick said: $1-
echo #WordMention =======================================
set -u10 %mention. [ $+ [ $nick ] ] $true
}
}
menu channel {
.Word mention ( $+ %mynick $+ )
..Set My word $iif(%me == $null,(no word set),( $+ %me $+ )):/set %me $$?="Enter word eg = word to watch for" | echo -a %me Set
..$iif(%myword == on,$style(2),$style(0)) On:/set %mynick on
..$iif(%myword == off,$style(2),$style(0)) Off:/set %mynick off
}
I am working with a perl based cgi pages for a webproject. I am encountering a strange problem with sendmail module which happens randomly.
Problem:
Sendmail would truncate the emails of the users appended at last. But not always, it happens randomly. I log the email list right before sending email and I don't see anything wrong.
Example Image (See Karl's last name is truncated at '.' after his first name.)
Headers for the email.
Message-ID: <201305221503.r4MF3dYf022792#pazmo.internal.company.com>
Subject: < ...>
MIME-Version: 1.0
Content-Type: text/plain
To: <biradavolu.ln#company.com>, <dessimira.ln#company.com>,
<yun.ln#company.com>, karl.
Date: Wed, 22 May 2013 10:03:39 -0500
From: <tool#company.com>
Return-Path: tool#company.com
X-MS-Exchange-Organization-AuthSource: eusaamw0712.domain.company.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 10
X-MS-Exchange-Organization-AVStamp-Mailbox: MSFTFF;1;0;0 0 0
The logged input before sending email: ( I don't see anything wrong with the format)
biradavolu.ln#company.com;dessimira.ln#company.com;yun.lastName#company.com;karl.LastName#company.com;
use Mail::Sendmail;
# Step 1: Declare the mail variable
%mail = (
from => 'test#company.com',
to => 'user1FN.user1LN#company.com;user2FN.user2LN#company.com;user3FN.user3LN#company.com;' . "$requester_email; $responsible_email",
subject => ... ,
'content-type' => "multipart/alternative; "
);
my $toList='user1FN.user1LN#company.com;user2FN.user2LN#company.com;user3FN.user3LN#company.com;' . "$requester_email;";
# Step 2: Add members to toList based on different conditions
if(condition1)
$toList= $toList.'user4FN.user4LN#company.com;';
if(condition2)
$toList= $toList.'user5FN.user5LN#company.com;';
... # few other similar condition statement
...
# Step 3: Assign toList based on different conditions
$mail{ 'to' } = $toList;
# Step 4: Set Body of the $mail
if(sendmail(%mail)){
print LOGFILE "Mail send successfully to $mail{\"to\"}: ";
}else{
print LOGFILE "Mail was not send : Mail list was $mail{\"to\"} : ";
}
Wild guess here. You're hiding the actual lastnames of your users (which is fine), but it could be possible that the "random" truncating is always happening on a user with a space in the last name? Like "St. Pierre". Your string might get truncated right at the space.
Let me know if that's possible!
I run a community site (built by hand using html, css, and php) for my wow guild. Recently, my members have demanded the ability to use tags like #username in their posts, which would then link to the users page. I already have this script, as listed below:
<?php
$string = '#user really?';
if (preg_match('/(^|\s)#([a-z0-9_]+)/i', $string))
{
$string = preg_replace('/(^|\s)#([a-z0-9_]+)/i', '#$2', $string);
echo $string;
}
else {
echo $string;
}
?>
This works fine, and I notice that the $2 is the user's name, but, since all user's names start with capital letters, the $2 needs to be capitalized, and not everyone does that. Is there a way to code it to automatically capitalize $2, or should I just tell users to remember to capitalize?
Thanx in advance,
Steven
use ucfirst ($2) to capitalize the first character
and strtoupper($2) if you want it all capital
I added more preg_replace and it now links to user no matter how u type name, as long as u have # symbol (#user, #USER, #User, #uSER, etc...). for anyone needing my solution, I will post it below:
<?php
$proper_str = "going to battle with #ADROK";
$proper_str = ucfirst(strtolower($proper_str));
$proper_str = preg_replace('/#[a-z]/e', 'ucfirst(strtoupper("$0"))', $proper_str);
$proper_str = preg_replace('/(^|\s)#([a-z0-9_]+)/i', ' #$2', $proper_str);
echo $proper_str;
?>
and if you change somethings around and make it:
<?php
$proper_str = "going to battle with e#mail.com";
if (preg_match('/(^|\s)#([a-z0-9_]+)/i', $proper_str))
{
$proper_str = ucfirst(strtolower($proper_str));
$proper_str = preg_replace('/#[a-z]/e', 'ucfirst(strtoupper("$0"))', $proper_str);
$proper_str = preg_replace('/(^|\s)#([a-z0-9_]+)/i', ' #$2', $proper_str);
echo $proper_str;
} else {
$proper_str = ucfirst("$proper_str");
echo $proper_str;
}
?>
Then it will leave email addresses alone and make sure first letter of post is capitalized!