|
|
Zeile 1: |
Zeile 1: |
− | ===wichtige Einstellungen===
| + | |
− | * min.-max. share (freigabe)
| + | Willkommen in der Beat-Box |
− | * min.-max. slots
| + | |
− | * IP-Adresse
| + | ...................................................Hub-Infos ................................................ |
− | * Motd - Massage of the Day - Info beim verbinden
| |
− | * Webserver - Info fuer den Hub-betreiber
| |
| | | |
| + | Das Kopieren fremder Inhalte zur privaten oder sonstigen, eigener |
| + | (auch geschäftlichen) Verwendung ist nach deutschem und schweizer |
| + | Recht zulässig. Laut dem Gesetzestext ist nicht zulässig, |
| + | die fremden Inhalte ohne Einwilligung des Urhebers wieder zu |
| + | veröffentlichen. Im Internet (World Wide Web) sind alle Seiten, die |
| + | nicht durch Paßworte geschützt sind, öffentlich! |
| + | Wer fremde Inhalte auf seine Web-Seiten stellt, diese |
| + | unzulässigerweise veröffentlicht dieses kann strafrechtlich verfolgt |
| + | werden und kann recht teuer werden. Allein die |
| + | GEMA & Urheberrechtsgesetz - Gebühren können einen arm machen |
| + | Ich hoffe, das euch das nicht zu sehr abschreckt! |
| + | |
| + | UND NOCH EINMAL, ICH DER BETREIBER DIESES HUBs/CHAT ÜBERNEHME |
| + | KEINE VERANTWORTUNG FÜR EUREN FESTPLATTENINHALT !!!!!!!! |
| + | |
| + | |
| | | |
− | ===zusätzliche skripte (nuetzliches und spass usw.) in der Programmiersprache Lua 5.0.2.===
| + | |
| | | |
− | ====Trivia Quiz-bot====
| + | Fragen zum Partnerhub bitte an Osiris oder die OP's wenden! |
− | <pre>
| |
− | -- Converted to Lua5 By Jelf 15/03/05
| |
− | -- Translated by Psycho Chihuahua 16/03/05
| |
| | | |
− | BotName = "Quiz"
| |
− | ScriptVersion = "WeimarnetzQuiz"
| |
− | BotVersion = BotName.." "..ScriptVersion
| |
| | | |
− | -- This file is not needed it will be created if it not exists
| |
− | strTrivScoreFile = "TriviaScores.dat"
| |
| | | |
− | -- This file is needed unless you want to run a Trivia with only two questions ;)
| + | Bitte beachtet: |
− | strDefTrivFile = "Trivia Fragen & Antworten.dat"
| + | Wer länger als 3 Wochen nicht im Hub |
− | strTrivFile = strDefTrivFile
| + | war wird gelöscht! Wer länger Abwesend ist |
− | strQFile = "Trivia Fragen & Antworten selfmade.dat"
| + | teilt es bitte ein OP mit, Danke! |
| + | |
| + | |
| + | |
| + | . *Regeln für unseren Hub* |
| | | |
− | -- This char will be the global separator? (Make it one that is not used in nicknames nor questions ;)
| |
− | strGSep = "*"
| |
| | | |
− | -- This char is used to mask the unrevealed chars | + | 01. Allgemein • (AD's) und (OP's) haben das letzte Wort....und generell Recht! |
− | strCMask = ""
| + | • max 10 HUbs |
| + | • Min. 2 Slots |
| + | • MinShare: 3 GB |
| + | • Kein Nazi, Tier oder Kinderporno im Share. |
| + | • Gesaugte Dateien sofort und min 2 Wochen lang sharen |
| + | • Entpackte Releases haben nix im Share verloren und sollten entfernt werden. |
| + | • Dateien anderer P2P Systeme können zu kick führen....! |
| + | • säubert euren Share von Torrentnamen |
| + | • Übersichtlichkeit ist Pflicht. Wirre Strukturen werden entfernt^^ |
| + | |
| + | 03. Wichtig: • Diskretion wird vorrausgesetzt |
| + | • Mainchatlogs werden nicht ausserhalb dieses Hubs kopiert. |
| + | • PMs ebenso |
| + | • Bereits der erste Verstoss hierzu führt zum Verlust des Accounts! |
| + | • Wer Werbung vorhat, kann die OPS auch gleich um delreg bitten |
| + | |
| + | 04. Sonstiges: • Regelmässige Onlinezeit wird vorrausgesetzt. |
| + | • Tragt in den Settings unter Email eure genaue Connection ein. |
| + | • z.B. DSL1000/128 - DSL2000/192 - DSL3000/384 |
| + | • Freundlichkeit den anderen Gegenüber wird als selbstverständlich angesehen. |
| + | • Die OPs haben dabei freien Ermessenspielraum |
| | | |
− | -- Default startup mode of Trivia!
| |
− | lngDefMode = 0 -- (0 = game is played in chat!, 1 = game is played in chat but questions only show for players, 2 = game is played in pm with players)
| |
− | lngMode = lngDefMode
| |
| | | |
− | -- Max number of questions to show when a Operator ask to see list Questions 0 = 0, -1 = Disabled | + | °°°°°°°°Wenn ihr euch nicht daran haltet, können warn, kick, ban oder delreg die Folge sein. Diskussionen sind sinnlos°°°°°°°° |
− | lngMaxShowList = 5
| + | .## |
| + | ,## |
| + | ##- ### |
| + | x##+ ; |
| + | ##. #+ |
| + | #### ######## |
| + | ;. .########### |
| + | ####+- ##########= |
| + | ;####. ## ,######- -#### |
| + | .##x, ## ,###= ######+ .## |
| + | #### # = ####### |
| + | -#- ######; ###x ### |
| + | -##### ## #+, .=##x## |
| + | x. ## x## |
| + | ####x. #######x; |
| + | ###### +############ |
| + | ;## ## #,# -###### |
| + | ####x ## =# ## =### |
| + | +############## ## ## ### |
| + | ############## ### ## ### |
| + | ### #########-#### ### -####### |
| + | ##### =##### ###### ############# |
| + | #######. ########### +###### ###- |
| + | ;## =###. #### -##########,#####- ### |
| + | ,###x+ ,####### ##### #######. ##### x### |
| + | x###### X#####, ##########. . x##### |
| + | ###=####+ .X##### +########.## # -X########- |
| + | ##+#######, ,#####x ,###### +## ##, .x############### |
| + | .+#####; +##### #### ; #####; ### ##################### |
| + | #-##### =##### .##+ ##==## ##X .#####= #####.### |
| + | ##-####;==#- -####x ## ####### ### ##-# ## ### |
| + | ################# .####; ##x######### ,### +#### ## +## |
| + | #####+ .#; +## #### ####; ### ##### ### |
| + | #####, ## .-###; ###x =#######- #=.## -########. |
| + | #####x, ;#, -#####X##X ###x #######,##### ###### -########### |
| + | #####+.. ## ######## -## ###= = ##### -######## # +##############= |
| + | #### # -######### + ,##;.###X##- x###X ;########### x### ##x#### |
| + | . ###x ## ## ######=###--X#+-##### #### ;+; ## ###;### #.##, |
| + | .# ### # ## #####x#-######X#### ### ,#. ### ##-## |
| + | #+## ## ## ################ ###-x### x# ### ## |
| + | ## # # ######### #-#####+#= #####;## .#+ +###+ #### , |
| + | ###x####. ## ######## ########.# #####= ### ##=.=+xx+=, +### #### ;#####- |
| + | x= =####x # ###### #-#####.# ## ### ### ## #################. #### -########## |
| + | .#####;;. =x# ##x#XX#x,= #####= ### ##x ###xx++x######## #####Xx;. =#############. |
| + | ##+X#####xx######xx+++X. -####; X##. ### ### ####. ############################### |
| + | =####X- .;;. ,### ### ## ## ###. #### ,=################################, |
| + | =##### .###### ##### ############.#X X### ###+## ### ##### X######################################### |
| + | ########## ######x###### -##### ## ####x ,## ###= ######## ###-. +################################# |
| + | ######, ;### ############# ########+ ######################## ;############################################, |
| + | ############ #### ### #### =######## ######x##########################X++x###################### .;-. |
| + | ############ #### # #####. ####. .## ###x .############. ,################# |
| + | -######## ###### #######-+########### ####################################++################### |
| + | ,, ., -############= =###############################+ |
| | | |
− | -- Max no of Hints per word, and always hit on a hidden char
| + | *************** So und nun viel Spaß Beat-Box *************** |
− | lngMaxHints = 4
| |
− | boolHintAlwaysHitHidden = nil -- (nil = off, 1 = on)
| |
− | | |
− | -- How much time before a question end. Time in Trivia is measured in 15 seconds, 1 = 15 seconds, 2 = 30 seconds etc!
| |
− | -- Rest is how long to rest after a question is solved depening on when the word is solved in the Timer loop it is 15 secs to the setting!
| |
− | lngMaxTime = 8 -- (Needs to be a multiple of 4 i.e. 4 / 8 / 12 / 16)
| |
− | lngRestTime = 2
| |
− | lngHintTime = lngMaxTime / 4
| |
− | | |
− | -- How often should the bot autosave the scores
| |
− | boolAutoSaveScores = 1 -- (nil = off, 1 = on)
| |
− | countSaveTurns = 10 -- After how many questions should the scores be saved
| |
− | | |
− | -- Should bot reveal the correct answer once time is up?
| |
− | boolRevealAnswer = 1 -- (nil = off, 1 = on)
| |
− | | |
− | -- Should the bot display what guess made the word become a little clearer if played in PM!
| |
− | boolShowGuessesInPM = 1 -- (nil = off, 1 = on)
| |
− | | |
− | -- Should the bot Auto Reveal Hints?
| |
− | boolAutoHint = 1 -- (nil = off, 1 = on)
| |
− | | |
− | -- Should the bot auto login every user on connect ?
| |
− | boolAutoLogin = nil -- (nil = off, 1 = on)
| |
− | | |
− | -- Do you want users to be able to add questions ? Operators can always add questions.
| |
− | boolAddQuestion = 1 -- (nil = No, 1 = Yes)
| |
− | | |
− | -- TriggStart is what char the commands should begin with I use ! but you can use # or whatever
| |
− | TriggStart = "#"
| |
− | | |
− | -- Theese are the different triggers I've tried to name them so that one easily understand what they do!
| |
− | -- I include TriggStart and then the word within "" this word is not casesensitive!
| |
− | JoinTrigg = TriggStart.."qmitmach"
| |
− | PartTrigg = TriggStart.."qraus"
| |
− | StartTrigg = TriggStart.."qstart"
| |
− | StopTrigg = TriggStart.."qstop"
| |
− | WordTrigg = TriggStart.."qwort"
| |
− | QuizTrigg = TriggStart.."qfrage"
| |
− | RestartTrigg = TriggStart.."qneustart"
| |
− | PointTrigg = TriggStart.."qpunkte"
| |
− | ScoreTrigg = TriggStart.."qergebnis"
| |
− | PlayerTrigg = TriggStart.."qspieler"
| |
− | QuestionsTrigg = TriggStart.."qfragen"
| |
− | ReloadTrigg = TriggStart.."qneuladen"
| |
− | HelpTrigg = TriggStart.."qhilfe"
| |
− | ExtraHelpTrigg = TriggStart.."qhilfe+"
| |
− | SaveTrigg = TriggStart.."qsicherergebnis"
| |
− | LoadTrigg = TriggStart.."qladeergebnis"
| |
− | ModeTrigg = TriggStart.."qmodus"
| |
− | HintTrigg = TriggStart.."qtip"
| |
− | TopTrigg = TriggStart.."qtopten"
| |
− | AddTrigg = TriggStart.."qfragedazu"
| |
− | | |
− | bcount = 0
| |
− | scount = 0
| |
− | sQuestion = ""
| |
− | sAnswer = ""
| |
− | guessArray = {}
| |
− | lngGuessmax = 0
| |
− | playerArray = {}
| |
− | pointArray = {}
| |
− | lngWord = 0
| |
− | lngPassed = 0
| |
− | lngHinted = 0
| |
− | strWord = ""
| |
− | strQuestion = ""
| |
− | strSolved = ""
| |
− | strBanner = "Schreibe '"..StartTrigg.."' um den Quizzbot zu starten, '"..StopTrigg.."' um den Quizzbot anzuhalten, '"..JoinTrigg.."' um am Quizz teilzunehmen und '"..PartTrigg.."' um das Quizz zu verlassen."
| |
− | strStart = "Quizzbot "..ScriptVersion.." gestartet! "..strBanner
| |
− | strStopp = "Quizzbot "..ScriptVersion.." angehalten! "..strBanner
| |
− | ----------------------
| |
− | function Main()
| |
− | frmHub:RegBot(BotName)
| |
− | ReloadQuestions()
| |
− | end
| |
− | ------------------------
| |
− | function NewUserConnected(curUser)
| |
− | if (boolAutoLogin) then
| |
− | if (not (playerArray[curUser.sName])) then
| |
− | playerArray[curUser.sName] = 1
| |
− | else
| |
− | playerArray[curUser.sName] = nil
| |
− | end
| |
− | end
| |
− | end
| |
− | ------------------------------
| |
− | function OpConnected(curUser)
| |
− | if (boolAutoLogin) then
| |
− | if (not (playerArray[curUser.sName])) then
| |
− | playerArray[curUser.sName] = 1
| |
− | else
| |
− | playerArray[curUser.sName] = nil
| |
− | end
| |
− | end
| |
− | end
| |
− | --------------------------------
| |
− | function UserDisconnected(curUser)
| |
− | playerArray[curUser.sName] = nil
| |
− | end
| |
− | --------------------------------
| |
− | function OpDisconnected(curUser)
| |
− | playerArray[curUser.sName] = nil
| |
− | end
| |
− | --------------------------------
| |
− | function ChatArrival(curUser, data)
| |
− | data = string.sub(data, 1, (string.len(data) - 1))
| |
− | if ((lngMode == 0) or (lngMode == 1)) then
| |
− | boolPlaydata = 1
| |
− | end
| |
− | GotoTriggs(curUser, data)
| |
− | end
| |
− | ----------------------------------
| |
− | function ToArrival(curUser, data)
| |
− | data = string.sub(data, 1, (string.len(data) - 1))
| |
− | local _, _, whoTo = string.find(data,"$To:%s+(%S+)")
| |
− | if (whoTo == BotName) then
| |
− | data = string.sub(data, (15 + string.len(BotName) + string.len(curUser.sName)))
| |
− | if (lngMode == 2) then
| |
− | boolPlaydata = 1
| |
− | local _, _, chat = string.find(data, "%b<>%s(.+)")
| |
− | SendChatToOthers(chat, curUser)
| |
− | end
| |
− | end
| |
− | GotoTriggs(curUser, data)
| |
− | end
| |
− | -------------------------------------------
| |
− | function GotoTriggs(curUser, data)
| |
− | local _, _, firstWord = string.find(data, "%b<>%s+(%S+)")
| |
− |
| |
− | if (firstWord ~= nil) then
| |
− | if ((string.lower(firstWord) == string.lower(HelpTrigg)) or (string.lower(firstWord) == string.lower(ExtraHelpTrigg))) then
| |
− | showHelp(curUser)
| |
− | elseif (string.lower(firstWord) == string.lower(SaveTrigg)) then
| |
− | if (curUser.bOperator) then
| |
− | SaveScores(curUser)
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(LoadTrigg)) then
| |
− | if (curUser.bOperator) then
| |
− | LoadScores(curUser)
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(TopTrigg)) then
| |
− | TopTen(user)
| |
− | elseif (string.lower(firstWord) == string.lower(AddTrigg)) then
| |
− | if (boolAddQuestion) then
| |
− | s,e,sQuestion,sAnswer = string.find(data, "%b<>%s+%S+%s+(.+)#(.+)")
| |
− | AddQuestion(curUser,sQuestion,sAnswer)
| |
− | elseif (curUser.bOperator) then
| |
− | s,e,sQuestion,sAnswer = string.find(data, "%b<>%s+%S+%s+(.+)#(.+)")
| |
− | AddQuestion(curUser,sQuestion,sAnswer)
| |
− | else
| |
− | SendToPlayers("Fragen koennen jetzt nicht hinzugefuegt werden.")
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(ModeTrigg)) then
| |
− | if (curUser.bOperator) then
| |
− | local _, _, ModeDigit = string.find(data, "%b<>%s+%S+%s+(%d+)")
| |
− | if (ModeDigit ~= nil) then
| |
− | lngMode = tonumber(ModeDigit)
| |
− | if (lngMode == 0) then
| |
− | SendToPlayers("Quizz wird im Mainchat gespielt")
| |
− | elseif (lngMode == 1) then
| |
− | SendToPlayers("Quizz wird im Mainchat gespielt aber Fragen koennen nur Quizzer sehen")
| |
− | elseif (lngMode == 2) then
| |
− | SendToPlayers("Quizz wird ueber PM gespielt")
| |
− | else
| |
− | SendToPlayers("Falscher Modus gewaehlt, wurde auf Voreinstellung gesetzt")
| |
− | lngMode = lngDefMode
| |
− | end
| |
− | end
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(JoinTrigg)) then
| |
− | if (not (playerArray[curUser.sName])) then
| |
− | playerArray[curUser.sName] = 1
| |
− | SendToPlayers(curUser.sName.." ist jetzt mit dabei!")
| |
− | else curUser:SendPM(BotName, "Du bist schon Mitspieler. Es kann sein das Du automatisch eingeloggt wurdest.")
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(PartTrigg)) then
| |
− | if (playerArray[curUser.sName]) then
| |
− | SendToPlayers(curUser.sName.." ist nicht länger Mitspieler!")
| |
− | playerArray[curUser.sName] = nil
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(RestartTrigg)) then
| |
− | if (curUser.bOperator) then
| |
− | SendToPlayers("Quizzbot neugestartet. Alle Punkte sind nun weg!")
| |
− | SendToPlayers("Wenn Du jetzt speicherst wird der alte Punktestand überschrieben!")
| |
− | pointArray = {}
| |
− | StopQuiz(1)
| |
− | end
| |
− | elseif ((string.lower(firstWord) == string.lower(PointTrigg)) and (playerArray[curUser.sName])) then
| |
− | if (pointArray[curUser.sName]) then
| |
− | SendToPlayers(curUser.sName.." Du hast "..pointArray[curUser.sName].." Punkte!")
| |
− | else
| |
− | SendToPlayers(curUser.sName.." Du hast 0 Punkte!")
| |
− | end
| |
− | elseif ((string.lower(firstWord) == string.lower(HintTrigg)) and (playerArray[curUser.sName])) then
| |
− | if ((lngWord ~= 0) and string.find(strSolved, strCMask, 1, plain)) then
| |
− | if (lngHinted < lngMaxHints) then
| |
− | for nn=1,bcount do
| |
− | local lngRepChar = math.random(1, string.len(strWord))
| |
− | while 1 do
| |
− | if (boolHintAlwaysHitHidden) then
| |
− | if (strsub(strSolved, lngRepChar, lngRepChar) == strCMask) then
| |
− | break
| |
− | end
| |
− | else
| |
− | break
| |
− | end
| |
− | lngRepChar = math.random(1, string.len(strWord))
| |
− | end
| |
− | local strTurn = ""
| |
− | for x=1, string.len(strWord) do
| |
− | if (x == lngRepChar) then
| |
− | strTurn = strTurn..string.sub(strWord, x, x)
| |
− | else
| |
− | strTurn = strTurn..string.sub(strSolved, x, x)
| |
− | end
| |
− | end
| |
− | strSolved = strTurn
| |
− | end
| |
− | lngHinted = lngHinted + 1
| |
− | lngHintTimeCount = lngHintTimeCount + lngHintTime
| |
− | SendToPlayers("Hinweis: "..strSolved)
| |
− | acount = ""
| |
− | else
| |
− | SendToPlayers("Alle Hinweise aufgebraucht!")
| |
− | end
| |
− | else
| |
− | SendToPlayers("Kein Hinweis gebraucht!")
| |
− | end
| |
− | elseif ((string.lower(firstWord) == string.lower(ScoreTrigg)) and (playerArray[curUser.sName])) then
| |
− | curUser:SendPM(BotName, "ERGEBNISSE:")
| |
− | curUser:SendPM(BotName, "---------------------------------------------------------")
| |
− | for index, value in pointArray do
| |
− | curUser:SendPM(BotName, index.."'s punkte: "..value)
| |
− | end
| |
− | curUser:SendPM(BotName, "---------------------------------------------------------")
| |
− | elseif ((string.lower(firstWord) == string.lower(PlayerTrigg)) and (playerArray[curUser.sName])) then
| |
− | curUser:SendPM(BotName, "SPIELER:")
| |
− | curUser:SendPM(BotName, "---------------------------------------------------------")
| |
− | for index, value in playerArray do
| |
− | curUser:SendPM(BotName, index)
| |
− | end
| |
− | curUser:SendPM(BotName, "---------------------------------------------------------")
| |
− | elseif (string.lower(firstWord) == string.lower(QuestionsTrigg)) then
| |
− | if (curUser.bOperator) then
| |
− | curUser:SendPM(BotName, "TOP "..lngMaxShowList.." FRAGEN:")
| |
− | curUser:SendPM(BotName, "---------------------------------------------------------")
| |
− | local lngShowMax = lngMaxShowList
| |
− | for index, value in guessArray do
| |
− | if (lngShowMax == 0) then
| |
− | break
| |
− | end
| |
− | arrTmp = tokenize(guessArray[index], strGSep)
| |
− | strTmp = arrTmp[1]
| |
− | curUser:SendPM(BotName, "["..index.."] "..strTmp)
| |
− | lngShowMax = lngShowMax - 1
| |
− | end
| |
− | curUser:SendPM(BotName, "Total # an Fragen: "..lngGuessmax)
| |
− | curUser:SendPM(BotName, "---------------------------------------------------------")
| |
− | curUser:SendPM(BotName, " ")
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(StartTrigg)) then
| |
− | if (curUser.sName) then
| |
− | if (lngWord == 0) then
| |
− | playerArray[curUser.sName] = 1
| |
− | SendToAll(BotName, strStart)
| |
− | if (lngMode == 2) then
| |
− | SendToPlayers(strStart)
| |
− | end
| |
− | StopQuiz(1)
| |
− | else
| |
− | SendToAll(BotName, "Da ist ein Quizz im gange, schreibe "..JoinTrigg.." um mitzuspielen!")
| |
− | end
| |
− | else
| |
− | curUser:SendPM(BotName, "Nur Op's koennen das Quizz starten.")
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(StopTrigg)) then
| |
− | if (curUser.sName) then
| |
− | HoldQuiz()
| |
− | StopQuiz()
| |
− | SendToAll(BotName, strStopp)
| |
− | if (lngMode == 2) then
| |
− | SendToPlayers(strStopp)
| |
− | end
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(WordTrigg)) then
| |
− | if ((lngWord ~= 0) and (playerArray[curUser.sName] == "Player")) then
| |
− | SendToPlayers("Die derzeitige Frage lautet: "..strSolved.." ("..strlen(strSolved)..")")
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(QuizTrigg)) then
| |
− | if ((lngWord ~= 0) and (playerArray[curUser.sName])) then
| |
− | SendToPlayers("Frage: "..strQuestion)
| |
− | end
| |
− | elseif (string.lower(firstWord) == string.lower(ReloadTrigg)) then
| |
− | if (curUser.bOperator) then
| |
− | local _, _, secondWord = string.find(data, "%b<>%s+%S+%s+(%S+)")
| |
− | if (secondWord) then
| |
− | handle = io.open(secondWord, "r")
| |
− | if (handle) then
| |
− | handle:close()
| |
− | strTrivFile = secondWord
| |
− | end
| |
− | end
| |
− |
| |
− | HoldQuiz()
| |
− | ReloadQuestions()
| |
− | end
| |
− | else
| |
− | if ((lngWord ~= 0) and (boolPlaydata)) then
| |
− | if (playerArray[curUser.sName]) then
| |
− | local msg = string.sub(data, (4 + string.len(curUser.sName)))
| |
− | if (string.len(msg) >= string.len(strWord)) then
| |
− | local boolDisc = nil
| |
− |
| |
− | local strTurn = ""
| |
− | if string.lower(msg) == string.lower(strWord) then
| |
− | strTurn = strWord
| |
− | boolDisc = 1
| |
− | else
| |
− | strTurn = strSolved
| |
− | end
| |
− |
| |
− |
| |
− | if (boolDisc) then
| |
− | strSolved = strTurn
| |
− | end
| |
− | if (boolDisc) then
| |
− | if (string.lower(msg) ~= string.lower(strWord)) then
| |
− | SendToOthers(curUser, msg)
| |
− | SendToPlayers("Die Antwort ist nun: "..strSolved)
| |
− | end
| |
− | end
| |
− | if (string.lower(msg) == string.lower(strWord)) then
| |
− | if (not (pointArray[curUser.sName])) then
| |
− | pointArray[curUser.sName] = 0
| |
− | end
| |
− | if lngHinted == 3 then pointArray[curUser.sName] = pointArray[curUser.sName] + 1
| |
− | elseif lngHinted == 2 then pointArray[curUser.sName] = pointArray[curUser.sName] + 2
| |
− | elseif lngHinted == 1 then pointArray[curUser.sName] = pointArray[curUser.sName] + 3
| |
− | else pointArray[curUser.sName] = pointArray[curUser.sName] + 4
| |
− | end
| |
− | SendToPlayers("Die Antwort war: "..strSolved)
| |
− | SendToPlayers("Die Antwort wurde erraten von: "..curUser.sName)
| |
− | SendToPlayers("Naechste Frage in "..(lngRestTime * 15).." (15) Secs")
| |
− | lngPassed = lngMaxTime
| |
− | SendToPlayers(curUser.sName.."'s Punkte: "..pointArray[curUser.sName])
| |
− | HoldQuiz()
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | --------------------------------
| |
− | function HoldQuiz()
| |
− | strWord = ""
| |
− | strQuestion = ""
| |
− | strSolved = ""
| |
− | end
| |
− | | |
− | function StopQuiz(restart)
| |
− | lngWord = 0
| |
− | lngPassed = 0
| |
− | strWord = ""
| |
− | strQuestion = ""
| |
− | strSolved = ""
| |
− | StopTimer()
| |
− | if (restart) then
| |
− | StartQuiz()
| |
− | end
| |
− | end
| |
− | | |
− | function StartQuiz()
| |
− | lngWord = math.random(1, lngGuessmax)
| |
− | QWarray = tokenize(guessArray[lngWord], strGSep)
| |
− | strQuestion = QWarray[1]
| |
− | strWord = QWarray[2]
| |
− | strSolved = ""
| |
− | for x=1, string.len(strWord) do
| |
− | if (string.sub(strWord, x, x) == " ") then
| |
− | strSolved = strSolved.." "
| |
− | else
| |
− | strSolved = strSolved..strCMask
| |
− | end
| |
− | end
| |
− | lngPassed = 0
| |
− | lngHinted = 0
| |
− | lngHintTimeCount = lngHintTime
| |
− | if string.len(strWord) < 4 then
| |
− | bcount = math.random(1, 2)
| |
− | elseif string.len(strWord) >= 4 and string.len(strWord) <= 9 then
| |
− | bcount = math.random(1, 3)
| |
− | elseif string.len(strWord) >= 9 and string.len(strWord) <= 20 then
| |
− | bcount = math.random(2, 4)
| |
− | else
| |
− | bcount = math.random(3, 5)
| |
− | end
| |
− | SetTimer(15000)
| |
− | StartTimer()
| |
− | SendToPlayers("Frage: "..strQuestion)
| |
− | SendToPlayers("Antwort: "..strSolved.." ("..string.len(strSolved)..")")
| |
− | end
| |
− | -----------------------------------------
| |
− | function OnTimer()
| |
− | lngPassed = lngPassed + 1
| |
− | if (lngPassed == lngMaxTime) then
| |
− | scount = scount + 1
| |
− | if scount == countSaveTurns then
| |
− | local handle = io.open(strTrivScoreFile, "w")
| |
− | for index, value in pointArray do
| |
− | handle:write(index..strGSep..value.."\r\n")
| |
− | end
| |
− | handle:close()
| |
− | scount = 0
| |
− | end
| |
− | if (boolRevealAnswer) then
| |
− | SendToPlayers("Die Antwort war '"..strWord.."' und wurde nicht erraten!")
| |
− | else
| |
− | SendToPlayers("Die Antwort wurde nicht erraten!")
| |
− | end
| |
− | SendToPlayers("Naechste Frage in "..(lngRestTime * 15).." Sekunden")
| |
− | HoldQuiz()
| |
− | elseif (lngPassed >= (lngRestTime + lngMaxTime)) then
| |
− | StopQuiz(1)
| |
− | elseif (lngPassed == lngHintTimeCount) then
| |
− | if (boolAutoHint) then
| |
− | for nn=1,bcount do
| |
− | local lngRepChar = math.random(1, string.len(strWord))
| |
− | while 1 do
| |
− | if (boolHintAlwaysHitHidden) then
| |
− | if (string.sub(strSolved, lngRepChar, lngRepChar) == strCMask) then
| |
− | break
| |
− | end
| |
− | else
| |
− | break
| |
− | end
| |
− | lngRepChar = math.random(1, string.len(strWord))
| |
− | end
| |
− | local strTurn = ""
| |
− | for x=1, string.len(strWord) do
| |
− | if (x == lngRepChar) then
| |
− | strTurn = strTurn..string.sub(strWord, x, x)
| |
− | else
| |
− | strTurn = strTurn..string.sub(strSolved, x, x)
| |
− | end
| |
− | end
| |
− | strSolved = strTurn
| |
− | end
| |
− | lngHinted = lngHinted + 1
| |
− | lngHintTimeCount = lngHintTimeCount + lngHintTime
| |
− | SendToPlayers("Hinweis: "..strSolved)
| |
− | end
| |
− | end
| |
− | end
| |
− | ---------------------------------------
| |
− | function tokenize (inString,token)
| |
− | _WORDS = {}
| |
− | local matcher = "([^"..token.."]+)"
| |
− | string.gsub(inString, matcher, function (w) table.insert(_WORDS,w) end)
| |
− | return _WORDS
| |
− | end
| |
− | ----------------------------------------
| |
− | function ReloadQuestions()
| |
− | guessArray = {}
| |
− | lngGuessmax = 0
| |
− | local boolRestart = nil
| |
− | if (lngWord ~= 0) then
| |
− | SendToPlayers("Lade Fragen neu, Quizz wird beendet!")
| |
− | StopQuiz()
| |
− | boolRestart = 1
| |
− | end
| |
− | handle = io.open(strTrivFile, "r")
| |
− | if (handle) then
| |
− | local line = handle:read()
| |
− |
| |
− | while line do
| |
− | if ((line ~= "") and (string.find(line, strGSep, 1, plain))) then
| |
− | table.insert(guessArray, line)
| |
− | lngGuessmax = lngGuessmax + 1
| |
− | end
| |
− | line = handle:read()
| |
− | end
| |
− | handle:close()
| |
− | end
| |
− | if (lngGuessmax < 1) then
| |
− | guessArray = {
| |
− | "Wie nennt man ein Boomerang der nicht zurückkommt?"..strGSep.."ein Stock",
| |
− | "Wie heisst das Rundling-Dorf in der nähe von Weimar?"..strGSep.."Tiefengruben",
| |
− | "Welcher deutsche Kaiser starb in Memmleben?"..strGSep.."Otto der Erste",
| |
− | "Welches ist das meistgebaute Auto der Welt?"..strGSep.."VW Kaefer",
| |
− | "An welchem Wochentag ist meistens das Weimarnetztreffen?"..strGSep.."Dienstag",
| |
− | "Wieviel Aldi Filialen gibt es in Weimar?"..strGSep.."3",
| |
− | "Wie heisst der Konstrukteur des VW Käfer?"..strGSep.."Ferdinand Porsche",
| |
− | "In welcher Stadt ist das grösste Freifunknetz?"..strGSep.."Berlin"
| |
− | }
| |
− | lngGuessmax = 2
| |
− | end
| |
− | if (boolRestart) then
| |
− | SendToPlayers("Lade Fragen neu, Quizz wird neugestartet! Derzeitige Anzahl der Fragen: "..lngGuessmax)
| |
− | StartQuiz()
| |
− | end
| |
− | strTrivFile = strDefTrivFile
| |
− | end
| |
− | ----------------------------------------
| |
− | function SaveScores(curUser)
| |
− | local handle = io.open(strTrivScoreFile, "w")
| |
− | for index, value in pointArray do
| |
− | handle:write(index..strGSep..value.."\r\n")
| |
− | end
| |
− | curUser:SendData(BotName,"Punktestand gesichert")
| |
− | handle:close()
| |
− | end
| |
− | -----------------------------------------
| |
− | function LoadScores(curUser)
| |
− | local handle = io.open(strTrivScoreFile, "r")
| |
− | if (handle) then
| |
− | local line = handle:read()
| |
− | while line do
| |
− | local arrTmp = tokenize(line, strGSep)
| |
− | if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then
| |
− | pointArray[arrTmp[1]] = tonumber(arrTmp[2])
| |
− | end
| |
− | line = handle:read()
| |
− | end
| |
− | curUser:SendData(BotName,"Punktestand geladen")
| |
− | handle:close()
| |
− | end
| |
− | end
| |
− | ---------------------------------------------------
| |
− | function AddQuestion(curUser, sQuestion, sAnswer)
| |
− | local handle = io.open(strQFile, "a")
| |
− | handle:write("Vorgeschlagen von <"..curUser.sName.."> "..sQuestion..strGSep..sAnswer.."\r\n")
| |
− | SendToPlayers(curUser.sName.." hat eine Frage hinzufefuegt "..sQuestion)
| |
− | curUser:SendPM(BotName,curUser.sName.." Du gabst als Antwort "..sAnswer)
| |
− | handle:close()
| |
− | end
| |
− | --------------------------------------------
| |
− | function SendToPlayers(msg)
| |
− | if ((lngMode > 2) or (lngMode < 0)) then
| |
− | lngMode = lngDefMode
| |
− | end
| |
− |
| |
− | if (lngMode == 0) then
| |
− | SendToAll(BotName, msg)
| |
− | elseif (lngMode == 1) then
| |
− | for index, value in playerArray do
| |
− | SendToNick(index, "<"..BotName.."> "..msg)
| |
− | end
| |
− | elseif (lngMode == 2) then
| |
− | for index, value in playerArray do
| |
− | SendPmToNick(index, BotName, msg)
| |
− | end
| |
− | end
| |
− | end
| |
− | ---------------------------------------------
| |
− | function SendToOthers(msg, curUser)
| |
− | if ((lngMode == 2) and (boolShowGuessesInPM)) then
| |
− | for index, value in playerArray do
| |
− | if (index ~= curUser.sName) then
| |
− | SendPmToNick(index, BotName, "<"..curUser.sName.."> "..msg)
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | -----------------------------------------------
| |
− | function SendChatToOthers(chat, curUser)
| |
− | if (lngMode == 2) then
| |
− | for index, value in playerArray do
| |
− | if (index ~= curUser.sName) then
| |
− | SendToNick(index, "$To: "..index.." From: "..BotName.." $<"..curUser.sName.."> "..chat)
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | --------------------------------------------
| |
− | function showHelp(curUser)
| |
− | curUser:SendData("<Help> ")
| |
− | curUser:SendData("<Help> "..BotVersion.." Befehle:")
| |
− | curUser:SendData("<Help> ")
| |
− | if (lngMode == 0) then
| |
− | curUser:SendData("<Help> "..BotVersion.." spielt das Quizz nun im Mainchat")
| |
− | elseif (lngMode == 1) then
| |
− | curUser:SendData("<Help> "..BotVersion.." spielt das Quizz nun versteckt im Mainchat")
| |
− | else
| |
− | curUser:SendData("<Help> "..BotVersion.." spielt das Quizz nun als PM")
| |
− | end
| |
− | curUser:SendData("<Help> "..HelpTrigg.." - Zeigt diese Hilfe")
| |
− | curUser:SendData("<Help> "..JoinTrigg.." - damit kannst Du am Quizz teilnehmen")
| |
− | curUser:SendData("<Help> "..PartTrigg.." - damit verlaesst Du das Quizz")
| |
− | curUser:SendData("<Help> "..WordTrigg.." - zeigt das derzeitig gesuchte Wort (Antwort)")
| |
− | curUser:SendData("<Help> "..QuizTrigg.." - zeigt die derzeitige Frage")
| |
− | curUser:SendData("<Help> "..PointTrigg.." - zeigt Deine Punkte")
| |
− | curUser:SendData("<Help> "..ScoreTrigg.." - zeigt die Ergebnisse von allen")
| |
− | curUser:SendData("<Help> "..PlayerTrigg.." - zeigt alle Spieler die am derzeitigen Quizz teilnehmen")
| |
− | curUser:SendData("<Help> "..HintTrigg.." - enthuellt einen Buchstaben in der derzeitigen Antwort")
| |
− | curUser:SendData("<Help> "..TopTrigg.." - zeigt die Top Ten Ergebnisse")
| |
− | curUser:SendData("<Help> "..AddTrigg.." - fuegt ein Frage zum Fragenfile hinzu. Schreibe die Frage und trenne die Antwort von der Frage mit einer #")
| |
− | curUser:SendData("<Help> BEISPIEL : qfrage Wie schnell fliegt ein Vogel?#keine Ahnung")
| |
− | if (curUser.bOperator) then
| |
− | curUser:SendData("<Help> ")
| |
− | curUser:SendData("<Help> "..BotVersion.." Operator Befehle:")
| |
− | curUser:SendData("<Help> "..StopTrigg.." - Stoppt den Quizzbot")
| |
− | curUser:SendData("<Help> "..RestartTrigg.." - startet den Quizzbot neu, alle Ergebnisse werden zurueckgesetzt!")
| |
− | curUser:SendData("<Help> "..QuestionsTrigg.." - zeigt alle Fragen im derzeitigen Quizz")
| |
− | curUser:SendData("<Help> "..ReloadTrigg.." (<filename>) - laedt die Fragen von "..strDefTrivFile)
| |
− | curUser:SendData("<Help> "..ModeTrigg.." - aendert den Spielmodus (0-2)!")
| |
− | curUser:SendData("<Help> "..SaveTrigg.." - speichert die Ergebnisse in "..strTrivScoreFile)
| |
− | curUser:SendData("<Help> "..LoadTrigg.." - laedt die Ergebnisse von "..strTrivScoreFile)
| |
− | curUser:SendData("<Help> "..StartTrigg.." - startet den Quizzbot und Du nimmst automatisch daran teil")
| |
− | curUser:SendData("<Help> ")
| |
− | curUser:SendData("<Help> "..BotVersion.." Modis:")
| |
− | curUser:SendData("<Help> ".."0 = gespielt wird im Mainchat!")
| |
− | curUser:SendData("<Help> ".."1 = gespielt wird im Mainchat aber die Fragen sind nur sichtbar fuer Mitspieler")
| |
− | curUser:SendData("<Help> ".."2 = gespielt wird komplett als PM")
| |
− | end
| |
− | end
| |
− | ----------------------------------------------
| |
− | function TopTen(user)
| |
− | local index = {n=0}
| |
− | table.foreach(pointArray, function(nick, score) table.insert(index, nick) end)
| |
− | local func = function(a, b) return pointArray[a] > pointArray[b] end
| |
− | table.sort(index, func)
| |
− | | |
− | x = x or 10 if x > index.n then x = index.n end
| |
− | local result = "\r\nTop "..x.." Quizz Ergebnisse in diesem Hub..\r\n Pos\t Score\t\t Nick\t\r\n"
| |
− | for i = 1, x do result = result.."\r\n "..i..".\t"..pointArray[index[i]].."\t\t"..index[i] end
| |
− | msg = result
| |
− | SendToPlayers(msg)
| |
− | end
| |
− | </pre>
| |
− | | |
− | | |
− | ====Postman(mailserver)-bot====
| |
− | <pre>
| |
− | -- PostMan Bot 0.3 by bastya_elvtars (the rock n' roll doctor)
| |
− | -- offline message system
| |
− | -- code ripped from law maker bot
| |
− | -- comands can be PMed or typed in main, the bot responds to them according to the environment (sometimes at least :D)
| |
− | -- the commands are case insensitive, the parameters aren't :)
| |
− | | |
− | ------- 0.2:
| |
− | -- added function so ppl cannot post 2 online users
| |
− | | |
− | ------- 0.3:
| |
− | -- converted to lua5
| |
− | -- washere is now global, no more CPU spikes
| |
− | | |
− | ------- 0.4:
| |
− | -- touched by Herodes (optimisation tsunami)
| |
− | -- added : more details on the bot
| |
− | -- added : message privacy ;)
| |
− | -- changed : better way to parseenv ;)
| |
− | -- changed : better way to display messages and inbox
| |
− | -- changed : better way to parsecmds ( thx bastya_elvtars ;)
| |
− | | |
− | ------- 0.5:
| |
− | -- touched by Skippy84
| |
− | -- fix error: make offline.dat thx goto Herodes for the idea to fix the problem
| |
− | -- fix error: false command !showmsg
| |
− | -- added: commands can edit at the Settings section
| |
− | -- added: shown commands linked to the editable commands (so ther change on the fly)
| |
− | | |
− | ------- 0.51:
| |
− | -- bastya_elvtars put his hands back on this
| |
− | -- script now creates an empty offline.dat if does not exist... you guys keep ignoring new Lua5 features :P
| |
− | -- thx guys for the features you added, they are really eye-candy
| |
− | | |
− | ------- 0.6:
| |
− | -- touched again by Skippy84
| |
− | -- added: a little rightclick menu
| |
− | | |
− | --------------------------------SETTINGS----------------------------------------
| |
− | | |
− | Bot = {
| |
− | name = "Weimarnetz-Mailserver" , -- bot's name
| |
− | email = "postman@mail.me", -- bot's email
| |
− | desc = "Nachrichten senden an User die gerade nicht da sind..", -- bot's desc
| |
− | }
| |
− | | |
− | inboxsize=15 -- the maximum amount of messages users can have in their inbox
| |
− | | |
− | cmdpost = "postmsg" -- Shows the Hub Stats
| |
− | cmdread = "readmsg" -- Shows the Hub Stats
| |
− | cmdibox = "inbox" -- Shows the Hub Stats
| |
− | cmddbox = "delmsg" -- Shows the Hub Stats
| |
− | | |
− | ----------------------END OF SETTINGS-------------------------------------------
| |
− | | |
− | | |
− | -------------------------------------- Utility Functions
| |
− | | |
− | function cls()
| |
− | collectgarbage()
| |
− | io.flush()
| |
− | end
| |
− | | |
− | function Main()
| |
− | local function load()
| |
− | local t = {}; local f = io.open("washere.lst", "r")
| |
− | if f then for l in f:lines() do t[l] = 1; end; f:close(); end
| |
− | return t;
| |
− | end
| |
− | washere = load()
| |
− | message = {}
| |
− | if loadfile("offline.dat") then
| |
− | dofile("offline.dat")
| |
− | else
| |
− | io.output("offline.dat")
| |
− | io.write("")
| |
− | io.output()
| |
− | end
| |
− | frmHub:RegBot(Bot.name, 1, Bot.desc, Bot.email )
| |
− | Bot = Bot.name
| |
− | end
| |
− | | |
− | -------------------------------------- Command Functions
| |
− | | |
− | --- post msg
| |
− | | |
− | function postmsg( user, data, how )
| |
− | local _,_,nick,msg = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
| |
− | if nick then
| |
− | if not GetItemByName(nick) then
| |
− | if washere[nick] then
| |
− | local function checksize(n) local cnt = 0; for a,b in message[n] do cnt = cnt + 1; end return cnt; end
| |
− | if not message[nick] then message[nick] = {}; end
| |
− | if (checksize(nick) < inboxsize) then
| |
− | table.insert( message[nick], { ["message"] = msg, ["who"] = user.sName, ["when"] = os.date("%Y. %m. %d. %X"), ["read"] = 0, } )
| |
− | SendBack( user, "Erfolgreich gesendete Nachricht!", Bot, how )
| |
− | savemsg()
| |
− | else
| |
− | SendBack( user, "Sorry, aber "..nick.." hat eine volle Mailbox. Probier es später.", Bot, how )
| |
− | end
| |
− | else
| |
− | SendBack( user, "User "..nick.." wart nie gesehen in diesem Hub.", Bot, how )
| |
− | end
| |
− | else
| |
− | SendBack( user, nick.." ist online! PM ist doch einfacher...", Bot, how )
| |
− | end
| |
− | else
| |
− | SendBack( user, "Falscher syntax! Schreibe: !"..cmdpost.." ", Bot, how )
| |
− | end
| |
− | cls(); return 1;
| |
− | end
| |
− | | |
− | --- del msg
| |
− | | |
− | function delmsg( user, data, how )
| |
− | if message[user.sName] then
| |
− | local _,_,args = string.find(data,"%b<>%s+%S+%s+(.+)")
| |
− | if args then
| |
− | local function checksize(n) local cnt = 0; for a,b in message[n] do cnt = cnt + 1; end return cnt; end
| |
− | local function resort(t) local r ={}; for i,v in t do table.insert(r, v); end; return r; end
| |
− | for num in string.gfind( args, "%s-(%d+)%s-" ) do
| |
− | if num then
| |
− | num = tonumber(num);
| |
− | if message[user.sName][num] then
| |
− | message[user.sName][num] = nil
| |
− | SendBack( user, "Nachricht #"..num.." erfolgreich gelöscht!", Bot, how )
| |
− | else
| |
− | SendBack( user, "Nachricht #"..num.." existiert nicht!", Bot, how )
| |
− | end
| |
− | end
| |
− | end
| |
− | message[user.sName] = resort(message[user.sName]);
| |
− | if checksize(user.sName) == 0 then message[user.sName] = nil; end
| |
− | savemsg()
| |
− | else
| |
− | SendBack( user, "Falscher syntax! Schreibe: !"..cmddbox.." . Mehrere Zahlen mit Leerzeichen trennen.", Bot, how )
| |
− | end
| |
− | else
| |
− | SendBack( user, "Deine Mailbox ist leer.", Bot, how )
| |
− | end
| |
− | cls(); return 1;
| |
− | end
| |
− | | |
− | ----------------------------------------------------------------------------------
| |
− | ---------------------------------------------------------------------------------
| |
− | ---------------------------------------------------------------------------------- show inbox
| |
− | | |
− | function inbox( user, how )
| |
− | local sep, msg = string.rep( "=", 75 ), "\r\n\r\n\t\t\t\t\t\t\tHere is your inbox:\r\n"
| |
− | msg = msg..sep.."\r\n Msg#\tSender\tTime of sending\t\tRead\r\n"..sep
| |
− | if message[user.sName] then
| |
− | local function numess ( r ) if r == 0 then return "no"; end return "yes"; end
| |
− | local function checksize ( n ) local cnt = 0; for a,b in message[n] do cnt = cnt + 1; end return cnt; end
| |
− | local function dcode ( s ) if (string.sub(s,1,3) == "-n#") then s=string.sub(s,4,-1); local res = ""; for num in string.gfind( s, "#?(%d+)") do res = res..string.char(tonumber(num));end;return res;end;return s;end
| |
− | for num, t in message[user.sName] do
| |
− | msg=msg.."\r\n "..num.."\t"..dcode(t.who).."\t"..t.when.."\t"..numess(t.read).."\r\n"..sep
| |
− | end
| |
− | SendBack( user, msg, Bot, true )
| |
− | SendBack( user, "Schreibe !"..cmdread.." um die Nachricht zu sehen. Mehrere Zahlen mit Leerzeichen trennen.", Bot, true )
| |
− | if checksize(user.sName) >= inboxsize then SendBack( user, "Alarm: Deine Mailbox ist voll!", Bot, true ); end
| |
− | else
| |
− | SendBack( user, "Du hast keine Nachrichten.", Bot, how )
| |
− | end
| |
− | cls(); return 1;
| |
− | end
| |
− | | |
− | --- read msg(s)
| |
− | | |
− | function readmsg( user, data, how )
| |
− | if message[user.sName] then
| |
− | local _,_,args=string.find(data,"%b<>%s+%S+%s+(.+)")
| |
− | if args then
| |
− | local function dcode(s) if (string.sub(s,1,3) == "-n#") then s = string.sub(s,4,-1);local res = ""; for num in string.gfind( s, "#?(%d+)") do res = res..string.char(tonumber(num));end;return res;end;return s;
| |
− | end
| |
− | for num in string.gfind( args, "%s-(%d+)%s-" ) do
| |
− | if num then num = tonumber(num) end
| |
− | if num and message[user.sName][num] then
| |
− | local t = message[user.sName][num]
| |
− | local msg, sep,set = "\r\n\r\n\t\t\t\t\t\t\tMessage #"..num.."\r\n", string.rep( "=", 100 ), string.rep("- ", 85)
| |
− | msg = msg..sep.."\r\n\r\nFrom: "..dcode(t.who).."\tTime: "..t.when.."\t\tMessage follows\r\n"..set.."[Message start]\r\n"..dcode(t.message).."\r\n"..set.."[Message end]\r\n"..sep
| |
− | SendBack( user, msg, Bot, true )
| |
− | if t.read == 0 then t.read = 1; savemsg(); end
| |
− | else
| |
− | SendBack( user, "Nachricht #"..num.." existiert nicht!", Bot, how )
| |
− | end
| |
− | end
| |
− | else
| |
− | SendBack( user, "Falscher syntax! Schreibe: !"..cmdread.." . Mehrere Zahlen mit Leerzeichen trennen.", Bot, how )
| |
− | end
| |
− | else
| |
− | SendBack( user, "Deine Mailbox ist leer.", Bot, how )
| |
− | end
| |
− | cls(); return 1;
| |
− | end
| |
− | | |
− | --- save msg
| |
− | | |
− | function savemsg()
| |
− | local function parse(tbl)
| |
− | local str, tab ="", string.rep( "\t", 9)
| |
− | local function fquot(s) return string.format( "%q", s) end
| |
− | local function ncode( s ) if (s ~= "") and (string.sub(s,1,3) ~= "-n#") then local t = {}; for i = 1, string.len(s) do t[i] = string.byte(string.sub(s,i,i)); end; return "-n#"..table.concat(t, "#"); end; return s; end
| |
− | for a, t in tbl do
| |
− | str = str.."\t\t{ ["..fquot("read").."] = "..t.read..", ["..fquot("who").."] = "..fquot(ncode(t.who))..", ["..fquot("when").."] = "..fquot(t.when)..",\n\t\t["..fquot("message").."] = "..fquot(ncode(t.message)).." },\n"
| |
− | end
| |
− | return str
| |
− | end
| |
− | local f = io.open ( "offline.dat", "w+" )
| |
− | local s = "message = {"
| |
− | for name, t in message do
| |
− | s = s.."\n\t["..string.format( "%q", string.gsub( name, "\"", "\"")).."] = {\n"..parse(t).."\t},"
| |
− | end;
| |
− | f:write(s.."\n}")
| |
− | f:close()
| |
− | end
| |
− | | |
− | function SendBack( user, msg, who, pm )
| |
− | if pm then user:SendPM ( who, msg ); else user:SendData( who, msg ); end
| |
− | end
| |
− | | |
− | function NewUserConnected(user)
| |
− | if user.bUserCommand then
| |
− | user:SendData("$UserCommand 1 3 :Weimarnetz-Mailserver:\\INBOX$<%[mynick]> !inbox||")
| |
− | user:SendData("$UserCommand 1 3 :Weimarnetz-Mailserver:\\poste eine Nachricht$<%[mynick]> !postmsg %[line:Enter and :]||")
| |
− | user:SendData("$UserCommand 1 3 :Weimarnetz-Mailserver:\\lese eine Nachricht$<%[mynick]> !readmsg %[line:Enter Nr of Post you would read:]||")
| |
− | user:SendData("$UserCommand 1 3 :Weimarnetz-Mailserver:\\lösche eine Nachricht$<%[mynick]> !delmsg %[line:Enter Nr of Post you would delete:]||")
| |
− | user:SendData(":Weimarnetz-Mailserver:", "Neues Rechts-Click Menu für Weimarnetz-Mailserver steht zur Verfügung..")
| |
− | end
| |
− |
| |
− | if not washere[user.sName] then washere[user.sName] = 1 end
| |
− | if message[user.sName] then
| |
− | local cnt=0
| |
− | for a,b in message[user.sName] do if (b.read == 0) then cnt = cnt+1; end end
| |
− | if (cnt > 0) then SendBack( user, "Du hast "..cnt.." neue Nachrichten. Schreibe !"..cmdibox.." um in Deine Mailbox zu schauen!", Bot, true ); end
| |
− | end
| |
− | end
| |
− | | |
− | function ChatArrival(user,data)
| |
− | local data = string.sub( data, 1, -2 )
| |
− | local _,_,cmd = string.find(data,"%b<>%s+[!+.#?](%S+)")
| |
− | if cmd then return parsecmds( user, data, string.lower(cmd) ); end
| |
− | end
| |
− | | |
− | function ToArrival(user,data)
| |
− | if (string.sub( data, 1, string.len(Bot)+5) == "$To: "..Bot) then
| |
− | local data = string.sub( data, 1, -2 )
| |
− | local _,_,cmd = string.find(data,"%$%b<>%s+[!+.#?](%S+)")
| |
− | if cmd then return parsecmds( user, data, string.lower(cmd), true ) end
| |
− | return 1
| |
− | end
| |
− | end
| |
− | | |
− | function parsecmds( user, data, cmd, how )
| |
− | local t = {
| |
− | [cmdpost] = { postmsg, { user, data, how } },
| |
− | [cmdread] = { readmsg, { user, data, how } },
| |
− | [cmdibox] = { inbox, { user, how } },
| |
− | [cmddbox] = { delmsg, { user, data, how } },
| |
− | }
| |
− | if t[cmd] then
| |
− | return t[cmd][1]( unpack(t[cmd][2]) )
| |
− | end
| |
− | end
| |
− | | |
− | function UserDisconnected(user)
| |
− | if not washere[user.sName] then washere[user.sName] = 1; end
| |
− | end
| |
− | | |
− | function OnExit()
| |
− | savemsg()
| |
− | local f = io.open( "washere.lst", "w+")
| |
− | for a,b in washere do f:write(a.."\n"); end
| |
− | f:close()
| |
− | end
| |
− | | |
− | OpDisconnected=UserDisconnected
| |
− | OpConnected=NewUserConnected
| |
− | </pre>
| |
− | | |
− | ====Voting(VotePoll-bot)====
| |
− | <pre>
| |
− | --Vote Poll v1.0
| |
− | --Made by nErBoS
| |
− | --Converted to Lua 5 by jiten
| |
− | --Changed Visual Design / Translated to german / Added Rightclick by pulsar
| |
− | | |
− | Bot = "Vote Poll"
| |
− | | |
− | vt = {}
| |
− | nr = {}
| |
− | | |
− | votetext = "voting.txt"
| |
− | oldpolls = "voting-old.txt"
| |
− | | |
− | function Main()
| |
− | frmHub:RegBot(Bot)
| |
− | end
| |
− | | |
− | function NewUserConnected(user, data)
| |
− | if (vt[user.sName] == nil) then
| |
− | vt[user.sName] = 0
| |
− | end
| |
− | if (nr[user.sName] == nil) then
| |
− | nr[user.sName] = 0
| |
− | end
| |
− | | |
− | end
| |
− | | |
− | function NewUserConnected(user,data)
| |
− | UserCmds(user)
| |
− | if user.bOperator then
| |
− | OpCmds(user)
| |
− | end
| |
− | end
| |
− | | |
− | OpConnected = NewUserConnected
| |
− | rcmenue = "Voting"
| |
− | | |
− | function UserCmds(user) -- User Befehle
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Zeige aktuelle Umfragen$<%[mynick]> +votefor||")
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Zeige beendete Umfragen$<%[mynick]> +votelist||")
| |
− | user:SendData("$UserCommand 0 3 |") -- separator
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Bei einer aktuellen Umfrage abstimmen$<%[mynick]> +vote %[line:Welche Zuordnungsnummer?] %[line:y / n ? (Yes or No)]||")
| |
− | user:SendData("$UserCommand 0 3 |") -- separator
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Abstimmungsergebnisse\\PM\\aktuelle Umfragen$<%[mynick]> +showvote %[line:Welche Zuordnungsnummer?] new||")
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Abstimmungsergebnisse\\PM\\beendete Umfragen$<%[mynick]> +showvote %[line:Welche Zuordnungsnummer?] old||")
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Abstimmungsergebnisse\\Main\\aktuelle Umfragen$<%[mynick]> +svmain %[line:Welche Zuordnungsnummer?] new||")
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Abstimmungsergebnisse\\Main\\beendete Umfragen$<%[mynick]> +svmain %[line:Welche Zuordnungsnummer?] old||")
| |
− | end
| |
− | function OpCmds(user) -- OP Befehle
| |
− | -- leer
| |
− | if (user.iProfile == 0) then -- Master Befehle
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Admin\\Umfrage erstellen$<%[mynick]> +createvote %[line:Welche Zuordnungsnummer?] %[line:Welche Umfrage?]||")
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Admin\\Umfrage beenden$<%[mynick]> +stopvote %[line:Welche Zuordnungsnummer?]||")
| |
− | user:SendData("$UserCommand 1 3 "..rcmenue.."\\Admin\\Umfrage löschen$<%[mynick]> +delvote %[line:Welche Zuordnungsnummer?]||")
| |
− | end
| |
− | end
| |
− | | |
− | function ChatArrival(user, data)
| |
− | data=string.sub(data,1,string.len(data)-1)
| |
− | s,e,cmd = string.find(data,"%b<>%s+(%S+)")
| |
− | if (cmd=="+votehelp") then
| |
− | local msg = ""
| |
− | if (user.iProfile == 0) then
| |
− | msg = msg.."Befehle für das Voting:\r\n"
| |
− | msg = msg.."\r\n"
| |
− | msg = msg.."+createvote <nr> <q>\tErstellt eine Umfrage (nr = Zuordnungsnummer für die Umfrage) (q = Umfrage)\r\n"
| |
− | msg = msg.."+stopvote <nr>\t\tBeendet die Umfrage\r\n"
| |
− | msg = msg.."+showvote <nr> <old/new>\tZeigt die Abstimmungsergebnisse der Umfrage (old = alte Umfragen) oder (new = Umfragen die noch nicht beendet worden sind)\r\n"
| |
− | msg = msg.."+svmain <nr> <old/new>\tZeigt die Abstimmungsergebnisse im Main (old = alte Umfragen) oder (new = Umfragen die noch nicht beendet worden sind)\r\n"
| |
− | msg = msg.."+votelist\t\t\tZeigt alle Umfragen\r\n"
| |
− | msg = msg.."+votefor\t\t\tZeigt die Umfragen bei denen du abstimmen kannst\r\n"
| |
− | msg = msg.."+vote <nr> <y/n>\t\tUm bei einer Umfrage abzustimmen (y = ja) (n = nein) (nr = Nummer der Umfrage)\r\n"
| |
− | msg = msg.."+delvote <nr>\t\tUm alte Umfragen zu löschen (nr = Nummer der zu löschenden Umfrage)\r\n"
| |
− | msg = msg.."\r\n"
| |
− | user:SendPM(Bot, msg)
| |
− | else
| |
− | msg = msg.."Befehle für das Voting:\r\n"
| |
− | msg = msg.."\r\n"
| |
− | msg = msg.."+votefor\t\t\tZeigt die Umfragen bei denen du abstimmen kannst\r\n"
| |
− | msg = msg.."+vote <nr> <y/n>\t\tUm bei einer Umfrage abzustimmen (y = ja) (n = nein) (nr = Nummer der Umfrage)\r\n"
| |
− | msg = msg.."\r\n"
| |
− | user:SendPM(Bot, msg)
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+createvote") then
| |
− | if (user.iProfile == 0) then
| |
− | local s,e,number,question = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
| |
− | if (tonumber(number) == nil) then
| |
− | user:SendPM(Bot, "Syntax error, +createvote <nr> <q>, nr muss eine Nummer sein!")
| |
− | else
| |
− | number = tonumber(number)
| |
− | if (question == nil or question == "") then
| |
− | user:SendPM(Bot, "Syntax error, +createvote <nr> <q>, du musst schon auch ne Frage erstellen worüber abgestimmt werden soll!")
| |
− | else
| |
− | if (CreatePoll(user, number, question) == 1) then
| |
− | user:SendPM(Bot, "Die Abstimmung bzw. Umfrage wurde erstellt.")
| |
− | else
| |
− | user:SendPM(Bot, "Es existiert bereits eine Abstimmung bzw. Umfrage mit der Nummer "..number..".")
| |
− | end
| |
− | end
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Du hast keine Befugnis diesen Befehl zu nutzen!")
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+stopvote") then
| |
− | if (user.iProfile == 0) then
| |
− | local s,e,number = string.find(data,"%b<>%s+%S+%s+(.*)")
| |
− | if (tonumber(number) == nil or number == "") then
| |
− | user:SendPM(Bot, "Syntax error, +stopvote <nr>, nr muss eine Nummer sein!")
| |
− | else
| |
− | number = tonumber(number)
| |
− | if (OldPoll(user, number) == 1) then
| |
− | user:SendPM(Bot, "Die Abstimmung bzw. Umfrage wurde beendet und gespeichert in der "..oldpolls..".")
| |
− | else
| |
− | user:SendPM(Bot, "Es gibt keine Abstimmung bzw. Umfrage mit der Nummer "..number..".")
| |
− | end
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Du hast keine Befugnis diesen Befehl zu nutzen!")
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+showvote") then
| |
− | if (user.iProfile == 0) then
| |
− | local s,e,number, opt = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
| |
− | if (tonumber(number) == nil) then
| |
− | user:SendPM(Bot, "Syntax error, +showvote <nr> <old/new>, nr muss eine Nummer sein!")
| |
− | else
| |
− | number = tonumber(number)
| |
− | if (opt == "old") then
| |
− | if (CheckPoll(user, number, oldpolls) == "") then
| |
− | user:SendPM(Bot, "Es gibt keine beendete Umfrage mit der Nummer "..number..".")
| |
− | else
| |
− | user:SendPM(Bot, CheckPoll(user, number, oldpolls))
| |
− | end
| |
− | elseif(opt == "new") then
| |
− | if (CheckPoll(user, number, votetext) == "") then
| |
− | user:SendPM(Bot, "Es gibt keine Umfrage mit der Nummer "..number..".")
| |
− | else
| |
− | user:SendPM(Bot, CheckPoll(user, number, votetext))
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Syntax error, +showvote <nr> <old/new>, muss sein (old = alte Umfragen) oder (new = Umfragen die noch nicht beendet worden sind)")
| |
− | end
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Du hast keine Befugnis diesen Befehl zu nutzen!")
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+svmain") then
| |
− | if (user.iProfile == 0) then
| |
− | local s,e,number, opt = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
| |
− | if (tonumber(number) == nil) then
| |
− | user:SendPM(Bot, "Syntax error, +svmain <nr> <old/new>, nr muss eine Nummer sein!")
| |
− | else
| |
− | number = tonumber(number)
| |
− | if (opt == "old") then
| |
− | if (CheckPoll(user, number, oldpolls) == "") then
| |
− | user:SendPM(Bot, "Es gibt keine beendete Umfrage mit der Nummer "..number..".")
| |
− | else
| |
− | SendToAll(Bot, CheckPoll(user, number, oldpolls))
| |
− | end
| |
− | elseif(opt == "new") then
| |
− | if (CheckPoll(user, number, votetext) == "") then
| |
− | user:SendPM(Bot, "Es gibt keine Umfrage mit der Nummer "..number..".")
| |
− | | |
− | else
| |
− | SendToAll(Bot, CheckPoll(user, number, votetext))
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Syntax error, +svmain <nr> <old/new>, muss sein (old = alte Umfragen) oder (new = Umfragen die noch nicht beendet worden sind)")
| |
− | end
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Du hast keine Befugnis diesen Befehl zu nutzen!")
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+votelist") then
| |
− | if (user.iProfile == 0) then
| |
− | local l = io.open(oldpolls, "r")
| |
− | if (ReadPoll(user, oldpolls) == "") then
| |
− | user:SendPM(Bot, "Es gibt keine beendeten Umfragen")
| |
− | else
| |
− | user:SendPM(Bot, ReadPoll(user, oldpolls))
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Du hast keine Befugnis diesen Befehl zu nutzen!")
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+votefor") then
| |
− | if (ReadPoll(user, votetext) == "") then
| |
− | user:SendPM(Bot, "Es gibt keine Abstimmungen bzw. Umfragen")
| |
− | else
| |
− | user:SendPM(Bot, ReadPoll(user, votetext))
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+vote") then
| |
− | local s,e,number,opt = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
| |
− | if (tonumber(number) == nil) then
| |
− | user:SendPM(Bot, "Syntax error, +vote <nr> <y/n>, nr muss eine Nummer sein!")
| |
− | else
| |
− | number = tonumber(number)
| |
− | if (opt == nil or opt == "" or opt ~= "n" and opt ~= "y") then
| |
− | user:SendPM(Bot, "Syntax error, +vote <nr> <y/n>, du musst schreiben (y = ja) oder (n = nein).")
| |
− | else
| |
− | if (Vote(user, number, opt) == 1) then
| |
− | user:SendPM(Bot, "Deine Abstimmung wurde registriert.")
| |
− | vt[user.sName] = 1
| |
− | nr[user.sName] = number
| |
− | elseif(Vote(user, number, opt) == 2) then
| |
− | user:SendPM(Bot, "Du hast bei dieser Umfrage bereits abgestimmt")
| |
− | else
| |
− | user:SendPM(Bot, "Es gibt keine Umfrage mit der Nummer "..number..".")
| |
− | end
| |
− | end
| |
− | end
| |
− | return 1
| |
− | elseif (cmd=="+delvote") then
| |
− | if (user.iProfile == 0) then
| |
− | local s,e,number = string.find(data,"%b<>%s+%S+%s+(%S+)")
| |
− | if (tonumber(number) == nil) then
| |
− | user:SendPM(Bot, "Syntax error, +delvote <nr>, nr muss eine Nummer sein!")
| |
− | else
| |
− | number = tonumber(number)
| |
− | if (DelOldPoll(user, number) == 0) then
| |
− | user:SendPM(Bot, "Es gibt keine beendete Umfrage mit der Nummer "..number)
| |
− | else
| |
− | user:SendPM(Bot, "Die alte Umfrage wurde gelöscht.")
| |
− | end
| |
− | end
| |
− | else
| |
− | user:SendPM(Bot, "Du hast keine Befugnis diesen Befehl zu nutzen!")
| |
− | end
| |
− | return 1
| |
− | end
| |
− | end
| |
− | | |
− | ToArrival = ChatArrival
| |
− | | |
− | function CreatePoll(user, number, question)
| |
− | local tmp = ""
| |
− | local time = 0
| |
− | local a = io.open(oldpolls, "r")
| |
− | if a then
| |
− | while 1 do
| |
− | local line = a:read()
| |
− | if (line == nil) then
| |
− | break
| |
− | else
| |
− | local s,e,num = string.find(line,"Nr:%s+(%S+)%s+")
| |
− | if (tonumber(num) ~= nil and tonumber(num) == number) then
| |
− | time = 2
| |
− | else
| |
− | end
| |
− | end
| |
− | end
| |
− | a:close()
| |
− | else
| |
− | dofile(oldpolls)
| |
− | -- return a.." doesnt exist"
| |
− | end
| |
− | | |
− | local b = io.open(votetext,"r")
| |
− | if b then
| |
− | while 1 do
| |
− | local line = b:read()
| |
− | if (line == nil) then
| |
− | if (time == 2) then
| |
− | break
| |
− | else
| |
− | tmp = tmp.."Nr: "..number.." Umfrage: "..question.." Ja: 0 Nein: 0 Active: Ja\r\n"
| |
− | time = 1
| |
− | break
| |
− | end
| |
− | else
| |
− | local s,e,num = string.find(line,"Nr:%s+(%S+)%s+")
| |
− | if (tonumber(num) ~= nil and tonumber(num) == number) then
| |
− | tmp = tmp..line.."\r\n"
| |
− | time = 2
| |
− | else
| |
− | tmp = tmp..line.."\r\n"
| |
− | end
| |
− | end
| |
− | end
| |
− | | |
− | b:close()
| |
− | local l = io.open(votetext,"w+")
| |
− | l:write(tmp)
| |
− | l:flush()
| |
− | l:close()
| |
− | return time
| |
− | else
| |
− | dofile(votetext)
| |
− | -- return b.." doesnt exist"
| |
− | end
| |
− | return time
| |
− | end
| |
− | | |
− | function OldPoll(user, number)
| |
− | local tmp = ""
| |
− | local tmp2 = ""
| |
− | local time = 0
| |
− | local c = io.open(votetext,"r")
| |
− | if c then
| |
− | while 1 do
| |
− | local line = c:read()
| |
− | if (line == nil) then
| |
− | break
| |
− | else
| |
− | local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Ja:%s+(%S+)%s+Nein:%s+(%S+)%s+Active:")
| |
− | if (tonumber(num) ~= nil and tonumber(num) == number) then
| |
− | tmp2 = tmp2.."Nr: "..number.." "..question.."Ja: "..ny.." Nein: "..nn.." Active: Nein\r\n"
| |
− | time = 1
| |
− | else
| |
− | tmp = tmp..line.."\r\n"
| |
− | end
| |
− | end
| |
− | end
| |
− | c:close()
| |
− | local d = io.open(votetext,"w+")
| |
− | d:write(tmp)
| |
− | d:flush()
| |
− | d:close()
| |
− | if (time == 0) then
| |
− | else
| |
− | local e = io.open(oldpolls, "a+") -- "a+"
| |
− | e:write(tmp2)
| |
− | e:close()
| |
− | end
| |
− | return time
| |
− | else
| |
− | dofile(votetext)
| |
− | -- return c.." existiert nicht"
| |
− | | |
− | end
| |
− | end
| |
− | | |
− | function CheckPoll(user, number, file)
| |
− | local tmp = ""
| |
− | local f = io.open(file,"r")
| |
− | if f then
| |
− | while 1 do
| |
− | local line = f:read()
| |
− | if (line == nil) then
| |
− | break
| |
− | else
| |
− | local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Ja:%s+(%S+)%s+Nein:%s+(%S+)%s+Active:")
| |
− | if (tonumber(num) ~= nil and tonumber(num) == number) then
| |
− | tmp = tmp.."\r\n________________________________________________"
| |
− | tmp = tmp.."\r\n------------------------------------------ Voting ------------------------------------------"
| |
− | tmp = tmp.."\r\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\r\n\r\n"
| |
− | tmp = tmp.."Ergebnis von Umfrage Nr: "..num.." "
| |
− | tmp = tmp.."\r\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\r\n\r\n"
| |
− | tmp = tmp..""..question.."\r\n"
| |
− | tmp = tmp.."------------------------------\r\n"
| |
− | tmp = tmp.."Ja: "..ny.."\r\n"
| |
− | tmp = tmp.."Nein: "..nn.."\r\n"
| |
− | tmp = tmp.."------------------------------\r\n"
| |
− | if (tonumber(ny) > tonumber(nn)) then
| |
− | tmp = tmp.."Ja liegt vorne"
| |
− | elseif (tonumber(ny) < tonumber(nn)) then
| |
− | tmp = tmp.."Nein hat gewonnen."
| |
− | elseif (tonumber(ny) == tonumber(nn)) then
| |
− | tmp = tmp.."unentschieden."
| |
− | end
| |
− | break
| |
− | else
| |
− | end
| |
− | end
| |
− | end
| |
− | f:close()
| |
− | return tmp
| |
− | else
| |
− | dofile(file)
| |
− | -- return f.." existiert nicht"
| |
− | end
| |
− | end
| |
− | | |
− | function ReadPoll(user, file)
| |
− | local tmp = ""
| |
− | local g = io.open(file,"r")
| |
− | if g then
| |
− | while 1 do
| |
− | local line = g:read()
| |
− | if (line == nil or line == "") then
| |
− | break
| |
− | else
| |
− | local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Ja:%s+(%S+)%s+Nein:%s+(%S+)%s+Active:")
| |
− | if (num == nil) then
| |
− | else
| |
− | tmp = tmp.."\r\n________________________________________________"
| |
− | tmp = tmp.."\r\n------------------------------------------ Voting ------------------------------------------"
| |
− | tmp = tmp.."\r\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\r\n\r\n"
| |
− | tmp = tmp.."Ergebnis von Umfrage Nr: "..num.." "
| |
− | tmp = tmp.."\r\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\r\n\r\n"
| |
− | tmp = tmp..""..question.."\r\n"
| |
− | tmp = tmp.."------------------------------\r\n"
| |
− | tmp = tmp.."Ja: "..ny.."\r\n"
| |
− | tmp = tmp.."Nein: "..nn.."\r\n"
| |
− | tmp = tmp.."------------------------------\r\n"
| |
− | if (file == oldpolls) then
| |
− | tmp = tmp.."Umfrage beendet\r\n"
| |
− | elseif (file == votetext) then
| |
− | tmp = tmp.."Umfrage läuft noch\r\n"
| |
− | end
| |
− | end
| |
− | end
| |
− | end
| |
− | g:close()
| |
− | return tmp
| |
− | else
| |
− | dofile(file)
| |
− | -- return g.." existiert nicht"
| |
− | end
| |
− | end
| |
− | | |
− | function Vote(user, number, opt)
| |
− | local tmp = ""
| |
− | local time = 0
| |
− | if (vt[user.sName] == 1 and nr[user.sName] == number) then
| |
− | time = 2
| |
− | else
| |
− | | |
− | local h = io.open(votetext,"r")
| |
− | if h then
| |
− | while 1 do
| |
− | local line = h:read()
| |
− | if (line == nil) then
| |
− | break
| |
− | else
| |
− | local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Ja:%s+(%S+)%s+Nein:%s+(%S+)%s+Active:")
| |
− | if (tonumber(num) ~= nil and tonumber(num) == number) then
| |
− | if (opt == "y") then
| |
− | ny = tonumber(ny) + 1
| |
− | elseif (opt == "n") then
| |
− | nn = tonumber(nn) + 1
| |
− | end
| |
− | tmp = tmp.."Nr: "..number.." "..question.."Ja: "..ny.." Nein: "..nn.." Active: Ja\r\n"
| |
− | time = 1
| |
− | else
| |
− | tmp = tmp..line.."\r\n"
| |
− | end
| |
− | end
| |
− | end
| |
− | h:close()
| |
− | else
| |
− | dofile(votetext)
| |
− | -- return h.." existiert nicht"
| |
− | end
| |
− | local i = io.open(votetext,"w+")
| |
− | i:write(tmp)
| |
− | i:flush()
| |
− | i:close()
| |
− | end
| |
− | return time
| |
− | end
| |
− | | |
− | function DelOldPoll(user, number)
| |
− | local tmp = ""
| |
− | local time = 0
| |
− | local j = io.open(oldpolls,"r")
| |
− | if j then
| |
− | while 1 do
| |
− | local line = j:read()
| |
− | if (line == nil) then
| |
− | break
| |
− | else
| |
− | local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Ja:%s+(%S+)%s+Nein:%s+(%S+)%s+Active:")
| |
− | if (tonumber(num) ~= nil and tonumber(num) == number) then
| |
− | time = 1
| |
− | else
| |
− | tmp = tmp..line.."\r\n"
| |
− | end
| |
− | end
| |
− | end
| |
− | j:close()
| |
− | else
| |
− | dofile(oldpolls)
| |
− | -- return j.." existiert nicht"
| |
− | end
| |
− | local k = io.open(oldpolls,"w+")
| |
− | k:write(tmp)
| |
− | k:flush()
| |
− | k:close()
| |
− | return time
| |
− | end
| |
− | </pre>
| |