How to auto copy paste between different channels on different network in mIRC, if it matches predefined word? - mirc

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 &timestamp < &+ &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
}

Related

mIRC chat bot doesn't acknowledge commands

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.

Varnish redirect based on browser language settings

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);
}
}

mIRC 'null' delimiter for $gettok

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! Только на английском языке в чате!
}
}

How do I port a shell script to Perl?

This is a shell script , How do I accomplish the same thing in Perl?
prfile=~/sqllib/db2profile
profile()
{
if [ -f $prfile ] && [ "$prfile" != "" ];
then
. $prfile
else
read -p "Enter a valid Profile : " prfile
profile
fi
}
profile
Here it checks for the profile file , if found it executes it with . $prfile else it again asks user for the proper profile file
Update
#!/usr/bin/perl
use strict;
use warnings;
my $profile = "$ENV{'HOME'}/sqllib/db2proile";
# default profile
while (not -e $profile) { # until we find an existing file
print "Enter a valid profile: ";
chomp($profile = <>); # read a new profile
}
qx(. $profile);
This worked. I want the home directory to be dynamic rather than hardcoded as they differ for different machines. I'm just trying to accomplish with Perl what I have achieved with shell.
If I understand your objectives, I don't think you can use perl to accomplish this because perl will be running as a child process and it can not change the environment of your shell (it's parent process). Maybe this would work for you (untested, off the cuff)?
prfile=~/sqllib/db2profile
if [ -s "$prfile" ] ; then
. "$prfile"
else
while true ; do
read -p "Enter a valid Profile : " prfile
if [ -s "$prfile" ] ; then
. "$prfile"
break;
fi
done
fi

mIRC Script snippet misfirigin

Whenever somebody just types ! point the snippet runs through all of its commands for some reason I'm trying to find what causes this to happen, so far I cannot find the issue in the code
alias -l sd { return " $+ $scriptdir $+ $$1 $+ " }
on $*:text:/^!(monday|tuesday|wednesday|thursday|friday|saturday|sunday|website|food|touchy|sakura|Bass|bacon|snickers|bot|quiz|quizrules|NYE|NYD|stop|dance|Leta|back|sways|ladies|enters|choice|lounge|hiphop|fault|country|piano|rocks|diva|diva1|hello|sassy|hips|bounces|woot|kiss|pops|wiggle|greets|gotit|phone|next|cheeky|dj|xmas|here|guitar|twist|dj1|facebook|cheeky1|jig|birthday|thanks|chacha|moves|fleshies|aerial|drinks|heifer|dances|tap|chacha1|jam|hairbrush|hairbrush1|hairbrush2|reggae|lmfao|accept|hairbrush3|touch|no|music|tinbot|buffering|fleshie1|brat|2step|twirls|vote|whistle|hohey|scripted|botgurl|shows|phone1|laughs|me|crazy|shares|rani|takes|hour|mj|elvis|profiles|song|sweet|brightie|fire|passenger|lr|)$/Si:#:{
if (!%f) { inc -u6 %f
if ($isfile($sd(timetable.txt))) { .play $+(-t,$regml(1)) # $sd(timetable.txt) 50 }
else { msg # Either timetable.txt doesn't exist or the txt file name doesn't match! }
}
}
menu * {
Ping-Pong:$iif(%pp,pingpongoff,pingpongon)
Anti-Idle:$iif(%antiidle,antioff,antion)
}
on 1:ping: { $iif(%pp,raw pong $1 wannaplaypingpong,) }
on 1:pong: { $iif(%pp,raw ping $1 wannaplaypingpong,) }
alias pingpongoff { unset %pp | echo -a Ping-Pong has been disabled. }
alias pingpongon { set %pp on | echo -a Ping-Pong has been enabled. }
alias antioff { timeridle off | unset %antiidle | echo -a Anti-Idle has been disabled. }
alias antion { .timeridle 0 120 scid -atM1 antiidle | set %antiidle on | echo -a Anti-Idle has been enabled. }
alias antiidle { .msg $status $me }
raw 401:*: {
if (connected isin $1-) && (%antiidle) { echo -s ***** SassIRC Anti-Idle | halt }
}
}
}
You have an error at the end of your regex.
...fire|passenger|lr|)$..
Which contain redundant last pipe |, remove it from the end and it will solve the problem.